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

user4_esp32
Posts: 21
Joined: Sun Nov 26, 2017 4:48 pm

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

Postby user4_esp32 » Sun Jun 23, 2019 11:50 pm

In the Bluetooth A2DP sink demo data callback at https://github.com/espressif/esp-idf/bl ... .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 (https://www.esp32.com/viewtopic.php?t=1756&start=20)

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)
-big-endian
-Most significant byte first
-Monochannel

Thanks.

User avatar
Jakobsen
Posts: 89
Joined: Mon Jan 16, 2017 8:12 am

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

Postby Jakobsen » Mon Jun 24, 2019 6:26 am

Hi
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
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

user4_esp32
Posts: 21
Joined: Sun Nov 26, 2017 4:48 pm

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

Postby user4_esp32 » Fri Jun 28, 2019 4:28 pm

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?

User avatar
Jakobsen
Posts: 89
Joined: Mon Jan 16, 2017 8:12 am

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

Postby Jakobsen » Mon Jul 01, 2019 7:11 am

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 https://www.cnx-software.com/2019/06/21 ... ality-aptx that will be a good starting point to dive done to the bluetooth stack and find what you are looking for.

/Jakobsen
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

Who is online

Users browsing this forum: No registered users and 58 guests