philippe44 / squeezelite-esp32

squeezelite ported to esp32
63 stars 123 forks source link

Using internal DAC #25

Closed marrog86 closed 5 years ago

marrog86 commented 5 years ago

During waiting for an I2S dac, i wanted to try it with internal one.

Espressif said on https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/i2s.html you have to send NULL on i2s_set_pin(i2s_num, NULL) for enabling the internal dac I changed the code: in output_i2c addad on line 300 | I2S_MODE_DAC_BUILT_INto configuration changed line 313 to: i2s_set_pin(CONFIG_I2S_NUM, NULL);//&pin_config); //chanched here for DAC output

But it isn't working.

The documentation says this whil configure dac to pin 25 & 26, but nothing happens. Thanks for help.

marrog86 commented 5 years ago

I also had to disable the I2S_COMM_FORMAT_I2S| parameter. Now i was able to verify that the cables are ok, but the audio is only cracking sound.

What could be the reason? here the log outputs:

`squeezelite -o I2S -b 500:2000 -d all=debug -m ESP32

D (13355) squeezelite_cmd: Parameters: D (13355) squeezelite_cmd: squeezelite D (13355) squeezelite_cmd: -o D (13355) squeezelite_cmd: I2S D (13365) squeezelite_cmd: -b D (13365) squeezelite_cmd: 500:2000 D (13365) squeezelite_cmd: -d D (13375) squeezelite_cmd: all=debug D (13375) squeezelite_cmd: -m D (13375) squeezelite_cmd: ESP32 D (13385) squeezelite_cmd: assigning parm 0 : squeezelite D (13385) squeezelite_cmd: assigning parm 1 : -o D (13385) squeezelite_cmd: assigning parm 2 : I2S D (13395) squeezelite_cmd: assigning parm 3 : -b D (13395) squeezelite_cmd: assigning parm 4 : 500:2000 D (13405) squeezelite_cmd: assigning parm 5 : -d D (13405) squeezelite_cmd: assigning parm 6 : all=debug D (13425) squeezelite_cmd: assigning parm 7 : -m D (13425) squeezelite_cmd: assigning parm 8 : ESP32 D (13425) squeezelite_cmd: Starting Squeezelite Thread D (13435) squeezelite_cmd: Back to console thread! I (13435) squeezelite_cmd: Waiting for WiFi. D (13445) squeezelite_cmd: Number of args received: 9 D (13445) squeezelite_cmd: Values: D (13445) squeezelite_cmd: squeezelite D (13455) squeezelite_cmd: -o D (13455) squeezelite_cmd: I2S D (13455) squeezelite_cmd: -b D (13465) squeezelite_cmd: 500:2000 D (13465) squeezelite_cmd: -d D (13465) squeezelite_cmd: all=debug D (13475) squeezelite_cmd: -m D (13485) squeezelite_cmd: ESP32 D (13485) squeezelite_cmd: Starting Squeezelite runner Thread I (13495) squeezelite_cmd: Calling squeezelite I (13495) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE [00:00:12.178298] stream_init:370 init stream [00:00:12.179085] stream_init:371 streambuf size: 512000 [00:00:12.190123] output_init_embedded:52 init device: I2S [00:00:12.190885] output_init_common:351 outputbuf size: 2048000 [00:00:12.202193] output_init_common:375 idle timeout: 0 [00:00:12.203262] output_init_common:427 supported rates: 192000 176400 96000 88200 48000 44100 32000 24000 22050 16000 12000 11025 8000 squeezelite-esp32> [00:00:12.215736] output_init_embedded:64 init I2S/SPDIF [00:00:12.226725] output_init_i2s:310 Initializing I2S mode normal with rate: 44100, bits per sample: 16, buffer frames: 512, number of buffers: 12 I (13565) I2S: DMA Malloc info, datalen=blocksize=2048, dma_buf_count=12 I (13565) I2S: APLL: Req RATE: 44100, real rate: 22049.982, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 5644795.500, SCLK: 705599.437500, diva: 1, divb: 0 [00:00:12.254226] output_thread_i2s:441 Output state is 0 [00:00:12.265915] output_thread_i2s:496 Restarting I2S. [00:00:12.265915] output_init_embedded:70 init completed. [00:00:12.277788] decode_init:157 init decode [00:00:12.278915] register_alac:547 using alac to decode alc [00:00:12.279942] register_helixaac:657 using helix-aac to decode aac [00:00:12.290952] register_vorbis:378 using vorbis to decode ogg [00:00:12.292003] register_opus:320 using opus to decode ops [00:00:12.303022] register_flac:306 using flac to decode flc [00:00:12.304175] register_pcm:483 using pcm to decode aif,pcm [00:00:12.315274] register_mad:417 using mad to decode mp3 [00:00:12.316282] decode_init:210 include codecs: exclude codecs: [00:00:12.320910] discover_server:791 sending discovery [00:00:12.320910] output_thread_i2s_stats:576 Heap internal:127816 (min:126368) external:1484760 (min:1484760) [00:00:12.517209] discover_server:802 got response from: 192.168.8.16:3483 [00:00:12.518957] slimproto:890 connecting to 192.168.8.16:3483 [00:00:12.731834] slimproto:929 connected [00:00:12.732947] sendHELO:144 mac: 0e:e6:2d:de:90:19 [00:00:12.733765] sendHELO:146 cap: Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=v1.9.2-1145,ModelName=SqueezeLite,MaxSampleRate=192000,alc,aac,ogg,ops,flc,aif,pcm,mp3 [00:00:13.029728] process:525 strm [00:00:13.030664] process_strm:276 strm command q [00:00:13.031395] decode_flush:252 decode flush [00:00:13.032138] output_flush:440 flush output buffer [00:00:13.043078] sendSTAT:191 STAT: STMf [00:00:13.746465] process:525 audg [00:00:13.747837] process_audg:437 audg gainL: 65536 gainR: 65536 adjust: 1 [00:00:13.749873] set_volume:80 setting internal gain left: 65536 right: 65536 [00:00:13.762699] process:525 strm [00:00:13.763606] process_strm:276 strm command s [00:00:13.764309] process_strm:346 strm s autostart: 1 transition period: 10 transition type: 0 codec: m [00:00:13.776780] sendSTAT:191 STAT: STMf [00:00:13.778315] codec_open:280 codec open: 'm' [00:00:13.780632] stream_sock:486 connecting to 192.168.8.16:9000 [00:00:13.791024] stream_sock:563 header: GET /stream.mp3?player=0e:e6:2d:de:90:19 HTTP/1.0

[00:00:13.792737] sendSTAT:191 STAT: STMc [00:00:13.804227] process_strm:381 set fade mode: 0 [00:00:13.807190] process:525 audg [00:00:13.807998] process_audg:437 audg gainL: 65536 gainR: 65536 adjust: 1 [00:00:13.819250] set_volume:80 setting internal gain left: 65536 right: 65536 [00:00:13.822010] process:525 setd [00:00:13.824511] process:525 setd [00:00:13.826548] process:525 aude [00:00:13.827256] process_aude:419 enable spdif: 1 dac: 1 [00:00:13.839634] process:525 audg [00:00:13.840847] process_audg:437 audg gainL: 65536 gainR: 65536 adjust: 1 [00:00:13.841989] set_volume:80 setting internal gain left: 65536 right: 65536 [00:00:13.878184] process:525 strm [00:00:13.879042] process_strm:276 strm command t [00:00:13.879846] sendSTAT:191 STAT: STMt [00:00:14.003384] stream_thread:247 headers: len: 116 HTTP/1.1 200 OK Server: Logitech Media Server (7.9.2 - 1565967976) Connection: close Content-Type: audio/mpeg

[00:00:14.019311] sendRESP:222 RESP [00:00:14.241403] process:525 strm [00:00:14.242303] process_strm:276 strm command t [00:00:14.243018] sendSTAT:191 STAT: STMt [00:00:14.304478] output_thread_i2s:441 Output state is 1 [00:00:14.315324] mad_decode:235 mad_frame_decode error: bad main_data_begin pointer [00:00:14.330076] mad_decode:247 setting track_start [00:00:14.331280] mad_decode:276 gapless: skipping 529 frames at start [00:00:14.414877] _output_frames:64 start buffer frames: 5231 [00:00:14.417136] _output_frames:149 track start sample rate: 48000 replay_gain: 0 [00:00:14.418333] output_thread_i2s:504 changing sampling rate 44100 to 48000 I (15755) I2S: APLL: Req RATE: 48000, real rate: 23999.980, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 6143995.000, SCLK: 767999.375000, diva: 1, divb: 0 [00:00:14.443832] output_thread_i2s:441 Output state is 2 [00:00:14.459274] sendSTAT:191 STAT: STMs [00:00:14.465137] sendSTAT:191 STAT: STMt [00:00:14.468498] sendSTAT:191 STAT: STMo [00:00:14.570433] process:525 strm [00:00:14.571302] process_strm:276 strm command t [00:00:14.573459] sendSTAT:191 STAT: STMt [00:00:14.639897] process:525 strm [00:00:14.640863] process_strm:276 strm command p [00:00:14.643161] sendSTAT:191 STAT: STMp [00:00:14.645113] output_thread_i2s:441 Output state is 0 [00:00:14.649086] process_strm:312 pause interval: 0 [00:00:14.905103] process:525 strm [00:00:14.906052] process_strm:276 strm command t [00:00:14.908256] sendSTAT:191 STAT: STMt [00:00:15.147227] process:525 strm [00:00:15.149634] process_strm:276 strm command t [00:00:15.152855] sendSTAT:191 STAT: STMt [00:00:15.499702] process:525 audg [00:00:15.500603] process_audg:437 audg gainL: 0 gainR: 0 adjust: 1 [00:00:15.502953] set_volume:80 setting internal gain left: 0 right: 0 [00:00:15.517827] process:525 strm [00:00:15.521785] process_strm:276 strm command u [00:00:15.525080] output_thread_i2s:441 Output state is 2 [00:00:15.524868] process_strm:333 unpause at: 0 now: 15529 [00:00:15.538020] sendSTAT:191 STAT: STMr [00:00:15.554424] process:525 audg [00:00:15.555326] process_audg:437 audg gainL: 65536 gainR: 65536 adjust: 1 [00:00:15.560065] set_volume:80 setting internal gain left: 65536 right: 65536 [00:00:16.043512] sendSTAT:191 STAT: STMt [00:00:16.053156] process:525 strm [00:00:16.054116] process_strm:276 strm command t [00:00:16.056269] sendSTAT:191 STAT: STMt [00:00:17.088050] sendSTAT:191 STAT: STMt [00:00:18.128803] sendSTAT:191 STAT: STMt [00:00:19.144834] sendSTAT:191 STAT: STMt E (20645) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (20645) task_wdt: - IDLE1 (CPU 1) E (20645) task_wdt: Tasks currently running: E (20645) task_wdt: CPU 0: IDLE0 E (20645) task_wdt: CPU 1: output_i2s [00:00:20.162585] sendSTAT:191 STAT: STMt [00:00:21.057032] process:525 strm [00:00:21.057926] process_strm:276 strm command t [00:00:21.059399] sendSTAT:191 STAT: STMt [00:00:22.096448] sendSTAT:191 STAT: STMt [00:00:23.125666] sendSTAT:191 STAT: STMt `

marrog86 commented 5 years ago

Pleas only tell mi if it should be possible no make this with the internal DAC, so i woll not loose time.
i am now able to use ist, but only with changing sample rate to 20000 and the quality is realy poor (no idea if it is the sample rate or other problem)

Thanks

philippe44 commented 5 years ago

I don’t know if this is possible or not, I’ve never tried so you know as much as I do

sle118 commented 5 years ago

I have ruled out the use on internal dac early on during the porting effort. First, the internal dac are 8 bits, which means low quality for music. Second, you would need to split the decoded stream into individual left and right channels for this to work. Typical i2s DAC will extract the channels for you.

your only option to reduce component count is to feed an SPDIF output into an amplifier.

Given how cheap the I2S headphone codec boards are (<$10), there really isn't an interest to support this configuration. You are welcomed to try and report back if you think there is some potential.

thank you!

philippe44 commented 5 years ago

Oh BTW you can use the esp32-a1s made by hilink which has the wrover pinout and integrates a DAC. Go on slimdevice forum, somebody has made it work