I'm using ADAU1761 in my project and its I2S output is configured to stereo 48kHz/24bit, 8 bit padding, that gives 32bit per channel, 64 BCLK per frame. However I need 16kHz/16bits. 24b to 16b can be performed by simple bitshift (>> 8). I'm having trouble with 48kHz to 16kHz conversion. I'm beginner in audio processing but as far as I understood I can't just take every 3rd sample from original audio and save because of aliasing. There must be a low pass filter but I don't know what cutoff frequency and order it should have. Target platform is STM32L4 but it's easier to just code on PC and then port the code. Here is a snippet:
fread(&WAVE_header, sizeof(WAVE_header_t), 1, pFile); // read wave header,
uint16_t* ptr = malloc(WAVE_header.SubChunk2Size); // allocate memory for audio data
fread(ptr, WAVE_header.SubChunk2Size, 1, pFile); // read audio data
uint16_t *ptrOut = malloc(WAVE_header.SubChunk2Size/3); // after resampling
for(uint32_t i = 0; i < WAVE_header.SubChunk2Size/3; i+=5){ //
ptrOut = ptr+i; // channel 1
ptrOut = ptr + 1+i; // channel 2
//filter here?
}
fwrite(ptrOut, WAVE_header.SubChunk2Size/3, 1, outFile);