Загрузка данных


/**
 * @brief Duplicate left channel for the buffer
 */
static void audio_mono_to_stereo(void *buf, int len) {
	/* Assume data is 16-bit */
	uint16_t *b16 = buf;
	for (int i = len * 2 - 1; i >= 0; i--) {
		b16[i] = b16[i / 2];
	}
}

/**
 * @brief Remove right channel from audio buffer
 */
static void audio_stereo_to_mono(void *buf, int len) {
	/* Assume data is 16-bit */
	uint16_t *b16 = buf;
	for (int i = 0; i < len; i++) {
		b16[i] = b16[i * 2];
	}
}

void audio_convert_channels(int cur_chan, int out_chan, uint8_t *buf,
		size_t buf_sz) {
	if (cur_chan == out_chan) {
		return;
	}
	if (cur_chan == 1 && out_chan == 2) {
		audio_mono_to_stereo(buf, buf_sz);
	} else if (cur_chan == 2 && out_chan == 1) {
		audio_stereo_to_mono(buf, buf_sz);
	}
}

pjsip speex 16kHz mono - imxrt1064 sai stereo - нужна конверсия в обе стороны, после конверсии хриплый звук в обе стороны. Если не вызывать audio_convert_channels - ускоренный нетипичный звук....