Page 1 of 1

Data type/format in ESP-IDF A2DP-SINK demo

Posted: Sun Jun 23, 2019 11:50 pm
by user4_esp32
In the Bluetooth A2DP sink demo data callback at ... .c#L70-L77:

Code: Select all

void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
    size_t bytes_written;
    i2s_write(0, data, len, &bytes_written, portMAX_DELAY);
    if (++s_pkt_cnt % 100 == 0) {
        ESP_LOGI(BT_AV_TAG, "Audio packet count %u", s_pkt_cnt);
In what specific format and order are the bytes pointed to by *data? Specifically:

1. Signed or unsigned?
2. little-endian or big-endian?
3. most significant byte first, or least significant byte first?
4. Channel format 2 channel: 16-bit right channel data followed by 16-bit left channel data?

I saw another post where BuddyCasino mentioned the (I2S) format should be MSB first (big-endian) two's complement (signed) integer (

My goal: instead of writing the bytes to I2S, I want to convert/cast them into a pulse code modulation format as:

-Unsigned 16 bit integer (uint16_t)
-Most significant byte first


Re: Data type/format in ESP-IDF A2DP-SINK demo

Posted: Mon Jun 24, 2019 6:26 am
by Jakobsen
Data out for bluetooth sink demo si :

Signed 16 bits, big-edian, 2 channel

data[..] = { left[7:0], left[15:8], right[7:0], right[15:8],left[7:0], ... }

Regards Jakobsen

Re: Data type/format in ESP-IDF A2DP-SINK demo

Posted: Fri Jun 28, 2019 4:28 pm
by user4_esp32
Thanks very much, Jakobsen!

Would you happen to know if there is a way to set/force the esp-idf bluetooth module to output mono-channel in the bt_app_a2d_data_cb( ) callback instead of dual channel? Or a way to force the bluetooth source device to output mono-channel?

Re: Data type/format in ESP-IDF A2DP-SINK demo

Posted: Mon Jul 01, 2019 7:11 am
by Jakobsen
No i am not aware if that is possible.

In the call back function you need to do a simple stereo to mono mixer or just pick left or right channel.

But i under stand you concern on saving bandwidth from the source if you can move this process to the source it self.
Take a look at this post ... ality-aptx that will be a good starting point to dive done to the bluetooth stack and find what you are looking for.