Closed BananaLoaf closed 3 years ago
interesting, have never come across this before and don't have the same hardware so I will struggle to reproduce. To help me isolate the problem could you do the following
.dma_buf_count = 2,
.dma_buf_len = 8,
Even changing .communication_format did not help
very puzzling,
some more questions.
E (23042) BT_APPL: bta_av_rc_create ACP handle exist for shdl:0
I (23042) BT_AV: A2DP connection state: Connecting, [04:ea:56:3e:a4:df]
I (23062) BT_AV: A2DP audio stream configuration, codec type 0
I (23062) I2S: PLL_D2: Req RATE: 48000, real rate: 48076.000, BITS: 16, CLKM: 13, BCK: 8, MCLK: 12292917.167, SCLK: 1538432.000000, diva: 64, divb: 1
I (23072) BT_AV: Configure audio player 11-15-2-33
I (23072) BT_AV: Audio player configured, sample rate=48000
Yet when I connect my phone it is set to 44100
E (274662) BT_APPL: bta_av_rc_create ACP handle exist for shdl:0
I (274672) BT_AV: A2DP connection state: Connecting, [f0:5c:77:d9:85:93]
I (274792) BT_AV: A2DP audio stream configuration, codec type 0
I (274792) I2S: PLL_D2: Req RATE: 44100, real rate: 44642.000, BITS: 16, CLKM: 14, BCK: 8, MCLK: 11289966.924, SCLK: 1428544.000000, diva: 64, divb: 11
I (274802) BT_AV: Configure audio player 21-15-2-35
I (274812) BT_AV: Audio player configured, sample rate=44100
Sample rate does not change while playing audio
Manually changing sample rate to 48000 fixed pitch and slowdowns on the PC, but phone audio is now pitched up
Great work. I think you're laptop is requesting 48000 and this isn't being acknowledged properly in my code but is in the IDF code. I think I just need to write in a callback to flexibly adapt to different sampling rates. Will work on this over the next few days.
Thank you for your work! I really appreciate it!
will forget if closed
OK, fix to determine sample rate automatically is live. I can't really test this for any 48KHz source so if @BananaLoaf could test and report back that would be great.
Unfortunately, bug is still present
With the debug notifications turned on what is the output?
OK, attempt 2 is up and should change the sample rate. the previous attempt only worked if the connection was made before i2s configuration.
The output for phone audio was
[I][btAudio.cpp:77] a2d_cb(): A2DP audio stream configuration, codec type 0
[I][btAudio.cpp:93] a2d_cb(): Configure audio player 21-15-2-35
[I][btAudio.cpp:94] a2d_cb(): Audio player configured, sample rate=44100
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 0
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 5
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 0
And for PC
[I][btAudio.cpp:77] a2d_cb(): A2DP audio stream configuration, codec type 0
[I][btAudio.cpp:93] a2d_cb(): Configure audio player 11-15-2-33
[I][btAudio.cpp:94] a2d_cb(): Audio player configured, sample rate=48000
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 0
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 5
[E][btAudio.cpp:99] a2d_cb(): a2dp invalid cb event: 1
[E][btAudio.cpp:144] avrc_callback(): unhandled AVRC event: 0
[E][btAudio.cpp:99] a2d_cb(): a2dp invalid cb event: 1
But now at all seems to be working correctly, although I'm getting a little bit of static noise, but I guess that's just my crappy speakers or cable
Is this static specific to my code or do you observe it with the IDF code as well? I sometimes get bad "static" from bad wiring, amplifier not having enough power or the gain on the amplifier (max98357A) changing due to interference.
I'm not much of the expert in this, but static went away after I disconnected DAC board from ground (???). I have not checked other examples for static with GND plugged in, but I will let you know if I discover something.
closing as initial pitch issue solved
Sound is pitched down, songs (played via Spotify) start slowed down but later (4-5 sec) get to their normal speed.
I use Wemos D1 mini ESP32 + PCM5102 I2S DAC Decoder Board
I'm aware that problem might be specific to my hardware or software(pipewire), but it does not persist when I use https://github.com/pschatzmann/ESP32-A2DP or https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/bluedroid/classic_bt/a2dp_sink