A2DP source

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

A2DP source

Postby zenman » Sat Sep 15, 2018 5:22 am

After quite a bit of trial and error with different bluetooth headphones and speakers, I finally got a speaker (and a set of headphones) connected.

When it played a sound I thought it was broken, but then found out that it was designed to play some static.

Can someone explain the bt_app_a2d_data_cb(uint8_t *data, int32_t len) method? That appears to be what is making the audio file. Can anyone suggestion how to convert an mp3 or wav or aa4 file to whatever format this is?

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Sat Sep 15, 2018 5:03 pm

I feel like I am a tiny bit closer. The docs say it is a PCM data stream. After a bit of research a .wav file is a PCM format. My next plan is to put a .wav file on an SD card, and see if I can somehow use that as the audio data.

If anyone out there knows how to do any part of this, I would love to hear from you, it will save me a lot of time.

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Sun Sep 16, 2018 6:43 pm

I feel like the code I need to make this work exists in the ADF library, but at this time I'm not smart enough to get it working. (still trying though!) There is an example called play_sdcard_wave_example.c that seems like, with some modifications, it should work.

At the moment in that example, I'm struggling to get past:

I (336) SDCARD_WAV_EXAMPLE: [ 1 ] Mount sdcard
E (336) sdmmc_io: sdmmc_io_reset: unexpected return: 0x108
E (346) SDCARD: Failed to initialize the card (264).

I'm using an SPI connected card, so I'm sure that's the cause of this particular issue. Also, anyone that gets the error:

/esp/sd_card/components/audio_service/bluetooth_service.c:221:5: error: implicit declaration of function 'esp_a2d_register_data_callback'

I found that if I comment line 221 and uncomment line 223 it gets passed the error.

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Mon Sep 17, 2018 1:37 pm

I haven't solved this yet, but I think I'm on the right track to a solution. I figure I'll just keep posting my notes here in case someone else is trying to do the same thing and ends up searching this forum for the answer.

My latest realization is that i'm using code from the esp-adf library which is reading from an SD card using SDMMC and not SPI. I was able to read/write a text file to my SD card using the example code in the esp-idf codebase, so my SD card clearly works. But... I was using the USE_SPI_MODE in that code. Up to this point I had never even heard of SDMMC, so now I'm going to try and get that to work with the esp-idf codebase.

I'm hopeful that if I can read/write using SDMMC that the esp-adf code will not throw an error on mounting the card.

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Wed Sep 26, 2018 12:02 am

Bump.

Anyone have any thoughts on how to play a .wav file or .mp3 file?

MarkIngle
Posts: 30
Joined: Wed Jan 18, 2017 4:48 am

Re: A2DP source

Postby MarkIngle » Sun Sep 30, 2018 8:54 pm

Hello! I am just starting a project using a2dp to play a PCM. will post my results here. Hopefully I will have something worthwhile to share. I found a esp32 repo with a code that mounts a SD card with a PCM file to play over BT.

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Thu Oct 11, 2018 11:14 pm

You found a repo that can play audio files? What is the link?

I have been able to get the sample code from the latest esp codebase, it plays a pretty annoying garbage sound. But I still can't figure out how to go from an SD card to a bluetooth speaker.

MarkIngle
Posts: 30
Joined: Wed Jan 18, 2017 4:48 am

Re: A2DP source

Postby MarkIngle » Tue Oct 16, 2018 1:59 am

Yes...I think its the same code you mention in your comments above...it just plays static. I am working to play a .wav file from SPIFFS. The file can be accesses and it is being sent but I dont hear anything on my bt speaker. I am getting the following error

[0;33mW (21382) BT_APPL: btc_get_num_aa_frame() - Limiting frames to be sent from 55 to 21[0m

...which is probably why I dont hear anything in the bt speakers. The wav file was created in Audacity 8-bit uncompressed format. I will keep trying different things to troubleshoot and post any finding here. Good luck to you and your attempts!

MarkIngle
Posts: 30
Joined: Wed Jan 18, 2017 4:48 am

Re: A2DP source

Postby MarkIngle » Tue Oct 16, 2018 4:21 pm

I suspect my issue might be due to the format of the wav file. It has been reformatted to 8-bit though

zenman
Posts: 7
Joined: Thu Sep 13, 2018 5:38 pm

Re: A2DP source

Postby zenman » Thu Nov 01, 2018 4:09 pm

Mark would you mind sharing the SPIFFS code that you almost got to work? Maybe if we are working on the same codebase we can figure it out together.

Who is online

Users browsing this forum: No registered users and 134 guests