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.
This commit is contained in:
1 parent
8a19c9c093
commit
860c6678ab
1 file changed
+1
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user