CarlosDerSeher / snapclient

snapclient on ESP32
GNU General Public License v3.0
101 stars 14 forks source link

Crackling/Distortion after a few seconds of playback #55

Closed BenediktMueller91 closed 4 months ago

BenediktMueller91 commented 5 months ago

With current master on my setup there is crackling/distortion building up after a few seconds. The audio then stays in a listenable but distorted state after that. This is best discernable in speech.

Current Setup:

ESP32-MAX98357A

CarlosDerSeher commented 5 months ago

Is there anything supicious in your logs?

Maybe related to DSP/Software volume? Could you test without?

Also could you try using standard sdkconfig and do settings for psram, board etc. yourself. Maybe sdkconfig_PSRAM_lyrat_v4.3 is faulty for some reason.

If that doesn't help maybe go back in time, you could start by trying commit 06161ae385524cf52a8ad29472a81db39e296563

BenediktMueller91 commented 5 months ago

I redid the sdkconfig based on the one in master and only changed wifi, board, and psram.

Unfortunately the logs are pretty empty and do not indicate any issues. I recompiled with CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y (and changed the nvs partition size to fix the overlap issue when doing so).

I (4759) OTA: idf.py build ; curl snapclient.local:8032 --data-binary @- < build/snapclient.bin
I (7839) SC: Found 192.168.1.16:1704
I (7843) SC: netconn connected
I (7845) SC: netconn sent hello message
I (7854) SC: Buffer length:  750
I (7854) SC: Latency:        10
I (7854) SC: Mute:           0
I (7856) SC: Setting volume: 14
I (7861) SC: fLaC sampleformat: 48000:16:2
I (7894) PLAYER: player_setup_i2s: dma_buf_len is 576, dma_buf_count is 4
I (7895) c_I2S: DMA Malloc info, datalen=blocksize=2304, dma_buf_count=4
I (7900) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (7912) GENERIC_BOARD: I2S0, MCLK output by GPIO0
I (7920) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
W (7932) PLAYER: no pcm chunk queue created?
I (7937) PLAYER: created new queue with 30
I (7941) PLAYER: snapserver config changed, buffer 750ms, chunk 1152 frames, sample rate 48000, ch 2, bits 16 mute 0 latency 10
I (8055) SC: latency buffer full
I (8802) PLAYER: initial sync age: 2us, chunk duration: 24000us

Also the issue still persists when disabling the DSP functionality - except now there is also some distortion from the poor speaker struggling with the volume ;)

