From 4c77950e702a329f3136456a932efbea36e03d42 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 19 Apr 2023 16:45:50 +1000 Subject: Pipeline working and outputting correctly, but noisy --- src/codecs/mad.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/codecs') diff --git a/src/codecs/mad.cpp b/src/codecs/mad.cpp index 020e0d57..7e5b350b 100644 --- a/src/codecs/mad.cpp +++ b/src/codecs/mad.cpp @@ -9,7 +9,7 @@ namespace codecs { -static int scaleTo24Bits(mad_fixed_t sample) { +static int scaleTo16Bits(mad_fixed_t sample) { // Round the bottom bits. sample += (1L << (MAD_F_FRACBITS - 16)); @@ -19,7 +19,7 @@ static int scaleTo24Bits(mad_fixed_t sample) { else if (sample < -MAD_F_ONE) sample = -MAD_F_ONE; - /* quantize */ + // Quantize. return sample >> (MAD_F_FRACBITS + 1 - 16); } @@ -119,10 +119,10 @@ auto MadMp3Decoder::WriteOutputSamples(cpp::span output) } for (int channel = 0; channel < synth_.pcm.channels; channel++) { - uint32_t sample_24 = - scaleTo24Bits(synth_.pcm.samples[channel][current_sample_]); - output[output_byte++] = static_cast((sample_24 >> 8) & 0xFF); - output[output_byte++] = static_cast((sample_24)&0xFF); + uint16_t sample_16 = + scaleTo16Bits(synth_.pcm.samples[channel][current_sample_]); + output[output_byte++] = static_cast((sample_16 >> 8) & 0xFF); + output[output_byte++] = static_cast((sample_16)&0xFF); } current_sample_++; } -- cgit v1.2.3