ESP32-A2DP icon indicating copy to clipboard operation
ESP32-A2DP copied to clipboard

IOS poor quality audio

Open Leo-Ha opened this issue 10 months ago • 20 comments

Problem Description

No matter how i play with the settings, it seems i only get very poor audio quality when i stream audio from IOS device through A2DP, with android it works flawlessly. Is there a solution for this? I checked all realted issues and searched online but did not find a solutrion myself

Device Description

ESP32-WROOM and Iphone 12 External DAC PCM5102A

Sketch

#include "BluetoothA2DPSinkQueued.h"

BluetoothA2DPSinkQueued a2dp_sink;

void setup() {
  a2dp_sink.start("MyMusicQueued");  

}


void loop() {
  delay(1000); // do nothing
}

Other Steps to Reproduce

No response

Provide your Version of the EP32 Arduino Core (or the IDF Version)

2.3.2

I have checked existing issues, discussions and online documentation

  • [X] I confirm I have checked existing issues, discussions and online documentation

Leo-Ha avatar Apr 04 '24 19:04 Leo-Ha

With my old IOS devices it is working w/o any problems. I am not buying any recent Hardware from Apple any more, so I can't reproduce this.

pschatzmann avatar Apr 06 '24 21:04 pschatzmann

Is there a way to add AAC codec support? I think it may be due to ios not liking the SBC codex too much.

With my old IOS devices it is working w/o any problems. I am not buying any recent Hardware from Apple any more, so I can't reproduce this.

Leo-Ha avatar Apr 07 '24 11:04 Leo-Ha

No, as far as I know, only SBC is supported by Espressif

pschatzmann avatar Apr 07 '24 11:04 pschatzmann

I found this by esperiff

https://docs.espressif.com/projects/esp-adf/en/latest/api-reference/codecs/aac_decoder.html

Leo-Ha avatar Apr 07 '24 13:04 Leo-Ha

I don't understand, where is the connection with A2DP ? Here is the link to the relevant API

pschatzmann avatar Apr 07 '24 14:04 pschatzmann

I don't understand, where is the connection with A2DP ? Here is the link to the relevant API

Oh okay, in your linked document AAC is mentioned in this

uint8_t m24[ESP_A2D_CIE_LEN_M24] MPEG-2, 4 AAC audio codec capabilities

do you know what this means? And would you know is the AAC support limited by hardware on the esp32 or just software?

Leo-Ha avatar Apr 07 '24 14:04 Leo-Ha

But I did not find any method where you could provide this information....

pschatzmann avatar Apr 07 '24 14:04 pschatzmann

But I did not find any method where you could provide this information....

I dont really understand the documentation or what you mean by that, i will try to search if theres a way to add AAC support but seems im out of luck with this one

Leo-Ha avatar Apr 07 '24 14:04 Leo-Ha

no updates?

bobisaperson1 avatar Jun 25 '24 12:06 bobisaperson1

no updates?

I never did manage to get the setup working, i think the esp32's and iphones bt codecs are just incompitable so that it struggles with the audio. Iphone prefers to use AAC codec while esp32 only supports SBC codec.

Leo-Ha avatar Jun 25 '24 16:06 Leo-Ha

I worked out that if the volume on the IPhone is all the way up and ignoring the background noise issue mentioned in a different issue then the sound is as good as you would expect, it’s only when the volume is part way that it sounds horrible, and I testing with a cheap android I have laying around and fount the same thing, is there any way of “blocking” the volume from changing when connected, like how on Mac when connected to a usb DAC the volume bar is greyed out and can’t be changed

bobisaperson1 avatar Jun 25 '24 17:06 bobisaperson1

do you have an example for "very poor audio quality"?

harryberlin avatar Jun 25 '24 18:06 harryberlin

I’ll try recording it and come back here later with a link

bobisaperson1 avatar Jun 26 '24 03:06 bobisaperson1

https://audio.com/bfulham/audio/esp32-test

it came out different to how it sounded straight off the esp32 as the recording has more background noise even at the full volume and didnt distort as much when at part volume compared to earphones off the esp32

bobisaperson1 avatar Jun 26 '24 08:06 bobisaperson1

I have ordered an external dac and amp (Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A) to test if this is still an issue without using the internal dac

bobisaperson1 avatar Jun 26 '24 08:06 bobisaperson1

If this is with your internal DAC, my first guess would be a noisy power supply Did you test with a simple sine test sketch ?

pschatzmann avatar Jun 26 '24 08:06 pschatzmann

I did not but as I have ordered the DAC I am not going to worry about doing further testing, I also noticed an error on the readme for that test sketch and have submitted changes

bobisaperson1 avatar Jun 26 '24 09:06 bobisaperson1

I have ordered an external dac and amp (Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A) to test if this is still an issue without using the internal dac

I can record the sound later with my 16bit dac i have for the project and connecting that to an aux speaker. I will also try with the esp32S3 instead of the basic, maybe it has some improvments made.

Leo-Ha avatar Jun 26 '24 09:06 Leo-Ha

Out of necessity, I installed Squeezelite on the ESP. I had no problem with the same DAC using an iPhone. Unfortunately, since I do not own an iPhone myself, I couldn't generate logs with A2DP. However, the issue with the DAC can be ruled out.

MarcelNox avatar Jun 26 '24 16:06 MarcelNox

I had some luck with the OP's issue, see here. Might be something else, but it worked for me.

mooballs avatar Jun 27 '24 20:06 mooballs