I then cherry-picked the commit Added support for MAX98357 (#46) onto https://github.com/CarlosDerSeher/snapclient/commit/06161ae385524cf52a8ad29472a81db39e296563 and recompiled. The issue persists.

The crackling is gone for a few seconds everytime i switch snapcast sources or pause the playback on the source. Are there some debug logs regarding the i2s/playback buffer stats that i could activate? See if there are some buffers that run dry.

CarlosDerSeher commented 5 months ago

You could enable logs around here https://github.com/CarlosDerSeher/snapclient/blob/master/components%2Flightsnapcast%2Fplayer.c#L1510 but I don't think it will help here. Still, please try.

Because of the loud volume could you just lower the volume on your input source to the server to ensure it isn't a dsp issue. I guess you are unable to hear the crackling with soft volume disabled because of the speaker distortion?

Also did you ensure it isn't a server issue? Do other architecture clients have this issue too (probably not)?

Another thing you could try is to disable apll tuning temporarily. The DAC doesn't have a MCLK line does it? I am not sure how this affects operation. I don't think it should be a problem as the others signal timings also change with MCLK timing but who knows.

I don't have this particular DAC so maybe someone else can report if he has similar issues, you could check if the DAC is correctly initialized by the driver. Maybe something is wrong there?

BenediktMueller91 commented 5 months ago

Other clients on my network play fine. I have a few around the house (Raspberry Pi 4B, Raspberry Pi 5, Snapweb).

Even without DSP and softvolume i can still hear the crackling over the slight distortion of the overdriven speaker. Reducing volume on the source side was a good idea. Just had to enable volume on the mopidy instance again.

I enabled the log in L1510 as mentioned. I get the feeling that the distortion is tied to the APLL direction switching. When it gets to the point where it oscillates the distortion becomes the strongest.

# L1510 Log Enabled
E (4259) esp_ota_ops: Running firmware is factory
I (4260) OTA: idf.py build ; curl snapclient.local:8032 --data-binary @- < build/snapclient.bin
I (7340) SC: Found 192.168.1.16:1704
I (7344) SC: netconn connected
I (7346) SC: netconn sent hello message
I (7350) SC: Buffer length:  750
I (7350) SC: Latency:        10
I (7350) SC: Mute:           0
I (7352) SC: Setting volume: 14
I (7357) SC: fLaC sampleformat: 48000:16:2
I (7394) PLAYER: player_setup_i2s: dma_buf_len is 576, dma_buf_count is 2
I (7395) c_I2S: DMA Malloc info, datalen=blocksize=2304, dma_buf_count=2
I (7400) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (7412) GENERIC_BOARD: I2S0, MCLK output by GPIO0
I (7420) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
W (7432) PLAYER: no pcm chunk queue created?
I (7437) PLAYER: created new queue with 31
I (7441) PLAYER: snapserver config changed, buffer 750ms, chunk 1152 frames, sample rate 48000, ch 2, bits 16 mute 0 latency 10
I (9351) SC: latency buffer full
I (10080) PLAYER: initial sync age: 2us, chunk duration: 24000us
I (10102) PLAYER: 0, -231us, -231us 6150986s, 254.116ms
I (10150) PLAYER: 0, -252us, -252us 6150986s, 254.116ms
I (10198) PLAYER: 0, -214us, -214us 6150986s, 254.116ms
I (10246) PLAYER: 0, -236us, -236us 6150986s, 254.116ms
I (10294) PLAYER: 0, -128us, -128us 6150986s, 254.116ms
I (10342) PLAYER: 0, -240us, -240us 6150986s, 254.116ms
I (10390) PLAYER: 0, -227us, -227us 6150986s, 254.121ms
I (10438) PLAYER: 0, -235us, -235us 6150986s, 254.121ms
I (10486) PLAYER: 0, -234us, -234us 6150986s, 254.121ms
I (10534) PLAYER: 0, -191us, -191us 6150986s, 254.121ms
I (10582) PLAYER: 0, -244us, -244us 6150986s, 254.121ms
I (10630) PLAYER: 0, -241us, -241us 6150986s, 254.121ms
I (10678) PLAYER: 0, -253us, -253us 6150986s, 254.121ms
I (10726) PLAYER: 0, -250us, -250us 6150986s, 254.121ms
I (10774) PLAYER: 0, -239us, -239us 6150986s, 254.121ms
I (10822) PLAYER: 0, -231us, -231us 6150986s, 254.121ms
I (10870) PLAYER: 0, -254us, -254us 6150986s, 254.121ms
I (10918) PLAYER: 0, -213us, -213us 6150986s, 254.121ms
I (10966) PLAYER: 0, -242us, -242us 6150986s, 254.121ms
I (11014) PLAYER: 0, -253us, -253us 6150986s, 254.121ms
I (11062) PLAYER: 0, -251us, -251us 6150986s, 254.121ms
I (11110) PLAYER: 0, -228us, -228us 6150986s, 254.121ms
I (11158) PLAYER: 0, -231us, -231us 6150986s, 254.121ms
I (11206) PLAYER: 0, -248us, -248us 6150986s, 254.121ms
I (11254) PLAYER: 0, -206us, -206us 6150986s, 254.121ms
I (11302) PLAYER: 0, -247us, -247us 6150986s, 254.121ms
I (11350) PLAYER: 0, -242us, -242us 6150986s, 254.121ms
I (11398) PLAYER: 0, -247us, -247us 6150986s, 254.121ms
I (11446) PLAYER: 0, -244us, -244us 6150986s, 254.121ms
I (11494) PLAYER: 0, -232us, -232us 6150986s, 254.121ms
I (11542) PLAYER: 0, -240us, -240us 6150986s, 254.121ms
I (11590) PLAYER: 0, -226us, -226us 6150986s, 254.121ms
I (11638) PLAYER: 0, -210us, -210us 6150986s, 254.121ms
I (11686) PLAYER: 0, -244us, -244us 6150986s, 254.121ms
I (11734) PLAYER: 0, -252us, -252us 6150986s, 254.121ms
I (11782) PLAYER: 0, -245us, -245us 6150986s, 254.121ms
I (11830) PLAYER: 0, -229us, -229us 6150986s, 254.121ms
I (11878) PLAYER: 0, -238us, -238us 6150986s, 254.121ms
I (11926) PLAYER: 0, -233us, -233us 6150986s, 254.121ms
I (11974) PLAYER: 0, -206us, -206us 6150986s, 254.121ms
I (12022) PLAYER: 0, -236us, -236us 6150986s, 254.121ms
I (12070) PLAYER: 0, -244us, -244us 6150986s, 254.121ms
I (12118) PLAYER: 0, -250us, -250us 6150986s, 254.121ms
I (12166) PLAYER: 0, -235us, -235us 6150986s, 254.121ms
I (12214) PLAYER: 0, -235us, -235us 6150986s, 254.121ms
I (12262) PLAYER: 0, -238us, -238us 6150986s, 254.121ms
I (12310) PLAYER: 0, -253us, -253us 6150986s, 254.121ms
I (12358) PLAYER: 0, -204us, -204us 6150986s, 254.121ms
I (12406) PLAYER: 0, -242us, -242us 6150986s, 254.122ms
I (12454) PLAYER: -1, -246us, -246us 6150986s, 254.122ms
I (12502) PLAYER: -1, -241us, -241us 6150986s, 254.122ms
I (12550) PLAYER: -1, -234us, -234us 6150986s, 254.122ms
I (12598) PLAYER: -1, -213us, -213us 6150986s, 254.122ms
I (12646) PLAYER: -1, -220us, -220us 6150986s, 254.122ms
I (12694) PLAYER: -1, -168us, -168us 6150986s, 254.122ms
I (12742) PLAYER: -1, -214us, -214us 6150986s, 254.122ms
I (12790) PLAYER: -1, -205us, -205us 6150986s, 254.122ms
I (12838) PLAYER: -1, -201us, -201us 6150986s, 254.122ms
I (12886) PLAYER: -1, -146us, -146us 6150986s, 254.122ms
I (12934) PLAYER: -1, -184us, -184us 6150986s, 254.122ms
I (12982) PLAYER: -1, -173us, -173us 6150986s, 254.122ms
I (13030) PLAYER: -1, -186us, -186us 6150986s, 254.122ms
I (13078) PLAYER: -1, -139us, -139us 6150986s, 254.122ms
I (13126) PLAYER: -1, -170us, -170us 6150986s, 254.122ms
I (13174) PLAYER: -1, -171us, -171us 6150986s, 254.122ms
I (13222) PLAYER: -1, -169us, -169us 6150986s, 254.122ms
I (13270) PLAYER: -1, -156us, -156us 6150986s, 254.122ms
I (13318) PLAYER: -1, -145us, -145us 6150986s, 254.122ms
I (13366) PLAYER: -1, -135us, -135us 6150986s, 254.124ms
I (13414) PLAYER: -1, -92us, -92us 6150986s, 254.124ms
I (13462) PLAYER: -1, -143us, -143us 6150986s, 254.124ms
I (13510) PLAYER: -1, -134us, -134us 6150986s, 254.124ms
I (13558) PLAYER: -1, -53us, -53us 6150986s, 254.124ms
I (13606) PLAYER: -1, -130us, -130us 6150986s, 254.124ms
I (13654) PLAYER: -1, -71us, -71us 6150986s, 254.124ms
I (13702) PLAYER: -1, -99us, -99us 6150986s, 254.124ms
I (13750) PLAYER: -1, -115us, -115us 6150986s, 254.124ms
I (13798) PLAYER: -1, -62us, -62us 6150986s, 254.124ms
I (13846) PLAYER: -1, -99us, -99us 6150986s, 254.124ms
I (13894) PLAYER: -1, -89us, -89us 6150986s, 254.124ms
I (13942) PLAYER: -1, -89us, -89us 6150986s, 254.124ms
I (13990) PLAYER: -1, -88us, -88us 6150986s, 254.124ms
I (14038) PLAYER: -1, -64us, -64us 6150986s, 254.124ms
I (14086) PLAYER: -1, -79us, -79us 6150986s, 254.124ms
I (14134) PLAYER: 0, -1us, -1us 6150986s, 254.124ms
I (14182) PLAYER: -1, -62us, -62us 6150986s, 254.124ms
I (14230) PLAYER: -1, -49us, -49us 6150986s, 254.124ms
I (14278) PLAYER: -1, -56us, -56us 6150986s, 254.124ms
I (14326) PLAYER: -1, -55us, -55us 6150986s, 254.124ms
I (14374) PLAYER: -1, -25us, -25us 6150986s, 254.125ms
I (14422) PLAYER: -1, -32us, -32us 6150986s, 254.125ms
I (14470) PLAYER: -1, -41us, -41us 6150986s, 254.125ms
I (14518) PLAYER: 0, 8us, 8us 6150986s, 254.125ms
I (14566) PLAYER: -1, -23us, -23us 6150986s, 254.125ms
I (14614) PLAYER: -1, -22us, -22us 6150986s, 254.125ms
I (14662) PLAYER: -1, -21us, -21us 6150986s, 254.125ms
I (14710) PLAYER: -1, -3us, -3us 6150986s, 254.125ms
I (14758) PLAYER: 0, 13us, 13us 6150986s, 254.125ms
I (14806) PLAYER: -1, -9us, -9us 6150986s, 254.125ms
I (14854) PLAYER: 0, 53us, 53us 6150986s, 254.125ms
I (14902) PLAYER: 0, 13us, 13us 6150986s, 254.125ms
I (14950) PLAYER: 0, 21us, 21us 6150986s, 254.125ms
I (14998) PLAYER: 0, 10us, 10us 6150986s, 254.125ms
I (15046) PLAYER: 0, 11us, 11us 6150986s, 254.125ms
I (15094) PLAYER: 0, 16us, 16us 6150986s, 254.125ms
I (15142) PLAYER: 0, 12us, 12us 6150986s, 254.125ms
I (15190) PLAYER: 0, 6us, 6us 6150986s, 254.125ms
I (15238) PLAYER: 0, 43us, 43us 6150986s, 254.125ms
I (15286) PLAYER: 0, 18us, 18us 6150986s, 254.125ms
I (15334) PLAYER: 0, 1us, 1us 6150986s, 254.125ms
I (15382) PLAYER: 0, 3us, 3us 6150986s, 254.126ms
I (15430) PLAYER: 0, 7us, 7us 6150986s, 254.126ms
I (15478) PLAYER: 0, 21us, 21us 6150986s, 254.126ms
I (15526) PLAYER: 0, 4us, 4us 6150986s, 254.126ms
I (15574) PLAYER: 0, 53us, 53us 6150986s, 254.126ms
I (15622) PLAYER: 0, 15us, 15us 6150986s, 254.126ms
I (15670) PLAYER: 0, 17us, 17us 6150986s, 254.126ms
I (15718) PLAYER: 0, 12us, 12us 6150986s, 254.126ms
I (15766) PLAYER: 0, 9us, 9us 6150986s, 254.126ms
I (15814) PLAYER: 0, 20us, 20us 6150986s, 254.126ms
I (15862) PLAYER: 0, 21us, 21us 6150986s, 254.126ms
I (15910) PLAYER: 1, 10us, 10us 6150986s, 254.126ms
I (15958) PLAYER: 1, 47us, 47us 6150986s, 254.126ms
I (16006) PLAYER: 1, 9us, 9us 6150986s, 254.126ms
I (16054) PLAYER: 0, -8us, -8us 6150986s, 254.126ms
I (16102) PLAYER: 0, -7us, -7us 6150986s, 254.126ms
I (16150) PLAYER: 1, 3us, 3us 6150986s, 254.126ms
I (16198) PLAYER: 0, -1us, -1us 6150986s, 254.126ms
I (16246) PLAYER: 0, 0us, 0us 6150986s, 254.126ms
I (16294) PLAYER: 1, 51us, 51us 6150986s, 254.126ms
I (16342) PLAYER: 0, -12us, -12us 6150986s, 254.126ms
I (16390) PLAYER: 0, -8us, -8us 6150986s, 254.126ms
I (16438) PLAYER: 0, -7us, -7us 6150986s, 254.126ms
I (16486) PLAYER: 0, 6us, 6us 6150986s, 254.126ms
I (16534) PLAYER: 0, 0us, 0us 6150986s, 254.126ms
I (16582) PLAYER: 1, 7us, 7us 6150986s, 254.126ms
I (16630) PLAYER: 0, -6us, -6us 6150986s, 254.126ms
I (16678) PLAYER: 1, 32us, 32us 6150986s, 254.126ms
I (16726) PLAYER: 1, 8us, 8us 6150986s, 254.126ms
I (16774) PLAYER: 0, -12us, -12us 6150986s, 254.126ms
I (16822) PLAYER: 0, -10us, -10us 6150986s, 254.126ms
I (16870) PLAYER: 0, -8us, -8us 6150986s, 254.126ms
I (16918) PLAYER: 1, 15us, 15us 6150986s, 254.126ms
I (16966) PLAYER: 0, -10us, -10us 6150986s, 254.126ms
I (17014) PLAYER: 1, 58us, 58us 6150986s, 254.126ms
I (17062) PLAYER: 0, -3us, -3us 6150986s, 254.126ms
I (17110) PLAYER: 0, -1us, -1us 6150986s, 254.126ms
I (17158) PLAYER: 1, 2us, 2us 6150986s, 254.126ms
I (17206) PLAYER: 0, -8us, -8us 6150986s, 254.126ms
I (17254) PLAYER: 1, 6us, 6us 6150986s, 254.126ms
I (17302) PLAYER: 1, 37us, 37us 6150986s, 254.126ms
I (17350) PLAYER: 0, -8us, -8us 6150986s, 254.126ms
I (17398) PLAYER: 1, 34us, 34us 6150986s, 254.126ms
I (17446) PLAYER: 1, 21us, 21us 6150986s, 254.126ms
I (17494) PLAYER: 0, -18us, -18us 6150986s, 254.126ms
I (17542) PLAYER: 0, -16us, -16us 6150986s, 254.126ms
I (17590) PLAYER: 1, 29us, 29us 6150986s, 254.126ms
I (17638) PLAYER: 0, -1us, -1us 6150986s, 254.126ms
I (17686) PLAYER: 0, -3us, -3us 6150986s, 254.126ms
I (17734) PLAYER: 0, 25us, 25us 6150986s, 254.126ms
I (17782) PLAYER: 0, -7us, -7us 6150986s, 254.126ms
I (17830) PLAYER: 0, 1us, 1us 6150986s, 254.126ms
I (17878) PLAYER: 0, -16us, -16us 6150986s, 254.126ms
I (17926) PLAYER: 0, -11us, -11us 6150986s, 254.126ms
I (17974) PLAYER: 0, -5us, -5us 6150986s, 254.126ms
I (18022) PLAYER: 0, 2us, 2us 6150986s, 254.126ms
I (18070) PLAYER: 0, -11us, -11us 6150986s, 254.126ms
I (18118) PLAYER: 0, 32us, 32us 6150986s, 254.126ms
I (18166) PLAYER: 0, -10us, -10us 6150986s, 254.126ms
I (18214) PLAYER: 0, -12us, -12us 6150986s, 254.126ms
I (18262) PLAYER: 0, -9us, -9us 6150986s, 254.126ms
I (18310) PLAYER: 0, -6us, -6us 6150986s, 254.126ms
I (18358) PLAYER: 0, 9us, 9us 6150986s, 254.127ms
I (18406) PLAYER: 0, -15us, -15us 6150986s, 254.127ms
I (18454) PLAYER: 0, 45us, 45us 6150986s, 254.127ms
I (18502) PLAYER: 0, -7us, -7us 6150986s, 254.127ms
I (18550) PLAYER: 0, 10us, 10us 6150986s, 254.127ms
I (18598) PLAYER: 0, -5us, -5us 6150986s, 254.127ms
I (18646) PLAYER: 0, -13us, -13us 6150986s, 254.127ms
I (18694) PLAYER: 0, -3us, -3us 6150986s, 254.127ms
I (18742) PLAYER: 0, 5us, 5us 6150986s, 254.127ms
I (18790) PLAYER: 0, -7us, -7us 6150986s, 254.127ms
I (18838) PLAYER: 0, 26us, 26us 6150986s, 254.127ms
I (18886) PLAYER: 0, -10us, -10us 6150986s, 254.127ms
I (18934) PLAYER: 0, -8us, -8us 6150986s, 254.127ms
I (18982) PLAYER: 0, -8us, -8us 6150986s, 254.127ms
I (19030) PLAYER: 0, -2us, -2us 6150986s, 254.127ms
I (19078) PLAYER: 0, 0us, 0us 6150986s, 254.127ms
I (19126) PLAYER: 0, -15us, -15us 6150986s, 254.127ms
I (19174) PLAYER: 0, 48us, 48us 6150986s, 254.127ms
I (19222) PLAYER: 0, 8us, 8us 6150986s, 254.127ms
I (19270) PLAYER: 0, -3us, -3us 6150986s, 254.127ms
I (19318) PLAYER: 0, 26us, 26us 6150986s, 254.127ms
I (19366) PLAYER: 0, 5us, 5us 6150986s, 254.127ms
I (19414) PLAYER: 0, 0us, 0us 6150986s, 254.127ms
I (19462) PLAYER: 0, -13us, -13us 6150986s, 254.127ms
I (19510) PLAYER: 0, -4us, -4us 6150986s, 254.127ms
I (19558) PLAYER: 0, -10us, -10us 6150986s, 254.127ms
I (19606) PLAYER: 0, 4us, 4us 6150986s, 254.127ms
I (19654) PLAYER: 0, -6us, -6us 6150986s, 254.127ms
I (19702) PLAYER: 0, 1us, 1us 6150986s, 254.127ms
I (19750) PLAYER: 0, -3us, -3us 6150986s, 254.127ms
I (19798) PLAYER: 0, 6us, 6us 6150986s, 254.127ms

With the APLL disabled it sounds a lot better - i am unsure if all artifacts are gone and its just the DAC and cheap speaker that is still not sounding great. I will see if i can set up a simple playback from file to check that.

# APLL Disabled
E (4261) esp_ota_ops: Running firmware is factory
I (4262) OTA: idf.py build ; curl snapclient.local:8032 --data-binary @- < build/snapclient.bin
I (7342) SC: Found 192.168.1.16:1704
I (7346) SC: netconn connected
I (7349) SC: netconn sent hello message
I (7353) SC: Buffer length:  750
I (7353) SC: Latency:        10
I (7353) SC: Mute:           0
I (7357) SC: Setting volume: 14
I (7362) SC: fLaC sampleformat: 48000:16:2
I (7394) PLAYER: player_setup_i2s: dma_buf_len is 576, dma_buf_count is 2
I (7395) c_I2S: DMA Malloc info, datalen=blocksize=2304, dma_buf_count=2
I (7400) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (7412) GENERIC_BOARD: I2S0, MCLK output by GPIO0
I (7420) c_I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
W (7432) PLAYER: no pcm chunk queue created?
I (7437) PLAYER: created new queue with 31
I (7441) PLAYER: snapserver config changed, buffer 750ms, chunk 1152 frames, sample rate 48000, ch 2, bits 16 mute 0 latency 10
I (9354) SC: latency buffer full
I (10058) PLAYER: initial sync age: 2us, chunk duration: 24000us
I (10079) PLAYER: 0, -167us, -167us 6152144s, 717.20ms
I (10127) PLAYER: 0, -325us, -325us 6152144s, 717.20ms
I (10175) PLAYER: 0, -300us, -300us 6152144s, 717.20ms
I (10223) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (10271) PLAYER: 0, -343us, -343us 6152144s, 717.20ms
I (10319) PLAYER: 0, -322us, -322us 6152144s, 717.20ms
I (10367) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (10415) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (10463) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (10511) PLAYER: 0, -300us, -300us 6152144s, 717.20ms
I (10559) PLAYER: 0, -154us, -154us 6152144s, 717.20ms
I (10607) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (10655) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (10703) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (10751) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (10799) PLAYER: 0, -206us, -206us 6152144s, 717.20ms
I (10847) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (10895) PLAYER: 0, -305us, -305us 6152144s, 717.20ms
I (10943) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (10991) PLAYER: 0, -341us, -341us 6152144s, 717.20ms
I (11040) PLAYER: 0, -65us, -65us 6152144s, 717.20ms
I (11087) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (11135) PLAYER: 0, -319us, -319us 6152144s, 717.20ms
I (11183) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (11231) PLAYER: 0, -306us, -306us 6152144s, 717.20ms
I (11279) PLAYER: 0, -307us, -307us 6152144s, 717.20ms
I (11327) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (11375) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (11423) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (11471) PLAYER: 0, -319us, -319us 6152144s, 717.20ms
I (11519) PLAYER: 0, -292us, -292us 6152144s, 717.20ms
I (11567) PLAYER: 0, -327us, -327us 6152144s, 717.20ms
I (11615) PLAYER: 0, -289us, -289us 6152144s, 717.20ms
I (11663) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (11711) PLAYER: 0, -341us, -341us 6152144s, 717.20ms
I (11759) PLAYER: 0, -251us, -251us 6152144s, 717.20ms
I (11807) PLAYER: 0, -323us, -323us 6152144s, 717.20ms
I (11855) PLAYER: 0, -305us, -305us 6152144s, 717.20ms
I (11903) PLAYER: 0, -311us, -311us 6152144s, 717.20ms
I (11951) PLAYER: 0, -298us, -298us 6152144s, 717.20ms
I (11999) PLAYER: 0, -161us, -161us 6152144s, 717.20ms
I (12047) PLAYER: 0, -327us, -327us 6152144s, 717.20ms
I (12095) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (12143) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (12191) PLAYER: 0, -328us, -328us 6152144s, 717.20ms
I (12239) PLAYER: 0, -244us, -244us 6152144s, 717.20ms
I (12287) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (12335) PLAYER: 0, -311us, -311us 6152144s, 717.20ms
I (12383) PLAYER: 0, -322us, -322us 6152144s, 717.20ms
I (12431) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (12479) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (12527) PLAYER: 0, -319us, -319us 6152144s, 717.20ms
I (12575) PLAYER: 0, -312us, -312us 6152144s, 717.20ms
I (12623) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (12671) PLAYER: 0, -289us, -289us 6152144s, 717.20ms
I (12719) PLAYER: 0, -182us, -182us 6152144s, 717.20ms
I (12767) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (12815) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (12863) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (12911) PLAYER: 0, -326us, -326us 6152144s, 717.20ms
I (12959) PLAYER: 0, -304us, -304us 6152144s, 717.20ms
I (13007) PLAYER: 0, -335us, -335us 6152144s, 717.20ms
I (13055) PLAYER: 0, -307us, -307us 6152144s, 717.20ms
I (13103) PLAYER: 0, -324us, -324us 6152144s, 717.20ms
I (13151) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (13199) PLAYER: 0, -303us, -303us 6152144s, 717.20ms
I (13247) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (13295) PLAYER: 0, -306us, -306us 6152144s, 717.20ms
I (13343) PLAYER: 0, -310us, -310us 6152144s, 717.20ms
I (13391) PLAYER: 0, -286us, -286us 6152144s, 717.20ms
I (13439) PLAYER: 0, -261us, -261us 6152144s, 717.20ms
I (13487) PLAYER: 0, -326us, -326us 6152144s, 717.20ms
I (13535) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (13583) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (13631) PLAYER: 0, -325us, -325us 6152144s, 717.20ms
I (13679) PLAYER: 0, -201us, -201us 6152144s, 717.20ms
I (13727) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (13775) PLAYER: 0, -307us, -307us 6152144s, 717.20ms
I (13823) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (13871) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (13920) PLAYER: 0, -148us, -148us 6152144s, 717.20ms
I (13967) PLAYER: 0, -318us, -318us 6152144s, 717.20ms
I (14015) PLAYER: 0, -315us, -315us 6152144s, 717.20ms
I (14063) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (14111) PLAYER: 0, -272us, -272us 6152144s, 717.20ms
I (14159) PLAYER: 0, -186us, -186us 6152144s, 717.20ms
I (14207) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (14255) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (14303) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (14351) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (14399) PLAYER: 0, -262us, -262us 6152144s, 717.20ms
I (14447) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (14495) PLAYER: 0, -309us, -309us 6152144s, 717.20ms
I (14543) PLAYER: 0, -180us, -180us 6152144s, 717.20ms
I (14591) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (14639) PLAYER: 0, -227us, -227us 6152144s, 717.20ms
I (14687) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (14735) PLAYER: 0, -246us, -246us 6152144s, 717.20ms
I (14783) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (14831) PLAYER: 0, -266us, -266us 6152144s, 717.20ms
I (14879) PLAYER: 0, -316us, -316us 6152144s, 717.20ms
I (14927) PLAYER: 0, -335us, -335us 6152144s, 717.20ms
I (14975) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (15023) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (15071) PLAYER: 0, -327us, -327us 6152144s, 717.20ms
I (15119) PLAYER: 0, -177us, -177us 6152144s, 717.20ms
I (15167) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (15215) PLAYER: 0, -303us, -303us 6152144s, 717.20ms
I (15263) PLAYER: 0, -325us, -325us 6152144s, 717.20ms
I (15311) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (15359) PLAYER: 0, -279us, -279us 6152144s, 717.20ms
I (15407) PLAYER: 0, -328us, -328us 6152144s, 717.20ms
I (15455) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (15503) PLAYER: 0, -163us, -163us 6152144s, 717.20ms
I (15551) PLAYER: 0, -287us, -287us 6152144s, 717.20ms
I (15599) PLAYER: 0, -307us, -307us 6152144s, 717.20ms
I (15647) PLAYER: 0, -337us, -337us 6152144s, 717.20ms
I (15695) PLAYER: 0, -333us, -333us 6152144s, 717.20ms
I (15743) PLAYER: 0, -328us, -328us 6152144s, 717.20ms
I (15791) PLAYER: 0, -326us, -326us 6152144s, 717.20ms
I (15839) PLAYER: 0, -248us, -248us 6152144s, 717.20ms
I (15887) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (15935) PLAYER: 0, -277us, -277us 6152144s, 717.20ms
I (15983) PLAYER: 0, -327us, -327us 6152144s, 717.20ms
I (16031) PLAYER: 0, -314us, -314us 6152144s, 717.20ms
I (16079) PLAYER: 0, -226us, -226us 6152144s, 717.20ms
I (16127) PLAYER: 0, -322us, -322us 6152144s, 717.20ms
I (16175) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (16223) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (16271) PLAYER: 0, -262us, -262us 6152144s, 717.20ms
I (16319) PLAYER: 0, -228us, -228us 6152144s, 717.20ms
I (16367) PLAYER: 0, -314us, -314us 6152144s, 717.20ms
I (16415) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (16463) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (16511) PLAYER: 0, -318us, -318us 6152144s, 717.20ms
I (16559) PLAYER: 0, -249us, -249us 6152144s, 717.20ms
I (16607) PLAYER: 0, -332us, -332us 6152144s, 717.20ms
I (16655) PLAYER: 0, -292us, -292us 6152144s, 717.20ms
I (16703) PLAYER: 0, -325us, -325us 6152144s, 717.20ms
I (16751) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (16799) PLAYER: 0, -178us, -178us 6152144s, 717.20ms
I (16847) PLAYER: 0, -323us, -323us 6152144s, 717.20ms
I (16895) PLAYER: 0, -316us, -316us 6152144s, 717.20ms
I (16944) PLAYER: 0, -135us, -135us 6152144s, 717.20ms
I (16991) PLAYER: 0, -240us, -240us 6152144s, 717.20ms
I (17040) PLAYER: 0, -144us, -144us 6152144s, 717.20ms
I (17087) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (17135) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (17183) PLAYER: 0, -327us, -327us 6152144s, 717.20ms
I (17231) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (17279) PLAYER: 0, -255us, -255us 6152144s, 717.20ms
I (17327) PLAYER: 0, -328us, -328us 6152144s, 717.20ms
I (17375) PLAYER: 0, -296us, -296us 6152144s, 717.20ms
I (17423) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (17471) PLAYER: 0, -336us, -336us 6152144s, 717.20ms
I (17519) PLAYER: 0, -286us, -286us 6152144s, 717.20ms
I (17567) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (17615) PLAYER: 0, -312us, -312us 6152144s, 717.20ms
I (17663) PLAYER: 0, -328us, -328us 6152144s, 717.20ms
I (17711) PLAYER: 0, -259us, -259us 6152144s, 717.20ms
I (17760) PLAYER: 0, -138us, -138us 6152144s, 717.20ms
I (17807) PLAYER: 0, -309us, -309us 6152144s, 717.20ms
I (17855) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (17903) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (17951) PLAYER: 0, -326us, -326us 6152144s, 717.20ms
I (17999) PLAYER: 0, -244us, -244us 6152144s, 717.20ms
I (18047) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (18095) PLAYER: 0, -293us, -293us 6152144s, 717.20ms
I (18143) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (18191) PLAYER: 0, -315us, -315us 6152144s, 717.20ms
I (18239) PLAYER: 0, -309us, -309us 6152144s, 717.20ms
I (18287) PLAYER: 0, -313us, -313us 6152144s, 717.20ms
I (18335) PLAYER: 0, -310us, -310us 6152144s, 717.20ms
I (18383) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (18431) PLAYER: 0, -262us, -262us 6152144s, 717.20ms
I (18479) PLAYER: 0, -295us, -295us 6152144s, 717.20ms
I (18527) PLAYER: 0, -315us, -315us 6152144s, 717.20ms
I (18575) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (18623) PLAYER: 0, -311us, -311us 6152144s, 717.20ms
I (18671) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (18719) PLAYER: 0, -268us, -268us 6152144s, 717.20ms
I (18767) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (18815) PLAYER: 0, -296us, -296us 6152144s, 717.20ms
I (18863) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (18911) PLAYER: 0, -326us, -326us 6152144s, 717.20ms
I (18959) PLAYER: 0, -293us, -293us 6152144s, 717.20ms
I (19007) PLAYER: 0, -316us, -316us 6152144s, 717.20ms
I (19055) PLAYER: 0, -310us, -310us 6152144s, 717.20ms
I (19103) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (19151) PLAYER: 0, -260us, -260us 6152144s, 717.20ms
I (19199) PLAYER: 0, -179us, -179us 6152144s, 717.20ms
I (19247) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (19295) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (19344) PLAYER: 0, -144us, -144us 6152144s, 717.20ms
I (19391) PLAYER: 0, -323us, -323us 6152144s, 717.20ms
I (19439) PLAYER: 0, -268us, -268us 6152144s, 717.20ms
I (19487) PLAYER: 0, -329us, -329us 6152144s, 717.20ms
I (19535) PLAYER: 0, -289us, -289us 6152144s, 717.20ms
I (19583) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (19631) PLAYER: 0, -321us, -321us 6152144s, 717.20ms
I (19680) PLAYER: 0, -139us, -139us 6152144s, 717.20ms
I (19727) PLAYER: 0, -324us, -324us 6152144s, 717.20ms
I (19775) PLAYER: 0, -308us, -308us 6152144s, 717.20ms
I (19823) PLAYER: 0, -331us, -331us 6152144s, 717.20ms
I (19871) PLAYER: 0, -269us, -269us 6152144s, 717.20ms
I (19919) PLAYER: 0, -156us, -156us 6152144s, 717.20ms
I (19967) PLAYER: 0, -334us, -334us 6152144s, 717.20ms
I (20015) PLAYER: 0, -330us, -330us 6152144s, 717.20ms
I (20063) PLAYER: 0, -324us, -324us 6152144s, 717.20ms
I (20111) PLAYER: 0, -323us, -323us 6152144s, 717.20ms
I (20159) PLAYER: 0, -304us, -304us 6152144s, 717.20ms
I (20207) PLAYER: 0, -320us, -320us 6152144s, 717.20ms
I (20255) PLAYER: 0, -294us, -294us 6152144s, 717.20ms
I (20303) PLAYER: 0, -322us, -322us 6152144s, 717.20ms
I (20351) PLAYER: 0, -322us, -322us 6152144s, 717.20ms
I (20399) PLAYER: 0, -243us, -243us 6152144s, 717.19ms
I (20447) PLAYER: 0, -325us, -325us 6152144s, 717.19ms
I (20495) PLAYER: 0, -318us, -318us 6152144s, 717.19ms
I (20543) PLAYER: 0, -320us, -320us 6152144s, 717.19ms
I (20591) PLAYER: 0, -268us, -268us 6152144s, 717.19ms
I (20639) PLAYER: 0, -256us, -256us 6152144s, 717.19ms
I (20687) PLAYER: 0, -333us, -333us 6152144s, 717.19ms
I (20735) PLAYER: 0, -330us, -330us 6152144s, 717.19ms
I (20783) PLAYER: 0, -327us, -327us 6152144s, 717.19ms
I (20831) PLAYER: 0, -316us, -316us 6152144s, 717.19ms
I (20880) PLAYER: 0, -100us, -100us 6152144s, 717.19ms
I (20927) PLAYER: 0, -326us, -326us 6152144s, 717.19ms
I (20975) PLAYER: 0, -293us, -293us 6152144s, 717.19ms
I (21023) PLAYER: 0, -325us, -325us 6152144s, 717.19ms
I (21071) PLAYER: 0, -327us, -327us 6152144s, 717.19ms
I (21119) PLAYER: 0, -180us, -180us 6152144s, 717.19ms
I (21167) PLAYER: 0, -327us, -327us 6152144s, 717.19ms
I (21215) PLAYER: 0, -315us, -315us 6152144s, 717.19ms
I (21263) PLAYER: 0, -332us, -332us 6152144s, 717.19ms
I (21311) PLAYER: 0, -276us, -276us 6152144s, 717.19ms
I (21359) PLAYER: 0, -300us, -300us 6152144s, 717.19ms
I (21407) PLAYER: 0, -330us, -330us 6152144s, 717.19ms
I (21455) PLAYER: 0, -330us, -330us 6152144s, 717.19ms
I (21503) PLAYER: 0, -325us, -325us 6152144s, 717.19ms
I (21551) PLAYER: 0, -319us, -319us 6152144s, 717.19ms
I (21599) PLAYER: 0, -191us, -191us 6152144s, 717.19ms
I (21647) PLAYER: 0, -332us, -332us 6152144s, 717.19ms
I (21695) PLAYER: 0, -297us, -297us 6152144s, 717.19ms
I (21743) PLAYER: 0, -323us, -323us 6152144s, 717.19ms
I (21791) PLAYER: 0, -321us, -321us 6152144s, 717.19ms
I (21839) PLAYER: 0, -337us, -337us 6152144s, 717.19ms
I (21887) PLAYER: 0, -314us, -314us 6152144s, 717.19ms
I (21935) PLAYER: 0, -320us, -320us 6152144s, 717.19ms
I (21983) PLAYER: 0, -330us, -330us 6152144s, 717.19ms
I (22031) PLAYER: 0, -287us, -287us 6152144s, 717.19ms
I (22079) PLAYER: 0, -329us, -329us 6152144s, 717.19ms
I (22127) PLAYER: 0, -330us, -330us 6152144s, 717.19ms
I (22175) PLAYER: 0, -324us, -324us 6152144s, 717.19ms
I (22223) PLAYER: 0, -308us, -308us 6152144s, 717.19ms
I (22271) PLAYER: 0, -329us, -329us 6152144s, 717.19ms
I (22319) PLAYER: 0, -313us, -313us 6152144s, 717.19ms
I (22367) PLAYER: 0, -318us, -318us 6152144s, 717.19ms
I (22415) PLAYER: 0, -317us, -317us 6152144s, 717.19ms
I (22463) PLAYER: 0, -329us, -329us 6152144s, 717.19ms
I (22511) PLAYER: 0, -327us, -327us 6152144s, 717.19ms
I (22559) PLAYER: 0, -327us, -327us 6152144s, 717.19ms
I (22607) PLAYER: 0, -312us, -312us 6152144s, 717.19ms
I (22655) PLAYER: 0, -321us, -321us 6152144s, 717.19ms
I (22703) PLAYER: 0, -333us, -333us 6152144s, 717.19ms
I (22751) PLAYER: 0, -329us, -329us 6152144s, 717.19ms
I (22799) PLAYER: 0, -333us, -333us 6152144s, 717.19ms

Edit: I think there is still some distortion but i will try to get a comparison running.

luar123 commented 5 months ago

Another thing you could try is to disable apll tuning temporarily. The DAC doesn't have a MCLK line does it? I am not sure how this affects operation. I don't think it should be a problem as the others signal timings also change with MCLK timing but who knows.

I am using pcm5102a dac without MCLK (it is optional for this dac) and don't have any distortion/crackling issues.

CarlosDerSeher commented 5 months ago

Try playing a sine wave and maybe record it somehow. Using a oscilloscope maybe. There isn't a line out on this dac I guess so you could record it using a pc soundcard? Maybe it helps to see how the distortion looks like...

CarlosDerSeher commented 5 months ago

Ahhh and I see another possible problem on your setup. The wifi antenna is very close to your audio board. This could also be to source of your troubles. Try to get as much space between the antenna and audio!

BenediktMueller91 commented 5 months ago

Ahhh and I see another possible problem on your setup. The wifi antenna is very close to your audio board. This could also be to source of your troubles. Try to get as much space between the antenna and audio!

I put the DAC on a second breadboard. Unfortunately this did not improve anything.

I don't have this particular DAC so maybe someone else can report if he has similar issues, you could check if the DAC is correctly initialized by the driver. Maybe something is wrong there?

The DAC does not need any runtime configuration. It should just play any I2S data sent to it.

Try playing a sine wave and maybe record it somehow. Using a oscilloscope maybe. There isn't a line out on this dac I guess so you could record it using a pc soundcard? Maybe it helps to see how the distortion looks like...

Unfortunately this DAC does not have a line level output. I added a voltage divider to ground on both speaker leads (with the speaker still connected) and fed that into the line in of a usb soundcard. One file is from a direct loop on the soundcard playing the same file and the other one from the esp32 playing the file. It is a 440Hz sine wave. Audio-Recordings.zip

CarlosDerSeher commented 5 months ago

Honestly I am not sure where this is coming from. To me it kind of looks like noise from the power supply. Could yo try to use a different supply for the DAC. At the moment you are using to power supply from the ESP module don't you? How do you supply everything at the moment, 5V from USB or through 3.3V regulator on the board?

Bildschirmfoto vom 2024-01-06 17-49-03

BenediktMueller91 commented 5 months ago

Here is the same file played on a raspberrypi connected to the DAC: esp32-snapcast-workbench_via_raspberry.zip

Maybe my way of recording is not perfect. Still the sound does seem a little better coming from the raspberry pi - but also farm from really good. I will try to wire up a separate power supply for the DAC to avoid getting interference from the usb lines or ESP32 cpu noise.

CarlosDerSeher commented 5 months ago

There is a lot of noise when using the DAC. Maybe some of it originates from your measurement setup but RPi and ESP32 look very similar to me, so I am assuming some kind of hardware problem here.

RPi playback (with DC offset removed through Audacity normalize tool): RPi playback:

ESP32 playback: ESP32 playback

loop playback: loop playback

BenediktMueller91 commented 5 months ago

So then i will put this aside as problem of the DAC for now. I was hoping to use this simple DAC for testing and switch to something more useful once i am happy with the basic playback and behaviour of the software. Something like the HiFiBerry AMP2 (TAS5713) or IQaudio DigiAMP+ (TAS5756M).

I am already using the IQaudio DigiAmp+ on one of my raspberry pi snapcast clients and it sounds great.

So the only 'real' problem with the crackling was probably the APLL correction. Could this also be something the DAC does not like? If so, I could try switching to the IQaudio amplifier and adding it as a custom board (I may have one lying around somewhere).

DerPicknicker commented 5 months ago

@BenediktMueller91 I use an TAS5805M board. And it sounds great with an esp32 I can't hear any difference in comparison to an raspberry pi. I am working on the support for this board: https://www.tindie.com/products/sonocotta/louder-esp32/ (Almost finished 95% it needs some adjustments but the board and the amp works fine) So from my perspective an raspberry is really not needed for an snapclient.

USB is really noisy and I can confirm with other dacs that the sound quality is not the best if the power supply is noisy.

CarlosDerSeher commented 5 months ago

Could this also be something the DAC does not like?

I read something about jitter correction in the datasheet but I doubt this is the problem. I don't think that apll correction is the problem. Did you try to change the power supply of the DAC?

Also @normanalie could be of help here maybe, he did add the codec and maybe has some input here.

BenediktMueller91 commented 5 months ago

USB is really noisy and I can confirm with other dacs that the sound quality is not the best if the power supply is noisy.

I read something about jitter correction in the datasheet but I doubt this is the problem. I don't think that apll correction is the problem. Did you try to change the power supply of the DAC?

I added a separate lab power supply for the DAC and now the quality is overall quite good. ESP32 and DAC share only ground and the i2s lines now. It looks like even when feeding the ESP32 with a really good power supply via the USB plug the power rail became quite noisy.

spectogram

Edit: All this with the apll correction still disabled!

With the apll correction enabled it still sounds and looks terrible:

spectogram_with_apll

normanalie commented 5 months ago

I've never encountered this problem with this DAC. First, I think that you don't have a resistor on the SD_MODE pin. With the ESP32, to have the sum L+R you need a resistor of 632ohms. With the E12 series, you can put a 560ohm resistor between SD_MODE and 3.3V. Do you have a way of measuring the BCLK signal? In the event of jitter or noise, the DAC behaves randomly.

BenediktMueller91 commented 5 months ago

I've never encountered this problem with this DAC. First, I think that you don't have a resistor on the SD_MODE pin. With the ESP32, to have the sum L+R you need a resistor of 632ohms. With the E12 series, you can put a 560ohm resistor between SD_MODE and 3.3V.

The Adafruit Max98357A Board already includes the resistor for the L+R operation mode when supplying 5V (see https://learn.adafruit.com/assets/32642).

Do you have a way of measuring the BCLK signal? In the event of jitter or noise, the DAC behaves randomly.

Unfortunately i don't have any kind of logic analyzer at the moment. I have ordered a cheap amazon usb logic analyzer (https://www.amazon.de/dp/B01MUFRHQ2) and will have a look at the i2s lines once it arrives and i can find some time.

normanalie commented 5 months ago

On the schematic, R1 is 1mOhm, thats too much for 3.3V logic. Based on the data sheet, SD_MODE pull-up resistor should be 632ohms on 3.3V I/O. I don't think this will solve your problem but it will eliminate a potential problem and your electronic design will follow the recommendations.

https://www.analog.com/media/en/technical-documentation/data-sheets/max98357a-max98357b.pdf

CarlosDerSeher commented 5 months ago

Are you sure it is 1m? To me it looks more like 1M And the datasheet states R_large = 634kOhm @ 3.3V for L+R so it should be ok with 1M @ 5V

Did you ever try a different speaker? Maybe your speaker's impedance isn't supported by the DAC?

BenediktMueller91 commented 5 months ago

Did you ever try a different speaker? Maybe your speaker's impedance isn't supported by the DAC?

I switched to a Visaton SC 5.9 (10W, 8 Ohms). The same issues persist. But it still sounds a lot better with the bigger speaker. The spectrograms i posted where already recored from this speaker.

On the schematic, R1 is 1mOhm, thats too much for 3.3V logic. Based on the data sheet, SD_MODE pull-up resistor should be 632ohms on 3.3V I/O. I don't think this will solve your problem but it will eliminate a potential problem and your electronic design will follow the recommendations.

In Table 5 V[SD_MODE] is given as B1 trip point > V[SD_MODE] > B0 trip point with B0 and B1 defined on page 7 (ELECTRICAL CHARACTERISTICS) as typ. 0.16v and typ. 0.77v respectively. I measured 0.47v with no additional components connected to the SD_MODE pin of the breakout board. So this should put the DAC securely into the "(Left/2 + right/2)" mode.

The pictured board is currently the only ESP32 available to me so I also ordered another ESP32-WROVER based board to make sure it is not something about this specific board. I will report back once the logic analyzer is running and i tested the new board.

BenediktMueller91 commented 5 months ago

tl;dr: When apll correction is active, i still have crackling but in a way that sounds more like short interruptions/pops. On the i2s lines the data looks fine in both cases.

Ok, so the logic analyzer did not make it any better šŸ˜•. And with the ESP32-WROVER CAM Board the issues are the same. Now only the DAC and the software are left as culprits imho.

In Sigrok/PulseView i recorded 50 MSamples at 6Mhz and added an i2s decoder. With a simple python script i transformed the exported i2s text data files into binary data files and imported them into audacity. In both cases when selecting 2-channel 16 bit signed pcm on the raw importer in audacity, a good looking/sounding sine wave was the result.

As far as i can tell the BCLK as well as LRCLK and DATA look fine and have no relevant timing inconsistencies. Maybe one of you can spot something in the recorded data?

Sigrok-Recording-01.zip

And thats the script i used to convert the data exported from PulseView:

#!/usr/bin/env python3

import sys

filename_in = sys.argv[1]
filename_out = filename_in + ".raw"

infile = open(filename_in, "r")
outfile = open(filename_out, "wb")

print(f"Reading: {filename_in}")
print(f"Writing: {filename_out}")
for line in infile:
    outfile.write(bytes.fromhex(line[-5:-1]))
print("Done!")
CarlosDerSeher commented 5 months ago

@BenediktMueller91 BCK width jitters a little for both apll/no_apll but I guess thats because of sample rate of logic analyzer not beeing high enough.

Also I get an error using yourt conversion script:

python3 convert.py esp32-i2s-playback_sine_stereo_apll.sr
Reading: esp32-i2s-playback_sine_stereo_apll.sr
Writing: esp32-i2s-playback_sine_stereo_apll.sr.raw
Traceback (most recent call last):
  File "convert.py", line 13, in <module>
    for line in infile:
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 15: invalid start byte
BenediktMueller91 commented 5 months ago

@BenediktMueller91 BCK width jitters a little for both apll/no_apll but I guess thats because of sample rate of logic analyzer not beeing high enough.

Also I get an error using yourt conversion script:

python3 convert.py esp32-i2s-playback_sine_stereo_apll.sr
Reading: esp32-i2s-playback_sine_stereo_apll.sr
Writing: esp32-i2s-playback_sine_stereo_apll.sr.raw
Traceback (most recent call last):
  File "convert.py", line 13, in <module>
    for line in infile:
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 15: invalid start byte

The script does not work on the *.sr files but the decoded/exported i2s data. You get the file when right-clicking on the i2s track and export that row. The file should look like this:

[...]
1177-1240 IĀ²S: : Left channel: 0000102d
1240-1302 IĀ²S: : Right channel: 0000102d
[...]

screenshot_export

CarlosDerSeher commented 5 months ago

I figured that out later, but still the same error

python3 convert.py esp32-i2s-playback_sine_stereo_apll.txt
Reading: esp32-i2s-playback_sine_stereo_apll.txt
Writing: esp32-i2s-playback_sine_stereo_apll.txt.raw
Traceback (most recent call last):
  File "convert.py", line 14, in <module>
    for line in infile:
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 8: invalid start byte

esp32-i2s-playback_sine_stereo_apll.txt:

52-114 IĀ²S: : Left channel: 000018d8
114-177 IĀ²S: : Right channel: 000018d8
177-239 IĀ²S: : Left channel: 0000182d
239-302 IĀ²S: : Right channel: 0000182d
302-364 IĀ²S: : Left channel: 0000176d
364-427 IĀ²S: : Right channel: 0000176d
427-489 IĀ²S: : Left channel: 00001699
489-552 IĀ²S: : Right channel: 00001699
552-614 IĀ²S: : Left channel: 000015b3
614-677 IĀ²S: : Right channel: 000015b3
677-739 IĀ²S: : Left channel: 000014b9
739-802 IĀ²S: : Right channel: 000014b9
802-864 IĀ²S: : Left channel: 000013ae
864-927 IĀ²S: : Right channel: 000013ae
927-990 IĀ²S: : Left channel: 00001293
990-1052 IĀ²S: : Right channel: 00001293
1052-1115 IĀ²S: : Left channel: 00001167
1115-1177 IĀ²S: : Right channel: 00001167
BenediktMueller91 commented 5 months ago

Oh, maybe the encoding is something different on your system by default. Probably the file will be ISO-8859-1 instead of UTF-8. Try wether it works when explicitly specifying the encoding like this:

 filename_out = filename_in + ".raw"

-infile = open(filename_in, "r")
+infile = open(filename_in, "r", encoding="ISO-8859-1")
 outfile = open(filename_out, "wb")
CarlosDerSeher commented 5 months ago

Ok now I am getting somewhere. audio sample rate is 48kHz and it is big endian format isn't it?

CarlosDerSeher commented 5 months ago

In Sigrok/PulseView i recorded 50 MSamples at 6Mhz and added an i2s decoder. With a simple python script i transformed the exported i2s text data files into binary data files and imported them into audacity. In both cases when selecting 2-channel 16 bit signed pcm on the raw importer in audacity, a good looking/sounding sine wave was the result.

So you recorded the I2S signals coming from ESP32 and we get a clean audio if we listen to it on a PC. At least it sounds / looks clean to me on my PC. This leaves your DAC as the problem I guess? Question is what is different for your hardware as it seems to work for others with this DAC type...

CarlosDerSeher commented 5 months ago

Can you see the APLL direction switch with the logic analyzer? maybe there is a glitch on the line when this is happening? Not sure how we could visualize that as we cant really trigger on the direction switch. maybe toggle a gpio when it is happening and use a scope to trigger on that signal?

CarlosDerSeher commented 5 months ago

And you talked about the raspberry behaving similar with this DAC connected? If that is the case then your DAC is the problem

CarlosDerSeher commented 5 months ago

And here is yet another possible problem I found:

Screenshot 2024-01-11 13 58 51

In line https://github.com/CarlosDerSeher/snapclient/blob/d3e20fe0eb4d8d562d97a02f43cbccb79e9c8505/main/main.c#L2777C13-L2777C13 I activate the I2S interface before I initialize the DAC. I did that for ADAU1961 DAC but it seems yours needs a different startup sequence. Maybe just comment the I2S initialization in main for a quick test?

DerPicknicker commented 5 months ago

@BenediktMueller91 ... Try also soldering the dac to the esp32 loose connection can cause also issues. I don't know the bandwidth but higher clock frequencies like 5mhz need short cables. Before looking that deep into software be sure that your hardware is connected properly.

BenediktMueller91 commented 5 months ago

It has to somehow be connected to software. I tried to change as little as possibel between the tests (same snapcast server, same stream, same/similar volume):

Note: I added a short log with the dir var. The artifacts in the output correspond to dir changing (rapidly). Unfortunately i could not get gpio_set_level to work. Also i discovered that i can't connect the logic analyzer and the DAC to BCK at the same time. The DAC goes silent as soon as i connect any channel of the analyzer to the BCK clock pin. LRCK and DATA i can record while the DAC is still working.

I (60903) PLAYER: APLL Dir: 0
I (60923) PLAYER: APLL Dir: 1
I (60943) PLAYER: APLL Dir: 1
I (60963) PLAYER: APLL Dir: 1
I (60983) PLAYER: APLL Dir: 0
I (61003) PLAYER: APLL Dir: 1
I (61023) PLAYER: APLL Dir: 1
I (61043) PLAYER: APLL Dir: 1
I (61063) PLAYER: APLL Dir: 1
I (61083) PLAYER: APLL Dir: 1
I (61103) PLAYER: APLL Dir: 1
I (61123) PLAYER: APLL Dir: 0
I (61143) PLAYER: APLL Dir: 1
I (61163) PLAYER: APLL Dir: 1
I (61183) PLAYER: APLL Dir: 1
I (61203) PLAYER: APLL Dir: 0
I (61223) PLAYER: APLL Dir: 0
I (61243) PLAYER: APLL Dir: 1
I (61263) PLAYER: APLL Dir: 1
I (61283) PLAYER: APLL Dir: 0
I (61303) PLAYER: APLL Dir: 0
I (61323) PLAYER: APLL Dir: 0
I (61343) PLAYER: APLL Dir: 0
I (61363) PLAYER: APLL Dir: 1
I (61383) PLAYER: APLL Dir: 0
I (61403) PLAYER: APLL Dir: 1
I (61423) PLAYER: APLL Dir: 1
I (61443) PLAYER: APLL Dir: 1
I (61463) PLAYER: APLL Dir: 1
I (61483) PLAYER: APLL Dir: 0
I (61503) PLAYER: APLL Dir: 1
I (61523) PLAYER: APLL Dir: 0
I (61543) PLAYER: APLL Dir: 1
I (61563) PLAYER: APLL Dir: 1
I (61583) PLAYER: APLL Dir: 1
I (61603) PLAYER: APLL Dir: 1
I (61623) PLAYER: APLL Dir: 0
I (61643) PLAYER: APLL Dir: 0
I (61663) PLAYER: APLL Dir: 0
I (61683) PLAYER: APLL Dir: 1
I (61703) PLAYER: APLL Dir: 0

šŸ™ Did not work:

  gpio_reset_pin(GPIO_NUM_4);
  gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
  gpio_set_pull_mode(GPIO_NUM_4, GPIO_PULLDOWN_ONLY);
  gpio_set_level(GPIO_NUM_4, 0);
             dir = -1;
+            gpio_set_level(GPIO_NUM_4, 0);
           } else if ((shortMedian > shortOffset) && (miniMedian > miniOffset) &&
                      (avg > miniOffset)) {  // we are late
             dir = 1;
+            gpio_set_level(GPIO_NUM_4, 1);
           }

Will continue investigating - Thanks for your help so far! šŸ˜„

CarlosDerSeher commented 5 months ago

There is a gpio_configure function you'll need to call first for the hpio to work.

And it still could be hardware related. Maybe this particular dac doesn't like the apll/clock jitter we are introducing on purpose. It's still strange that others won't report this behavior

CarlosDerSeher commented 4 months ago

@BenediktMueller91 I've pushed a new branch https://github.com/CarlosDerSeher/snapclient/commit/1e3bda9ad01025e566f8aadd6a705e0a76ba73b2

Where I've implemented a different syncing approach. It's still experimental, maybe you are willing to test.

BenediktMueller91 commented 4 months ago

@CarlosDerSeher I flashed my ESP32 with a build based on branch sync_with_sample_stuffing. Also i found a old bookshelf speaker in the basement. That removed the artifacts from the sqeaky speaker. It now sounds really good. When playing a pure 440Hz sinus i can faintly hear the sample manipulations but nothing that i could hear in anything but such pure waveforms. Initially samples were added/removed rapidly so I changed shortOffset and miniOffset a little to relax the timing. It now slowly drifts around and sometimes a sample is added or removed.

-      const int64_t shortOffset = 2;              // Āµs, softsync
-      const int64_t miniOffset = 1;               // Āµs, softsync
+      const int64_t shortOffset = 128;              // Āµs, softsync
+      const int64_t miniOffset = 64;               // Āµs, softsync

Thanks again for all your work and help :)

CarlosDerSeher commented 4 months ago

Awesome :)