Merge branch 'bugfix/hfp_demo_audio_not_sine_v4.2' into 'release/v4.2'

Bugfix/hfp demo audio not sine v4.2

See merge request espressif/esp-idf!15750
This commit is contained in:
Wang Meng Yang
2021-11-09 03:05:25 +00:00

View File

@ -116,17 +116,17 @@ static const int16_t sine_int16[] = {
-19260, -17557, -15786, -13952, -12062, -10126, -8149, -6140, -4107, -2057, -19260, -17557, -15786, -13952, -12062, -10126, -8149, -6140, -4107, -2057,
}; };
#define TABLE_SIZE_CVSD 100 #define TABLE_SIZE_CVSD 100
#define TABLE_SIZE_CVSD_BYTE 200
static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz) static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz)
{ {
static int sine_phase = 0; static int index = 0;
uint8_t *data = (uint8_t *)sine_int16;
for (int i = 0; i * 2 + 1 < sz; i++) { for (uint32_t i = 0; i < sz; i++) {
p_buf[i * 2] = sine_int16[sine_phase]; p_buf[i] = data[index++];
p_buf[i * 2 + 1] = sine_int16[sine_phase]; if (index >= TABLE_SIZE_CVSD_BYTE) {
++sine_phase; index -= TABLE_SIZE_CVSD_BYTE;
if (sine_phase >= TABLE_SIZE_CVSD) {
sine_phase -= TABLE_SIZE_CVSD;
} }
} }
return sz; return sz;