I've gotten the A2DP example to work with audio output to I2S - thanks for the example code!
I have used 44100Hz / 16 bit as default, but I saw that 16000 - 48000Hz are possible. Is there a way to be notified what the SBC decoder actually found?
I tried to find out more by looking at the log output from btc_media_task.c and changed the appl_trace_level in bta_sys_main.c on line 62 to BT_TRACE_LEVEL_DEBUG, but that didn't do anything.
Also, since I have gotten the libfaad2 decoder to work I'd like to see if I can select it as an A2DP codec. I guess there is currently no interface for user-provided codecs?
A2DP Sink: how to get bit depth and sample rate
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: A2DP Sink: how to get bit depth and sample rate
hi mike,BuddyCasino wrote:I've gotten the A2DP example to work with audio output to I2S - thanks for the example code!
I have used 44100Hz / 16 bit as default, but I saw that 16000 - 48000Hz are possible. Is there a way to be notified what the SBC decoder actually found?
which SBC decoder you use?
have you example seen this this Line can notified the info - do you have your example work for A2DP and output I2S online for a lookup?
best wishes
rudi
edit, not sure how your SBC decoder looks: lookup to the header of stream.... or header info
info Side 4 and Side 5
general info
- Attachments
-
- avt-8.pdf
- Info Side 4 and 5
- (316.52 KiB) Downloaded 833 times
-
- A2DP_spec_v10.pdf
- (2.25 MiB) Downloaded 925 times
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: A2DP Sink: how to get bit depth and sample rate
Espressif conviently take care of the details, the SBC decoder is part of the Bluedroid stack in the ESP-IDF. They provide a callback function where they pass the decoded audio as PCM samples, I literally had it running in about an hour.
I added it to the webradio project, theres a guide in the Readme how to activate Bluetooth speaker mode.
I added it to the webradio project, theres a guide in the Readme how to activate Bluetooth speaker mode.
Re: A2DP Sink: how to get bit depth and sample rate
Hi Mike,
I've gotten the A2DP example to work too, but when I play audiobook over Bluetooth I've got rattling sound on PCM5102 connected to esp32. It's rather hard to understand artists' words. I don't know in which direction to dig.
I've got SBC stream (mcc.type==0)
i2s is inited as:
I send samples to i2s from callback:
Could anybody give me some hint?
I've gotten the A2DP example to work too, but when I play audiobook over Bluetooth I've got rattling sound on PCM5102 connected to esp32. It's rather hard to understand artists' words. I don't know in which direction to dig.
I've got SBC stream (mcc.type==0)
i2s is inited as:
Code: Select all
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX,
.sample_rate = 44100,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 8,
.dma_buf_len = 64,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1
};
i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 22,
.data_in_num = -1
};
i2s_driver_install(0, &i2s_config, 0, NULL);
i2s_set_pin(0, &pin_config);
i2s_set_clk(0, i2s_config.sample_rate, i2s_config.bits_per_sample, 2);
Code: Select all
void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
{
int bytes_written = i2s_write_bytes(0, (const char *)data, len, portMAX_DELAY);
if (++m_pkt_cnt % 100 == 0) {
ESP_LOGE(BT_AV_TAG, "audio data pkt cnt %u", m_pkt_cnt);
}
}
Re: A2DP Sink: how to get bit depth and sample rate
To define sample rate I do check in callback for A2DP sink: in case of ESP_A2D_AUDIO_CFG_EVT I do:BuddyCasino wrote:I have used 44100Hz / 16 bit as default, but I saw that 16000 - 48000Hz are possible. Is there a way to be notified what the SBC decoder actually found?
Code: Select all
a2d = (esp_a2d_cb_param_t *)(param);
uint8_t sbc0 = a2d->audio_cfg.mcc.cie.sbc[0];
Code: Select all
if (sbc0 & 0x80) sample_rate = 16000;
if (sbc0 & 0x40) sample_rate = 32000;
if (sbc0 & 0x20) sample_rate = 44100;
if (sbc0 & 0x10) sample_rate = 48000;
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: A2DP Sink: how to get bit depth and sample rate
Good find. Thanks!
Who is online
Users browsing this forum: No registered users and 54 guests