Commit 2fd71d3a authored by David Reid's avatar David Reid

Add an encoding API.

This API is called ma_encoder. Currently it only supports encoding to
WAV files, which is done via dr_wav.
parent 4d3dcb71
This diff is collapsed.
#include "../test_common/ma_test_common.c" #include "../test_common/ma_test_common.c"
ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_decoder* pDecoder, drwav* pEncoder) ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_decoder* pDecoder, ma_encoder* pEncoder)
{ {
ma_result result; ma_result result;
ma_decoder_config decoderConfig; ma_decoder_config decoderConfig;
drwav_data_format wavFormat; ma_encoder_config encoderConfig;
decoderConfig = ma_decoder_config_init(format, 0, 0); decoderConfig = ma_decoder_config_init(format, 0, 0);
result = ma_decoder_init_file(pInputFilePath, &decoderConfig, pDecoder); result = ma_decoder_init_file(pInputFilePath, &decoderConfig, pDecoder);
...@@ -12,10 +12,11 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c ...@@ -12,10 +12,11 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
return result; return result;
} }
wavFormat = drwav_data_format_from_minaudio_format(pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate); encoderConfig = ma_encoder_config_init(ma_resource_format_wav, pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate);
if (!drwav_init_file_write(pEncoder, pOutputFilePath, &wavFormat, NULL)) { result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, pEncoder);
if (result != MA_SUCCESS) {
ma_decoder_uninit(pDecoder); ma_decoder_uninit(pDecoder);
return MA_ERROR; return result;
} }
return MA_SUCCESS; return MA_SUCCESS;
......
ma_result bpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, drwav* pEncoder) ma_result bpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, ma_encoder* pEncoder)
{ {
return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder); return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder);
} }
...@@ -8,13 +8,13 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -8,13 +8,13 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_bpf2_config bpfConfig; ma_bpf2_config bpfConfig;
ma_bpf2 bpf; ma_bpf2 bpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = bpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = bpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -23,7 +23,7 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -23,7 +23,7 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_bpf2_init(&bpfConfig, &bpf); result = ma_bpf2_init(&bpfConfig, &bpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -42,14 +42,14 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -42,14 +42,14 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead); ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -68,13 +68,13 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -68,13 +68,13 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_bpf_config bpfConfig; ma_bpf_config bpfConfig;
ma_bpf bpf; ma_bpf bpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = bpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = bpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -83,7 +83,7 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -83,7 +83,7 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_bpf_init(&bpfConfig, &bpf); result = ma_bpf_init(&bpfConfig, &bpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -102,14 +102,14 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -102,14 +102,14 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead); ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
......
...@@ -5,8 +5,8 @@ ma_result test_dithering__u8(const char* pInputFilePath) ...@@ -5,8 +5,8 @@ ma_result test_dithering__u8(const char* pInputFilePath)
ma_result result; ma_result result;
ma_decoder_config decoderConfig; ma_decoder_config decoderConfig;
ma_decoder decoder; ma_decoder decoder;
drwav_data_format wavFormat; ma_encoder_config encoderConfig;
drwav wav; ma_encoder encoder;
decoderConfig = ma_decoder_config_init(ma_format_f32, 0, 0); decoderConfig = ma_decoder_config_init(ma_format_f32, 0, 0);
result = ma_decoder_init_file(pInputFilePath, &decoderConfig, &decoder); result = ma_decoder_init_file(pInputFilePath, &decoderConfig, &decoder);
...@@ -14,10 +14,11 @@ ma_result test_dithering__u8(const char* pInputFilePath) ...@@ -14,10 +14,11 @@ ma_result test_dithering__u8(const char* pInputFilePath)
return result; return result;
} }
wavFormat = drwav_data_format_from_minaudio_format(ma_format_u8, decoder.outputChannels, decoder.outputSampleRate); encoderConfig = ma_encoder_config_init(ma_resource_format_wav, ma_format_u8, decoder.outputChannels, decoder.outputSampleRate);
if (!drwav_init_file_write(&wav, pOutputFilePath, &wavFormat, NULL)) { result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, &encoder);
if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
return MA_ERROR; return result;
} }
for (;;) { for (;;) {
...@@ -35,14 +36,14 @@ ma_result test_dithering__u8(const char* pInputFilePath) ...@@ -35,14 +36,14 @@ ma_result test_dithering__u8(const char* pInputFilePath)
ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle); ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
......
ma_result hpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, drwav* pEncoder) ma_result hpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, ma_encoder* pEncoder)
{ {
return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder); return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder);
} }
...@@ -8,13 +8,13 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -8,13 +8,13 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_hpf1_config hpfConfig; ma_hpf1_config hpfConfig;
ma_hpf1 hpf; ma_hpf1 hpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -23,7 +23,7 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -23,7 +23,7 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_hpf1_init(&hpfConfig, &hpf); result = ma_hpf1_init(&hpfConfig, &hpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -42,14 +42,14 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -42,14 +42,14 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -68,13 +68,13 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -68,13 +68,13 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_hpf2_config hpfConfig; ma_hpf2_config hpfConfig;
ma_hpf2 hpf; ma_hpf2 hpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -83,7 +83,7 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -83,7 +83,7 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_hpf2_init(&hpfConfig, &hpf); result = ma_hpf2_init(&hpfConfig, &hpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -102,14 +102,14 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -102,14 +102,14 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -128,13 +128,13 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -128,13 +128,13 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_hpf_config hpfConfig; ma_hpf_config hpfConfig;
ma_hpf hpf; ma_hpf hpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = hpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -143,7 +143,7 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -143,7 +143,7 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_hpf_init(&hpfConfig, &hpf); result = ma_hpf_init(&hpfConfig, &hpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -162,14 +162,14 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -162,14 +162,14 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
......
ma_result lpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, drwav* pEncoder) ma_result lpf_init_decoder_and_encoder(const char* pInputFilePath, const char* pOutputFilePath, ma_format format, ma_decoder* pDecoder, ma_encoder* pEncoder)
{ {
return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder); return filtering_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, 0, 0, pDecoder, pEncoder);
} }
...@@ -8,13 +8,13 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -8,13 +8,13 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_lpf1_config lpfConfig; ma_lpf1_config lpfConfig;
ma_lpf1 lpf; ma_lpf1 lpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -23,7 +23,7 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -23,7 +23,7 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_lpf1_init(&lpfConfig, &lpf); result = ma_lpf1_init(&lpfConfig, &lpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -42,14 +42,14 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -42,14 +42,14 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -68,13 +68,13 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -68,13 +68,13 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_lpf2_config lpfConfig; ma_lpf2_config lpfConfig;
ma_lpf2 lpf; ma_lpf2 lpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -83,7 +83,7 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -83,7 +83,7 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_lpf2_init(&lpfConfig, &lpf); result = ma_lpf2_init(&lpfConfig, &lpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -102,14 +102,14 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -102,14 +102,14 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -129,13 +129,13 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -129,13 +129,13 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
{ {
ma_result result; ma_result result;
ma_decoder decoder; ma_decoder decoder;
drwav wav; ma_encoder encoder;
ma_lpf_config lpfConfig; ma_lpf_config lpfConfig;
ma_lpf lpf; ma_lpf lpf;
printf(" %s\n", pOutputFilePath); printf(" %s\n", pOutputFilePath);
result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &wav); result = lpf_init_decoder_and_encoder(pInputFilePath, pOutputFilePath, format, &decoder, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
...@@ -144,7 +144,7 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -144,7 +144,7 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
result = ma_lpf_init(&lpfConfig, &lpf); result = ma_lpf_init(&lpfConfig, &lpf);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return result; return result;
} }
...@@ -163,14 +163,14 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi ...@@ -163,14 +163,14 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* Write to the WAV file. */
drwav_write_pcm_frames(&wav, framesJustRead, tempOut); ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
if (framesJustRead < framesToRead) { if (framesJustRead < framesToRead) {
break; break;
} }
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
return MA_SUCCESS; return MA_SUCCESS;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment