Properly shutting down the I2S stream #2348
-
Problem DescriptionHi Phil, I am using your libraries in possibly unusual way and faced an issue. I need to feed the audio to an external DAC. The idea is that when the BT source is selected, I shut down the DAB shield and only the ESP32 "talks" to the DAC. It looks like it can work:
The issue is when I switch source. Do you think that the ESP32 I2S could be "not shut down properly"? If you have a recommendation on how to do this better, please do not hesitate. Device Description
SketchI am not sure you can fully make sense of it, but here is the shut down code:
https://github.com/jmcazaux/esp32_dab_radio/blob/use_dabshield_as_source_of_i2s_clock/firmware/src/main.cpp#L109-L131Other Steps to ReproduceNo response What is your development environment (incl. core version info)CLion + PlatformIO 6.1.19 I have checked existing issues, discussions and online documentation (incl. the Wiki)
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
|
Calling end() on the I2SStream is shutting down the ESP32 I2S properly! I guess you also might need to reset the DAC or make the DAC the I2S master... |
Beta Was this translation helpful? Give feedback.
-
|
Mmmhh... Other option I tried was to the DAB shield be the master and let it on at all times (just providing the clock in BT mode), but I think I was not able to set the ESP32 as a slave... It did not work. |
Beta Was this translation helpful? Give feedback.
-
|
Hey Phil, I am a bit lost with what you call the I2S module... When switching the BT mode off on the ESP32, I call Unfortunately I cannot verify the actual signal (no scope here). |
Beta Was this translation helpful? Give feedback.
-
|
What sample rate and bits are used by your DAB shield ? I think most DAB shields are using 48000 samples per second 16 bits, 2 channels. A2DP is using 44100, 16 bits, 2 channels. Some DAB chipsets require the ESP32 to be the I2S slave instead of master. |
Beta Was this translation helpful? Give feedback.
-
|
Your enableRadio() and disableRadio() is missing the setup and shutdown of I2S! Alternatively you can just make sure to call I2SStream begin in setup() and change the sample rate via setAudioInfo(), assuming you don't need to change any other I2S settings. |
Beta Was this translation helpful? Give feedback.
Calling end() on the I2SStream is shutting down the ESP32 I2S properly!
I guess you also might need to reset the DAC or make the DAC the I2S master...