mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 16:24:04 +02:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d76b9a1ac4 | |||
| e9b6559be1 | |||
| 1bd7713e85 | |||
| e7e666d827 | |||
| 8c59e9b736 | |||
| a2698a0048 | |||
| ea42e16a79 | |||
| 14be2bd394 | |||
| a8f3cb857e | |||
| 563e1c52cb | |||
| 4520faa1d2 | |||
| 8dec4e0b9b | |||
| 69f4a19ef5 | |||
| 9374f5e8d2 | |||
| b98acd2422 | |||
| 5c099791ee | |||
| 773d97a95c | |||
| fa7cd81027 | |||
| af46c1fcc0 | |||
| 65574f44e3 | |||
| f05bb5306d | |||
| 6eeea700f0 | |||
| 04a6fe6eea |
+11
@@ -1,3 +1,14 @@
|
||||
v0.11.7 - 2023-05-27
|
||||
====================
|
||||
* Fix compilation errors with MA_USE_STDINT.
|
||||
* Fix a possible runtime error with Windows 95/98.
|
||||
* Fix a very minor linting warning in VS2022.
|
||||
* Add support for AIFF/AIFC decoding.
|
||||
* Add support for RIFX decoding.
|
||||
* Work around some bad code generation by Clang.
|
||||
* Amalgamations of dr_wav, dr_flac, dr_mp3 and c89atomic have been updated so that they're now fully namespaced. This allows each of these libraries to be able to be used alongside miniaudio without any conflicts. In addition, some duplicate code, such as sized type declarations, result codes, etc. has been removed.
|
||||
|
||||
|
||||
v0.11.16 - 2023-05-15
|
||||
=====================
|
||||
* Fix a memory leak with `ma_sound_init_copy()`.
|
||||
|
||||
+10
-10
@@ -521,7 +521,7 @@ static ma_result ma_context_uninit__sdl(ma_context* pContext)
|
||||
((MA_PFN_SDL_QuitSubSystem)pContextEx->sdl.SDL_QuitSubSystem)(MA_SDL_INIT_AUDIO);
|
||||
|
||||
/* Close the handle to the SDL shared object last. */
|
||||
ma_dlclose(pContext, pContextEx->sdl.hSDL);
|
||||
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
|
||||
pContextEx->sdl.hSDL = NULL;
|
||||
|
||||
return MA_SUCCESS;
|
||||
@@ -551,7 +551,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
|
||||
/* Check if we have SDL2 installed somewhere. If not it's not usable and we need to abort. */
|
||||
for (iName = 0; iName < ma_countof(pSDLNames); iName += 1) {
|
||||
pContextEx->sdl.hSDL = ma_dlopen(pContext, pSDLNames[iName]);
|
||||
pContextEx->sdl.hSDL = ma_dlopen(ma_context_get_log(pContext), pSDLNames[iName]);
|
||||
if (pContextEx->sdl.hSDL != NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -562,13 +562,13 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
}
|
||||
|
||||
/* Now that we have the handle to the shared object we can go ahead and load some function pointers. */
|
||||
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_InitSubSystem");
|
||||
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
|
||||
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
|
||||
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
|
||||
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
|
||||
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
|
||||
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
|
||||
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_InitSubSystem");
|
||||
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
|
||||
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
|
||||
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
|
||||
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
|
||||
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
|
||||
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
|
||||
#else
|
||||
pContextEx->sdl.SDL_InitSubSystem = (ma_proc)SDL_InitSubSystem;
|
||||
pContextEx->sdl.SDL_QuitSubSystem = (ma_proc)SDL_QuitSubSystem;
|
||||
@@ -581,7 +581,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
|
||||
resultSDL = ((MA_PFN_SDL_InitSubSystem)pContextEx->sdl.SDL_InitSubSystem)(MA_SDL_INIT_AUDIO);
|
||||
if (resultSDL != 0) {
|
||||
ma_dlclose(pContext, pContextEx->sdl.hSDL);
|
||||
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
|
||||
return MA_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+8780
-10587
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||
miniaudio - v0.11.16 - 2023-05-15
|
||||
miniaudio - v0.11.17 - 2023-05-27
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
|
||||
#define MA_VERSION_MAJOR 0
|
||||
#define MA_VERSION_MINOR 11
|
||||
#define MA_VERSION_REVISION 16
|
||||
#define MA_VERSION_REVISION 17
|
||||
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
@@ -212,6 +212,13 @@ typedef ma_uint16 wchar_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define MA_INLINE __forceinline
|
||||
|
||||
/* noinline was introduced in Visual Studio 2005. */
|
||||
#if _MSC_VER >= 1400
|
||||
#define MA_NO_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define MA_NO_INLINE
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
/*
|
||||
I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
|
||||
@@ -228,13 +235,17 @@ typedef ma_uint16 wchar_t;
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
|
||||
#define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline))
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#else
|
||||
#define MA_INLINE MA_GNUC_INLINE_HINT
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define MA_INLINE __inline
|
||||
#define MA_NO_INLINE
|
||||
#else
|
||||
#define MA_INLINE
|
||||
#define MA_NO_INLINE
|
||||
#endif
|
||||
|
||||
#if !defined(MA_API)
|
||||
@@ -464,28 +475,31 @@ typedef enum
|
||||
MA_CANCELLED = -51,
|
||||
MA_MEMORY_ALREADY_MAPPED = -52,
|
||||
|
||||
/* General non-standard errors. */
|
||||
MA_CRC_MISMATCH = -100,
|
||||
|
||||
/* General miniaudio-specific errors. */
|
||||
MA_FORMAT_NOT_SUPPORTED = -100,
|
||||
MA_DEVICE_TYPE_NOT_SUPPORTED = -101,
|
||||
MA_SHARE_MODE_NOT_SUPPORTED = -102,
|
||||
MA_NO_BACKEND = -103,
|
||||
MA_NO_DEVICE = -104,
|
||||
MA_API_NOT_FOUND = -105,
|
||||
MA_INVALID_DEVICE_CONFIG = -106,
|
||||
MA_LOOP = -107,
|
||||
MA_BACKEND_NOT_ENABLED = -108,
|
||||
MA_FORMAT_NOT_SUPPORTED = -200,
|
||||
MA_DEVICE_TYPE_NOT_SUPPORTED = -201,
|
||||
MA_SHARE_MODE_NOT_SUPPORTED = -202,
|
||||
MA_NO_BACKEND = -203,
|
||||
MA_NO_DEVICE = -204,
|
||||
MA_API_NOT_FOUND = -205,
|
||||
MA_INVALID_DEVICE_CONFIG = -206,
|
||||
MA_LOOP = -207,
|
||||
MA_BACKEND_NOT_ENABLED = -208,
|
||||
|
||||
/* State errors. */
|
||||
MA_DEVICE_NOT_INITIALIZED = -200,
|
||||
MA_DEVICE_ALREADY_INITIALIZED = -201,
|
||||
MA_DEVICE_NOT_STARTED = -202,
|
||||
MA_DEVICE_NOT_STOPPED = -203,
|
||||
MA_DEVICE_NOT_INITIALIZED = -300,
|
||||
MA_DEVICE_ALREADY_INITIALIZED = -301,
|
||||
MA_DEVICE_NOT_STARTED = -302,
|
||||
MA_DEVICE_NOT_STOPPED = -303,
|
||||
|
||||
/* Operation errors. */
|
||||
MA_FAILED_TO_INIT_BACKEND = -300,
|
||||
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -301,
|
||||
MA_FAILED_TO_START_BACKEND_DEVICE = -302,
|
||||
MA_FAILED_TO_STOP_BACKEND_DEVICE = -303
|
||||
MA_FAILED_TO_INIT_BACKEND = -400,
|
||||
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -401,
|
||||
MA_FAILED_TO_START_BACKEND_DEVICE = -402,
|
||||
MA_FAILED_TO_STOP_BACKEND_DEVICE = -403
|
||||
} ma_result;
|
||||
|
||||
|
||||
@@ -6343,7 +6357,7 @@ struct ma_encoder
|
||||
ma_encoder_uninit_proc onUninit;
|
||||
ma_encoder_write_pcm_frames_proc onWritePCMFrames;
|
||||
void* pUserData;
|
||||
void* pInternalEncoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
|
||||
void* pInternalEncoder;
|
||||
union
|
||||
{
|
||||
struct
|
||||
@@ -6408,6 +6422,33 @@ MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double freque
|
||||
MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type);
|
||||
MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ma_format format;
|
||||
ma_uint32 channels;
|
||||
ma_uint32 sampleRate;
|
||||
double dutyCycle;
|
||||
double amplitude;
|
||||
double frequency;
|
||||
} ma_pulsewave_config;
|
||||
|
||||
MA_API ma_pulsewave_config ma_pulsewave_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double dutyCycle, double amplitude, double frequency);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ma_waveform waveform;
|
||||
ma_pulsewave_config config;
|
||||
} ma_pulsewave;
|
||||
|
||||
MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsewave* pWaveform);
|
||||
MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform);
|
||||
MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
|
||||
MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint64 frameIndex);
|
||||
MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double amplitude);
|
||||
MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double frequency);
|
||||
MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 sampleRate);
|
||||
MA_API ma_result ma_pulsewave_set_duty_cycle(ma_pulsewave* pWaveform, double dutyCycle);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ma_noise_type_white,
|
||||
|
||||
+8853
-10639
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ ma_result init_data_converter(ma_uint32 rateIn, ma_uint32 rateOut, ma_resample_a
|
||||
config = ma_data_converter_config_init(ma_format_s16, ma_format_s16, 1, 1, rateIn, rateOut);
|
||||
config.resampling.algorithm = algorithm;
|
||||
|
||||
result = ma_data_converter_init(&config, pDataConverter);
|
||||
result = ma_data_converter_init(&config, NULL, pDataConverter);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ ma_result test_data_converter__resampling_expected_output_fixed_interval(ma_data
|
||||
ma_uint64 expectedOutputFrameCount;
|
||||
|
||||
/* We retrieve the required number of input frames for the specified number of output frames, and then compare with what we actually get when reading. */
|
||||
expectedOutputFrameCount = ma_data_converter_get_expected_output_frame_count(pDataConverter, frameCountPerIteration);
|
||||
ma_data_converter_get_expected_output_frame_count(pDataConverter, frameCountPerIteration, &expectedOutputFrameCount);
|
||||
|
||||
outputFrameCount = ma_countof(output);
|
||||
inputFrameCount = frameCountPerIteration;
|
||||
@@ -90,7 +90,7 @@ ma_result test_data_converter__resampling_expected_output_by_algorithm_and_rate_
|
||||
|
||||
result = test_data_converter__resampling_expected_output_fixed_interval(&converter, frameCountPerIteration);
|
||||
|
||||
ma_data_converter_uninit(&converter);
|
||||
ma_data_converter_uninit(&converter, NULL);
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
@@ -170,12 +170,6 @@ ma_result test_data_converter__resampling_expected_output()
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
printf("Speex\n");
|
||||
result = test_data_converter__resampling_expected_output_by_algorithm(ma_resample_algorithm_speex);
|
||||
if (result != 0) {
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
} else {
|
||||
@@ -205,7 +199,7 @@ ma_result test_data_converter__resampling_required_input_fixed_interval(ma_data_
|
||||
ma_uint64 requiredInputFrameCount;
|
||||
|
||||
/* We retrieve the required number of input frames for the specified number of output frames, and then compare with what we actually get when reading. */
|
||||
requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(pDataConverter, frameCountPerIteration);
|
||||
ma_data_converter_get_required_input_frame_count(pDataConverter, frameCountPerIteration, &requiredInputFrameCount);
|
||||
|
||||
outputFrameCount = frameCountPerIteration;
|
||||
inputFrameCount = ma_countof(input);
|
||||
@@ -243,7 +237,7 @@ ma_result test_data_converter__resampling_required_input_by_algorithm_and_rate_f
|
||||
|
||||
result = test_data_converter__resampling_required_input_fixed_interval(&converter, frameCountPerIteration);
|
||||
|
||||
ma_data_converter_uninit(&converter);
|
||||
ma_data_converter_uninit(&converter, NULL);
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
@@ -323,12 +317,6 @@ ma_result test_data_converter__resampling_required_input()
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
printf("Speex\n");
|
||||
result = test_data_converter__resampling_required_input_by_algorithm(ma_resample_algorithm_speex);
|
||||
if (result != MA_SUCCESS) {
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
drwav_data_format drwav_data_format_from_minaudio_format(ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
|
||||
{
|
||||
drwav_data_format wavFormat;
|
||||
|
||||
wavFormat.container = drwav_container_riff;
|
||||
wavFormat.channels = channels;
|
||||
wavFormat.sampleRate = sampleRate;
|
||||
wavFormat.bitsPerSample = ma_get_bytes_per_sample(format) * 8;
|
||||
|
||||
if (format == ma_format_f32) {
|
||||
wavFormat.format = DR_WAVE_FORMAT_IEEE_FLOAT;
|
||||
} else {
|
||||
wavFormat.format = DR_WAVE_FORMAT_PCM;
|
||||
}
|
||||
|
||||
return wavFormat;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate);
|
||||
result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, pEncoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(pDecoder);
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
bpfConfig = ma_bpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_bpf2_init(&bpfConfig, &bpf);
|
||||
result = ma_bpf2_init(&bpfConfig, NULL, &bpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
bpfConfig = ma_bpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 4);
|
||||
result = ma_bpf_init(&bpfConfig, &bpf);
|
||||
result = ma_bpf_init(&bpfConfig, NULL, &bpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@ ma_result test_dithering__u8(const char* pInputFilePath)
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, ma_format_u8, decoder.outputChannels, decoder.outputSampleRate);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, ma_format_u8, decoder.outputChannels, decoder.outputSampleRate);
|
||||
result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
@@ -30,13 +30,13 @@ ma_result test_dithering__u8(const char* pInputFilePath)
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Convert, with dithering. */
|
||||
ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
|
||||
hishelfConfig = ma_hishelf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 18, 1, 16000);
|
||||
result = ma_hishelf2_init(&hishelfConfig, &hishelf);
|
||||
result = ma_hishelf2_init(&hishelfConfig, NULL, &hishelf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hishelf2_process_pcm_frames(&hishelf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf1_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000);
|
||||
result = ma_hpf1_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf1_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_hpf2_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf2_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -142,7 +142,7 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 3);
|
||||
result = ma_hpf_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -158,13 +158,13 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
|
||||
loshelfConfig = ma_loshelf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 6, 1, 200);
|
||||
result = ma_loshelf2_init(&loshelfConfig, &loshelf);
|
||||
result = ma_loshelf2_init(&loshelfConfig, NULL, &loshelf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_loshelf2_process_pcm_frames(&loshelf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf1_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000);
|
||||
result = ma_lpf1_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf1_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_lpf2_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf2_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -143,7 +143,7 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, /*poles*/3);
|
||||
result = ma_lpf_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -159,13 +159,13 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
|
||||
}
|
||||
|
||||
notchConfig = ma_notch2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 1, 60);
|
||||
result = ma_notch2_init(¬chConfig, ¬ch);
|
||||
result = ma_notch2_init(¬chConfig, NULL, ¬ch);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_notch2_process_pcm_frames(¬ch, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
|
||||
}
|
||||
|
||||
peakConfig = ma_peak2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 24, 0, 16000);
|
||||
result = ma_peak2_init(&peakConfig, &peak);
|
||||
result = ma_peak2_init(&peakConfig, NULL, &peak);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_peak2_process_pcm_frames(&peak, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -11,12 +11,12 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
||||
printf(" %s\n", pFileName);
|
||||
|
||||
noiseConfig = ma_noise_config_init(format, 1, type, 0, 0.1);
|
||||
result = ma_noise_init(&noiseConfig, &noise);
|
||||
result = ma_noise_init(&noiseConfig, NULL, &noise);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, format, noiseConfig.channels, 48000);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, format, noiseConfig.channels, 48000);
|
||||
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
@@ -25,8 +25,8 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
||||
/* We'll do a few seconds of data. */
|
||||
for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) {
|
||||
ma_uint8 temp[1024];
|
||||
ma_noise_read_pcm_frames(&noise, temp, 1);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1);
|
||||
ma_noise_read_pcm_frames(&noise, temp, 1, NULL);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
|
||||
}
|
||||
|
||||
ma_encoder_uninit(&encoder);
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
|
||||
static drwav_data_format drwav_data_format_from_waveform_config(const ma_waveform_config* pWaveformConfig)
|
||||
{
|
||||
MA_ASSERT(pWaveformConfig != NULL);
|
||||
|
||||
return drwav_data_format_from_minaudio_format(pWaveformConfig->format, pWaveformConfig->channels, pWaveformConfig->sampleRate);
|
||||
}
|
||||
|
||||
ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type type, double amplitude, const char* pFileName)
|
||||
{
|
||||
ma_result result;
|
||||
ma_waveform_config waveformConfig;
|
||||
ma_waveform waveform;
|
||||
drwav_data_format wavFormat;
|
||||
drwav wav;
|
||||
ma_encoder_config encoderConfig;
|
||||
ma_encoder encoder;
|
||||
ma_uint32 iFrame;
|
||||
|
||||
printf(" %s\n", pFileName);
|
||||
@@ -23,19 +16,22 @@ ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type t
|
||||
return result;
|
||||
}
|
||||
|
||||
wavFormat = drwav_data_format_from_waveform_config(&waveformConfig);
|
||||
if (!drwav_init_file_write(&wav, pFileName, &wavFormat, NULL)) {
|
||||
return MA_ERROR; /* Could not open file for writing. */
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, waveformConfig.format, waveformConfig.channels, waveformConfig.sampleRate);
|
||||
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result; /* Failed to initialize encoder. */
|
||||
}
|
||||
|
||||
/* We'll do a few seconds of data. */
|
||||
for (iFrame = 0; iFrame < wavFormat.sampleRate * 10; iFrame += 1) {
|
||||
for (iFrame = 0; iFrame < waveformConfig.sampleRate * 10; iFrame += 1) {
|
||||
float temp[MA_MAX_CHANNELS];
|
||||
ma_waveform_read_pcm_frames(&waveform, temp, 1);
|
||||
drwav_write_pcm_frames(&wav, 1, temp);
|
||||
ma_waveform_read_pcm_frames(&waveform, temp, 1, NULL);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
|
||||
}
|
||||
|
||||
drwav_uninit(&wav);
|
||||
ma_encoder_uninit(&encoder);
|
||||
ma_waveform_uninit(&waveform);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user