我使用CC1310做PDM采集MIC,现在用16K的有尾音,例程里的pdmstream 工程里有一个函数不知道是做什么的
static int SA_envelopeDetector(int16_t *pPCMsamples, uint16_t numOfSamples)
{
#define FILTER_COEFF_B 3
#define FILTER_COEFF_A 1
static int filteredValue = 0;
static int slowFilteredValue = 0;
int i, newSample;
// // Scale value
// filteredValue = filteredValue * (FILTER_COEFF_B + FILTER_COEFF_A);
for (i = 0; i < numOfSamples; i++)
{
newSample = (pPCMsamples[i] > 0) ? pPCMsamples[i] : -pPCMsamples[i];
// Weigh 3/4 on new value
filteredValue += (newSample + (newSample << 1)) – (filteredValue * FILTER_COEFF_A);
// Normalize
filteredValue = (filteredValue)/(FILTER_COEFF_B + FILTER_COEFF_A);
slowFilteredValue += (filteredValue + (filteredValue << 1)) – (slowFilteredValue * FILTER_COEFF_A);
// Normalize
slowFilteredValue = (slowFilteredValue)/(FILTER_COEFF_B + FILTER_COEFF_A);
}
#define VOL_OFFSET 5
for (i = 31; i > VOL_OFFSET; i–)
{
if ((slowFilteredValue >> i) & 0x00000001)
{
break;
}
}
i = (i < 0) ? 0 : (i – VOL_OFFSET);
return i;
}
这段程序会影响音质吗?
Viki Shi:
你好,请参考这边:e2echina.ti.com/…/190661
音频的问题建议发布到E2E英文版,会有专精这块的工程师进行解答