How do you write your own SD Card WAV Player on ESP32 over I2S - all the details

  Рет қаралды 12,357

XTronical

XTronical

Күн бұрын

A detailed look at how to play WAV's from SD without using 3rd party libraries for transfer of WAV's to I2S. It should give you enough detail to add this into your own code/wav players.
Project page with demo software available at:
www.xtronical.c...
Affiliate links for the items shown:
ESP32 : amzn.to/3kb02n8
ESP32 - Pack of three : amzn.to/2XfIRqH
I2S Decoder : MAX98357A : amzn.to/3fkHEnU
SD Card Reader : amzn.to/2Q9Fb5V
3W Speaker : amzn.to/2XeRP7i
Breadboards : amzn.to/30fWibZ
Wires : amzn.to/3k4PKoC
Pins and sockets : amzn.to/39O7a3K (I2S board doesn't come with them)
Time Codes
Intro - 00:37
Circuit Diagram - 01:41
Demo 1 Code (does not work) - 03:48
Demo 2 Code (works but will slow your main code) - 09:27
Demo 3 (best) Flow Chart - 14:24
Demo 3 (best!) Code - 17:16
Epilogue - 19:29
For other projects and ideas see :
Web : www.xtronical.com
If you'd like to support me via Patreon then the link is below and that would be just amazing. Patreons have access to all videos early plus can view all the posts on Patreon. There are other rewards if you're interested. If you just want to watch videos then that's also fantastic because without people viewing I wouldn't even do half of what I do. So thanks very much :)
Patreon at : / xtronical
If you don't like Patreon and would like to say thank you in other ways then there's also:
Kofi (Coffee) if you want to tip me for a brew! : ko-fi.com/xtro...
Also if you go to my website www.xtronical.com you will a part on every page to make a direct one off donation to my paypal.
Credits
Intro/Outro Music by Creo Music : www.creo-music.com
Some sounds from Freesound.org
Some images from OpenClipart-Vectors from Pixabay

