Assistance Needed for Streaming and Playing MP3 from SPIFFS over I2S on ESP32 #1037
-
Hello everyone, I’m Fernando from Argentina and I'm currently working on an artistic project with the ESP32 where I intend to download an MP3 file from the internet, save it to the SPIFFS (Serial Peripheral Interface Flash File System), and then play it using I2S (Inter-IC Sound) interface. Intended Functionality: Error message i get on serial monitor: What could be the cause of these resets and how can I troubleshoot them? Thank you in advance for your time and assistance. Here's the code:
` |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 7 replies
-
https://github.com/pschatzmann/arduino-audio-tools/wiki/It's-not-working |
Beta Was this translation helpful? Give feedback.
-
Why don't you play it directly or you could play it and download it at the same time ? Or you could take my file download example as a starting point... |
Beta Was this translation helpful? Give feedback.
-
Looks more like a network (infrastructure) issue.. |
Beta Was this translation helpful? Give feedback.
-
What kind of test did you do exactly ? |
Beta Was this translation helpful? Give feedback.
-
I am not sure if it is a good idea to use the driver/dac.h functionality directly and the defines do not have any impact like this. I have some issues with your url as well.... Did you create this mp3 ? ps. I added an example for ftp today... |
Beta Was this translation helpful? Give feedback.
-
I tend to think that the issue is on the server side: You don't hear this on your desktop because all audio players have a big buffer: this is something that we can't afford on microcontrollers... Did you try to play the same from a file on your microcontroller ? |
Beta Was this translation helpful? Give feedback.
-
I downloaded your mp3 with curl, copied it to a SD drive and played it with the help of the sdmmc API and it was playing great! When you set the log level to Info, you can see when it is choking: Like you have highlighted already above. ps if you plan to use mp3 with very high bitrates, do not forget to read the LibHelix wiki. But I would recommend that you avoid this. |
Beta Was this translation helpful? Give feedback.
-
Dear Phil, I hope this message finds you well. I wanted to take a moment to express my deepest gratitude for the invaluable assistance you've provided to the coding community. Your guidance has been instrumental for enthusiasts like myself, who sometimes struggle due to lack of experience. Your willingness to share knowledge and provide support is greatly appreciated. Your recommendation to set up a local FTP server on a Raspberry Pi was a game-changer for my project. It worked seamlessly, and for that, I am incredibly thankful. I'm excited about the progress I've made and was wondering if you'd be interested in having my project featured in the "show and tell" section. It would be an honor to showcase the work that was successful, in part, due to your advice. Additionally, I'm exploring the potential for a "player" feature that allows for changing MP3 files mid-routine. I'm aware of the "player" routine you posted and am curious if it could serve this purpose. Could you provide some insight into this? I'm also seeking a straightforward method to externally interrupt the "write sample to i2s" routine, aiming for a synchronization level that Snapcast doesn't seem to provide. Any suggestions you might have on this would be highly beneficial. Lastly, I've attached the code snippet that worked for me after tweaking some parameters as per the LibHelix wiki guidelines. Any feedback or improvements you could suggest would be welcomed. Warm regards, This is the code that worked:
|
Beta Was this translation helpful? Give feedback.
-
You can also set the codec parameters in the sketch with I think your dac_output_enable and dac_output_voltage doen't really do what you expect and are not necessary. If you want to control the volume here is the documentation. What kind of synchronization logic are you planning to implement exactly ? |
Beta Was this translation helpful? Give feedback.
-
Dear Phil, Thank you for the codec parameter tips; I've incorporated them into my sketch with the setMaxPCMSize and setMaxFrameSize methods as you suggested. Regarding synchronization, I'm currently looking to achieve simultaneous audio playback across multiple boards using a WiFi-triggered command. I haven't settled on a specific implementation yet, but I'm under some time pressure to figure out a viable solution. Do you have any recommendations for a simple way to send such a trigger so that all the boards start playback at the exact same moment? Also, I wanted to clarify that the dac_output_enable and dac_output_voltage functions are indeed serving their purpose in my setup. I'm using them to control the volume through the DAC on the ESP32, which is functioning flawlessly. It's quite useful for managing the volume at a more "analog" stage before it reaches the amplifier. |
Beta Was this translation helpful? Give feedback.
-
The easiest is to send a udp brodcast to all machines. However I don't know how big the time differences will be. The Snapcast protocol is sending the server time in regular intervals so that the clients can adjust. With each audio segment, the information when this is supposed to be played is sent, to make sure that all clients work in time. |
Beta Was this translation helpful? Give feedback.
I downloaded your mp3 with curl, copied it to a SD drive and played it with the help of the sdmmc API and it was playing great!
This confirms that the issue is on your server: it can't provide the data fast enough and adds long delays!
When you set the log level to Info, you can see when it is choking: Like you have highlighted already above.
There are work arounds, but it is better to fix the root cause of the issue!
ps if you plan to use mp3 with very high bitrates, do not forget to read the LibHelix wiki. But I would recommend that you avoid this.