atomic14 / diy-alexa

DIY Alexa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProcessI2SData() ?

mttstt opened this issue · comments

Hi, a question: what is the processI2SData function for?

void I2SMicSampler::processI2SData(uint8_t *i2sData, size_t bytesRead)
{
    int32_t *samples = (int32_t *)i2sData;
    for (int i = 0; i < bytesRead / 4; i++)
    {
        addSample(samples[i] >> 11);
    }
}
commented

The data coming from the microphone is 32-bit samples.

But the processing code only expects 16bit samples.

We should be shifting the data from the microphone to the right by 16 bits, but the signal from the microphones - even if you are quite close - are very quiet. Shifting by 11 amplifies the signal from the microphone.

Ideally, we'd put some kind of AGC in place to avoid the need for this ammplification.