From 860c6678ab20a9fc98ddcf11688f95f22b62c6ae Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 20 Nov 2017 07:04:11 -0800 Subject: [PATCH] Fix noise during amplification @armSeb, in issue 7, noticed noise being introduced when amplifying the output. By moving the amplification to right before submitting the sample to I2S it went away. Update with his suggested fix. --- src/AudioOutputI2SDAC.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/AudioOutputI2SDAC.cpp b/src/AudioOutputI2SDAC.cpp index 0cb1be6..a104aa0 100644 --- a/src/AudioOutputI2SDAC.cpp +++ b/src/AudioOutputI2SDAC.cpp @@ -75,15 +75,13 @@ bool AudioOutputI2SDAC::begin() bool AudioOutputI2SDAC::ConsumeSample(int16_t sample[2]) { MakeSampleStereo16( sample ); - sample[0] = Amplify(sample[0]); - sample[1] = Amplify(sample[1]); if (this->mono) { // Average the two samples and overwrite uint32_t ttl = sample[LEFTCHANNEL] + sample[RIGHTCHANNEL]; sample[LEFTCHANNEL] = sample[RIGHTCHANNEL] = (ttl>>1) & 0xffff; } - uint32_t s32 = ((sample[RIGHTCHANNEL])<<16) | (sample[LEFTCHANNEL] & 0xffff); + uint32_t s32 = ((Amplify(sample[RIGHTCHANNEL]))<<16) | (Amplify(sample[LEFTCHANNEL]) & 0xffff); return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true }