Page 1 of 1

a2dp sink low volume

Posted: Sat Jul 13, 2019 8:22 am
by DonIdaGreat
Greetings!

I am using wroom-32D and eclipse for flashing. I managed to get the a2dp sink example working with I2S_MODE_DAC_BUILT_IN.
I changed only the bt_app_a2d_data_cb function in bt_app_av.c as suggested in this forum:

Code: Select all

uint16_t buffer[2048];
void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
{
    size_t bytes_written;
    for(int i = 0; i < 2048; i++){
        buffer[i] = ((int16_t*)data)[i] + 0x8000;
    }

    i2s_write(0, (const uint8_t*) buffer, len, &bytes_written, portMAX_DELAY);
    if (++s_pkt_cnt % 100 == 0) {
        ESP_LOGI(BT_AV_TAG, "Audio packet count %u", s_pkt_cnt);
    }
}
I can hear the sound when connected to my speaker but with very low volume. The command

Code: Select all

volume_set_by_local_host
does not really make a difference and in the file synthesis-8-generated.c changing the

Code: Select all

#define MUL_16S_16S(_x, _y) ((_x) * (_y))
to for example

Code: Select all

#define MUL_16S_16S(_x, _y) ((_x)*4 * (_y))
just makes the audio terrible.

My extremely old oscilloscope gives the following when no audio is playing with gpio 26 channel inverted, so it is pretty much identical with gpio 25. Gpio 26 has a 1 uF capacitor in series :
IMG_20190713_111039.jpg
IMG_20190713_111039.jpg (3.19 MiB) Viewed 3205 times
And when playing:
IMG_20190713_111102.jpg
IMG_20190713_111102.jpg (3.19 MiB) Viewed 3205 times
Is this normal? Why the positive voltage peak is cut off? How could i make the volume louder? How could I eliminate the random cliches that hear every 10s or so....?

Also additional question, I have seen examples where the deprecated i2s_push_sample() has been used with separate data[2] for left and right channels. How is i2s_write() handling the stereo issue?

Thanks for any help!


My sdkconfig.default

Code: Select all

CONFIG_BT_ENABLED=y
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CTRL_MODE_BTDM=
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_SPP_ENABLED=n
CONFIG_BT_GATTS_ENABLE=n
CONFIG_BT_GATTC_ENABLE=n
CONFIG_BT_BLE_SMP_ENABLE=n