void audio_upsample_to_32k(const int16_t *src, int32_t *dst, uint8_t src_channels, uint32_t src_framerate)
{
const uint32_t target_framerate = 32000;
uint32_t factor = target_framerate / src_framerate;
uint32_t src_frames = (src_framerate / 10);
uint32_t dst_idx = 0;
for (uint32_t f = 0; f < src_frames; f++) {
for (uint32_t rep = 0; rep < factor; rep++) {
if (src_channels == 2) {
/* STEREO: Convert to int32_t */
dst[dst_idx] = ((int32_t)src[f * 2]) << 16; // Left
dst[dst_idx + 1] = ((int32_t)src[f * 2 + 1]) << 16; // Right
dst_idx += 2;
} else {
/* MONO: Duplicate the mono signal into both 32-bit channels*/
int32_t mono_sample = ((int32_t)src[f]) << 16;
dst[dst_idx] = mono_sample; // Left
dst[dst_idx + 1] = mono_sample; // Right
dst_idx += 2;
}
}
}
}