Пікірлер: 30
@torch1ca
@torch1ca Ай бұрын
Easily the best audio file tutorial I've seen. Very comprehensive and I have a much better idea of the scope and feasibility of my project thanks to you
@pauld1988
@pauld1988 3 жыл бұрын
This might be one of the most informative, least annoying YT videos I've ever seen. Excellent!
@pauld1988
@pauld1988 3 жыл бұрын
Hey is there a way I can get in touch with you X?
@NikiDorian
@NikiDorian 3 жыл бұрын
Excelent. As a follow up you may add a playlist functionality, decoder for compressed audio containers, switching between the decoders as the playlist goes from one track to another one with different format, encoding, etc...
@davidburke52
@davidburke52 4 жыл бұрын
Thanks, This will help with the project I'm developing. Also my understanding of the process makes my project more reliable. Keep up the great work
@XTronical
@XTronical 4 жыл бұрын
Thank you
@GorgusGFX
@GorgusGFX 4 жыл бұрын
Great work! Looking forward to the next part.
@XTronical
@XTronical 4 жыл бұрын
Thank you, very kind comments
@TheElectronicEngineer
@TheElectronicEngineer 2 жыл бұрын
Got it all working except, when the wav file playing is done, it keeps going, producing noise...it seems that sketch doesn't see that the file has ended...The wavheader.datafile is always way bigger then what the wave file realy is. any idea on this bug?
@XTronical
@XTronical 2 жыл бұрын
So the length taken from the header file is much bigger than the actual data? Have you tried a different simple wav file?
@TheElectronicEngineer
@TheElectronicEngineer 2 жыл бұрын
@@XTronical yeah looks like that; i will try a smaller file today. It happend with a 44k1 16hz. I think it is an overflow as the size variable is int16 or int32
@XTronical
@XTronical 2 жыл бұрын
Is it. Will change.
@matthewbarnett3
@matthewbarnett3 3 жыл бұрын
Great tutorial though the bit where you are trying to connect the usb cable causes me some discomfort😄. Keep up the great work.
@huch4265
@huch4265 6 ай бұрын
Amazing content and you sound like a cool dude, I subscribed :))
@davidealessandrini2235
@davidealessandrini2235 4 ай бұрын
Thank you for your videos. I have implemented the routine you suggest in the video to read from SD and write to i2s, however I have a problem. The audio plays well but sometimes I have interruptions/noises, not periodically but randomly. the duration of these noises is approximately 1 but also 3 seconds. My suspicion is that there is some task on esp32 (I'm not an expert) taking up a lot of resources at that time. I tried disabling any LOGs but it didn't help. Do you have any suggestions? Thank you in advance
@alfredopreciadomolina1576
@alfredopreciadomolina1576 4 жыл бұрын
I think that wav files represent less load than mp3 files because it doesn't have to work on decoding, only on transferring the data to the i2s buffers
@XTronical
@XTronical 4 жыл бұрын
Yes, they do, one good reason to use them for sure. I've some tests I'm planning though in the future to see which is better performance overall, as mp3 takes up approx 10 times less data than wav, so 10 times faster to transfer from Sd card but of course it then needs decoding, where as wav needs no real decoding but takes 10 times longer from SD. My intuition says mp3 might win in this situation but I've got to do the tests to be sure. If both stores in internal memory then wav wins hands down.
@alfredopreciadomolina1576
@alfredopreciadomolina1576 4 жыл бұрын
I know it's a lot to ask, but it would be great if you could find a way to get the bluetooth communication sound information, for example (a2dp) 👀
@XTronical
@XTronical 4 жыл бұрын
Yes, a few people have asked for Bluetooth and I want to and will do it, but it's not in the immediate future unfortunately. I've several things to do first. Thanks for your comments and support
@mitchell5267
@mitchell5267 2 жыл бұрын
Thank you for your I2S tutorial. I have completed parts 1-3 but I was not impressed with the delay between when the command to play the WAV file is issued and the time elapsed before it actually starts to play (~1 sec) I am attempting to create a sound effect based on a button press and I need the short sound effect to be perceived as by the user as instantaneous. What method do you recommend to achieve this and would you be able to provide an example? Is the majority of the 1s delay from reading data out of the SD card or is it in the MAX98357A CODEC?
@XTronical
@XTronical 2 жыл бұрын
I am returning to this after two episodes of the 6502 project. I will improve it then. It's going to be slow initial access to sd card although 1 second is more than I would have expected. Anyways there are ways round it.
@VMHache
@VMHache 3 жыл бұрын
Gracias! desde el otro lado del mundo. La serie de videos fue muy ilustrativo para entender como funciona y como mejorar el sonido.
@XTronical
@XTronical 3 жыл бұрын
De nada
@jaiman4764
@jaiman4764 Жыл бұрын
Hi! I'm working a project and this video was extremely informative! Thank you so much! Quick question, I'm using a MCU that does not have an I2S module. Do you believe that the logic used here (of course with some modifications to the actual code!) would work in my case if i'm using I2C? Thanks!
@XTronical
@XTronical Жыл бұрын
Unfortunately not, it's a very different protocol. If your mcu has a DAC then you can could possibly do something with that.
@graysong5787
@graysong5787 3 жыл бұрын
Do I need an I2S amp for this, or can I just write the SD data to a buffer and then write that Buffer to the onboard DAC?
@graysong5787
@graysong5787 3 жыл бұрын
For anyone wondering the answer to this, you can point the I2S output to the internal DAC which can then output to an external amp
@SarahKchannel
@SarahKchannel 2 жыл бұрын
How does the SD implementation work when playing multiple files at the same time from card ?
@XTronical
@XTronical 2 жыл бұрын
Has to read in blocks of data at a time into buffers otherwise the sd can't keep up with random access to single bytes
@SarahKchannel
@SarahKchannel 2 жыл бұрын
@@XTronical Yeah, the throughput restriction was obvious. I think the bytes read through multiple files, keeping the buffer filled would be a slight nightmare over multiple files. I am creating interactive objects, like small sculptures. That among other things can play sounds if one gets too close etc... layering those sounds is what makes it interesting over just SD playback - lets say with an DFplayer. I think i need to find a way to squeeze them into memory...
Writing your own ESP32 I2S WAV Player - Part 5 - Mixing sounds
8:47
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 2 МЛН
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 35 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 47 МЛН
The FASTEST way to PASS SNACKS! #shorts #mingweirocks
00:36
mingweirocks
Рет қаралды 15 МЛН
ESP32 Gaming Console - Homemade Emulator Less Than 20$
10:26
Electronoobs
Рет қаралды 77 М.
Building a Digital Music Player with I2S?! What is I2S! EB#45
10:24
Play MP3 Files on ESP32 Without Codec Chip: Easy Guide
8:51
atomic14
Рет қаралды 85 М.
ESP32 Audio Input Using I2S and Internal ADC
10:43
atomic14
Рет қаралды 126 М.
Audio modules for electronics project
37:54
Playful Technology
Рет қаралды 49 М.
Новый уровень твоей сосиски
00:33
Кушать Хочу
Рет қаралды 2 МЛН