From e4784182c5393f614f1506bef33a0427ed8362a6 Mon Sep 17 00:00:00 2001 From: Dimitri Diakopoulos Date: Sun, 17 May 2015 18:24:18 -0700 Subject: [PATCH] simplify encoderparams --- examples/src/Main.cpp | 2 +- include/libnyquist/RiffUtils.h | 2 -- src/RiffUtils.cpp | 8 +++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/src/Main.cpp b/examples/src/Main.cpp index ec3ea53..31ace8e 100644 --- a/examples/src/Main.cpp +++ b/examples/src/Main.cpp @@ -98,7 +98,7 @@ int main() } // Test wav file encoder - encoder.WriteFile({2, 44100, 32, PCM_FLT, DITHER_NONE}, fileData, "encoded.wav"); + encoder.WriteFile({2, PCM_FLT, DITHER_NONE}, fileData, "encoded.wav"); return 0; } \ No newline at end of file diff --git a/include/libnyquist/RiffUtils.h b/include/libnyquist/RiffUtils.h index 31eab26..ece940e 100644 --- a/include/libnyquist/RiffUtils.h +++ b/include/libnyquist/RiffUtils.h @@ -40,8 +40,6 @@ namespace nqr struct EncoderParams { int channelCount; - int sampleRate; - int bitDepth; PCMFormat targetFormat; DitherType dither; }; diff --git a/src/RiffUtils.cpp b/src/RiffUtils.cpp index 7c7fc52..67c60f0 100644 --- a/src/RiffUtils.cpp +++ b/src/RiffUtils.cpp @@ -53,14 +53,16 @@ WaveChunkHeader nqr::MakeWaveHeader(const EncoderParams param) { WaveChunkHeader header; + int bitdepth = GetFormatBitsPerSample(param.targetFormat); + header.fmt_id = GenerateChunkCode('f', 'm', 't', ' '); header.chunk_size = 16; header.format = (param.targetFormat <= PCMFormat::PCM_32) ? WaveFormatCode::FORMAT_PCM : WaveFormatCode::FORMAT_IEEE; header.channel_count = param.channelCount; header.sample_rate = param.sampleRate; - header.data_rate = param.sampleRate * param.channelCount * (param.bitDepth / 8); - header.frame_size = param.channelCount * (param.bitDepth / 8); - header.bit_depth = param.bitDepth; + header.data_rate = param.sampleRate * param.channelCount * (bitdepth / 8); + header.frame_size = param.channelCount * (bitdepth/ 8); + header.bit_depth = bitdepth; return header; } \ No newline at end of file