Quickie: Playing MP3's (and other types) on your ESP32 from an SD Card

  Рет қаралды 31,223

XTronical

XTronical

Күн бұрын

Пікірлер: 86
@embeddedjunction9204
@embeddedjunction9204 2 жыл бұрын
hey can u please help. I want to play 2 different music at same time on both internal DAC in esp32 (1st one is played on pin25 on1st DAC & 2nd music is played on 2nd DAC at same time in esp32).
@XTronical
@XTronical 2 жыл бұрын
My DACAudio can do this, mixing both sounds onto to one channel. It will only work with sounds stored in esp32 memory though.
@embeddedjunction9204
@embeddedjunction9204 2 жыл бұрын
​@@XTronical there are 2 mp3 in the SD card & also set the different audio on different channel to play but only one audio play on both channel but i want to play different mp3 on different channel at same time. have u the code related with mine question.
@XTronical
@XTronical 2 жыл бұрын
I don't, sorry.
@iotan09
@iotan09 Ай бұрын
i dont understand why my ESP32 tells me that Sketch too big Sketch uses 1450185 bytes (110%) of program storage space
@XTronical
@XTronical Ай бұрын
How big is the mp3?
@bananaman1397
@bananaman1397 Ай бұрын
@@XTronical I'm having a similar issue. I thought the audio file was stored on the SD card, not the ESP32
@bananaman1397
@bananaman1397 Ай бұрын
@@XTronical Just did a little testing and the "Audio.h" alone takes up 72% of program storage space. Did they update the library and make it huge?
@XTronical
@XTronical Ай бұрын
Yes, your right, I have a library that stores on esp32, got confused, sorry.
@XTronical
@XTronical Ай бұрын
Really, what the hell is on that, that's ridiculous. Although are you just measuring size of the text file? If so that won't all be transferred.
@ramrubicon1014
@ramrubicon1014 10 ай бұрын
Thanks for the sample. Has anyone been able to play more than one audio file with this? What other code would have to be added to have it play multiple files?
@12_fahrulabdulaziz91
@12_fahrulabdulaziz91 10 ай бұрын
Hi friends, my problem is that the SD card is not initialized. Can combining two pins in SD module like the one in the video work? need help :)
@skorakora
@skorakora 4 жыл бұрын
I did everything like in video but sd card won't initialize.
@XTronical
@XTronical 4 жыл бұрын
Did you do the mod to the SD card? It's at 1:33 in the video. On some SD card boards you need to disconnect the regulator and solder a quick by-pass to get them to work with ESP32.
@skorakora
@skorakora 4 жыл бұрын
@@XTronical I found the isue, I added filtering capacitor to power line, and everything works fine
@XTronical
@XTronical 4 жыл бұрын
Brilliant, thanks for adding this info. The current draw can cause issues.
@junhaozhang533
@junhaozhang533 3 жыл бұрын
at 1:16 in text box you wrote GAIN ->GND but on your board it is connect to VCC?
@XTronical
@XTronical 3 жыл бұрын
You can connect to either. Different connection gives a different gain. I think I list these on the project page linked in the description.
@kijngs2584
@kijngs2584 Жыл бұрын
Im looking at using a rotary encoder to play an audio file. Is there a way i can stop the audiofile when i stop turning the encoder
@dennissea.viverosgonzalez3177
@dennissea.viverosgonzalez3177 Жыл бұрын
Hi I getting Error compiling this code, Audio audio was not name a type, I used the library that you put in the video. I also use a ESP32. Do you know what's happen? And Thanks for your tutorial, it is great.
@XTronical
@XTronical Жыл бұрын
I'd check library version just in case something has changed. It may be you are on latest version and I'm using older one due to age of video.
@dennissea.viverosgonzalez3177
@dennissea.viverosgonzalez3177 Жыл бұрын
@@XTronical The error continues. It says: the Audio library is intended to run on sam architecture(s) and may be incompatible with your current card which runs on esp32 architecture(s). I changed the library for an older one. :((
@TlTAN
@TlTAN 2 жыл бұрын
is there any way to conect thos pins of i2s to and auxiliar jack cable?
@XTronical
@XTronical 2 жыл бұрын
Yes, other i2s decoders are available that have a jack built in. Or you can just wire up a socket to the output and it'll work fine. The impedence of earphones is much greater than the speakers being used. Just ensure you connect correctly.
@ilkeraykut7064
@ilkeraykut7064 3 жыл бұрын
Sir,I use esp32sim800l(ttgo tcall) and I get error talking to sd card!. What could it be the problem?I tried 3.3 and 5v vcc.I use micro sd module.
@chrisgallagher85
@chrisgallagher85 2 жыл бұрын
Nice tutorial... and thanks. Love the William Turner quote.
@mrzcs
@mrzcs 2 жыл бұрын
Thanks a lot for your great tutorial. One point to add, i.e. as far as I tested, connecting the SD card vcc to vin pin of ESP32 board makes it work normally. I used the same SD card reader as the video demostrated.
@bunnatang2081
@bunnatang2081 4 жыл бұрын
what if the Amp or DAC requires MCK, what should I do?
@XTronical
@XTronical 4 жыл бұрын
Trying to remember, it can be done but it's a faff, when I was researching the previous episode I read solutions, just can't remember where I read the info off top of my head. I think the extra complexity is why I selected DACS that did not need it.
@zakofrx
@zakofrx 2 жыл бұрын
Are their libraries /Boards that will support 128g etc.. Sd Cards and long filenames/different file systems or are such things above the ability of the esp32??
@XTronical
@XTronical 2 жыл бұрын
Not to my knowledge but I've never had the need for one that big. I imagine there is a technical problem with above 32gb and the 32bit addressing. I would think not insurmountable but I've never looked into it.
@HeikkiHietala
@HeikkiHietala 3 жыл бұрын
Hi! Great video! I am trying to figure out a way of playing multiple sounds, as in a talking clock. I can play single sounds, but getting the system to have a function to which an MP3 file name can be passed, played, and then returned to wait for the next one is a little tough. Do you have any pointers?
@XTronical
@XTronical 3 жыл бұрын
Can't remember at moment and only on my phone but does the code not wait till the sound completes. If not then there should be some properties that state length of time the sample takes. Least I would have thought saw. You then as you worked out need to just pass the filename to the function.
@HeikkiHietala
@HeikkiHietala 3 жыл бұрын
@@XTronical I tried to add two sounds but it actually doesn't play either sound. In the current system, the file is attached to the audio object in the Setup() and the Loop() has only audio.loop(). The audio library not really well documented.
@XTronical
@XTronical 3 жыл бұрын
I try looking through the header file of the library. I can't be much more help at the moment as I don't have access to a computer.
@HeikkiHietala
@HeikkiHietala 3 жыл бұрын
@@XTronical thank you for this.
@yoseph6456
@yoseph6456 3 жыл бұрын
Why is the gain in the video connected alongside the vcc?
@XTronical
@XTronical 3 жыл бұрын
It's from the datasheet, you can attach the gain to gnd, vcc, or to some resistors for various gain settings. I think this gives 9 dB if I remember correctly.
@yoseph6456
@yoseph6456 3 жыл бұрын
@@XTronical so the best choice would be to connect it to the vcc?
@XTronical
@XTronical 3 жыл бұрын
For my speaker it gave good volume without distortion. Larger or smaller speakers may be OK with different setting.
@iceberg789
@iceberg789 Жыл бұрын
does it sound better than regular phone mp3 ?
@XTronical
@XTronical Жыл бұрын
Yes and no. The tech is basically the same. The factors that matter would be the bit rate of your sample and the quality of the speaker and it's housing. Probably the speaker and enclosure being quite important as bit rate is easy to change. For there speaker size most reasonable phones do a good job. So some effort has gone into that area.
@iceberg789
@iceberg789 Жыл бұрын
@@XTronical oke
@serdar-abali
@serdar-abali Жыл бұрын
Thank you for this very simple tutorial.
@jaysunx1
@jaysunx1 3 жыл бұрын
if my mp3 file on the sd card is named "music" does the string in the code need to be "music.mp3" or "/music.mp3" ??
@XTronical
@XTronical 3 жыл бұрын
As it originally is "/amaze. mp3" it would be "/music. mp3"
@jaysunx1
@jaysunx1 3 жыл бұрын
@@XTronical thanks
@jaysunx1
@jaysunx1 3 жыл бұрын
​@@XTronical hey again, so is the library supposed to only work with 8 or 16 bit pcm? And if so why are all the test sounds in the library folder 32bit?
@XTronical
@XTronical 3 жыл бұрын
It should work with a variety of bit rates etc. As long as they are mp3. It will then convert to i2s/pcm for transmission to the decoder chip.
@Darkipod
@Darkipod 3 жыл бұрын
I see the speakers themselves are listed, but what about those printed cases?
@XTronical
@XTronical 3 жыл бұрын
Sorry, any 4 to 8 ohm speakers will do. Those ones on screen are out of an old laptop. The ones listed are just ones that are suitable.
@farisa.f3095
@farisa.f3095 4 жыл бұрын
Can you make it controllable with piezoelectric input? Like octapad?
@XTronical
@XTronical 4 жыл бұрын
Depends what level of control you'd want I guess. You can read the input from sensor and control basic play back but I don't think the library offers a lot of control over the output.
@bennguyen1313
@bennguyen1313 4 жыл бұрын
Do you think the ESP8266 (Single 80Mhz Core) could do this, or do you need the power of the ESP32 (160Mhz Dual Core)? BTW, any thoughts on using Visual Studio Code with the Espressif IDF extension instead of the Arduino environment?
@XTronical
@XTronical 4 жыл бұрын
Yes, it should be able to, I think the libraries github page (link in description) may confirm. I've got plans to move over to VS, I use it as a simple editor but not properly.
@rodrigo_dm
@rodrigo_dm 4 жыл бұрын
Hi there, nice project. What would be the sampling rate of your output DAC?
@XTronical
@XTronical 4 жыл бұрын
Upto 50000 samples per second max
@GuillaumeCorgnet
@GuillaumeCorgnet 2 жыл бұрын
Hi, thanks for the video, it was useful content. Do you have a video where you explain how to get the code on the ESP32 chip? You seem to be skimming through this very quickly
@XTronical
@XTronical 2 жыл бұрын
Getting the esp32 to work with the Arduino ide is beyond the scope of that video. I have done a seperate video on this but it is quite old and probably out dated. I would type in "esp32 on arduino" ide" on KZbin for an up to date guide on how to set up and upload code to esp32. Then this guide should be easier.
@dragoshujunior4909
@dragoshujunior4909 2 жыл бұрын
Very useful video, ty buddy!
@michaelpxd6325
@michaelpxd6325 3 жыл бұрын
Hello is it possible to regulate the volume digital with this library? Great video btw!
@XTronical
@XTronical 3 жыл бұрын
Yes, you can.
@RDCST
@RDCST 4 жыл бұрын
Would you please keep in silence a bit more to appreciate the audio quality? Thanks!
@XTronical
@XTronical 4 жыл бұрын
Sorry,
@RDCST
@RDCST 4 жыл бұрын
@@XTronical Thanks for understand.
@wei48221
@wei48221 4 жыл бұрын
Thank you.
@phillipneal8194
@phillipneal8194 4 жыл бұрын
Bravo !!! But alas, my talents lie elsewhere....1:10
@electronash
@electronash 4 жыл бұрын
lol You were corpsing for ages after that balls-up.
@MannyCaruana
@MannyCaruana 7 ай бұрын
Second MAX98357A and speaker are a waste of time and money in this configuration. No difference between left and right channels.
@XTronical
@XTronical 7 ай бұрын
I've tested with a known stereo test track, it shows it works. How are you testing?
@MannyCaruana
@MannyCaruana 6 ай бұрын
@@XTronical I have not tested. I'm just basing my statement on you leaving the SD pin of both MAX98357A boards unconnected. This will put the boards into mono mode and output (L+R)/2 from both. Yes, you will hear sound from both speakers, but it will be the same sound. You have to configure the voltage on the SD pins to specifically select Left or Right channel.
@XTronical
@XTronical 6 ай бұрын
You've misunderstood the use of the SD pin, check the data sheet but in brief. The SD is not the pin that selects stereo channel. It either shuts the device down if low or if high (and unconnected floats high) it specifies that the LRCLK pin should be used to determine which data is left or right channel. The timing diagrams are in the datasheet for LRCLK etc. As I said I tested with special stereo testing tracks for Mp3 as well. Basically if high it is saying "OK work normally in stereo I2S" which then uses the LRCLK pin for left and right channels. So you can see all is correct. The clue is in the pin names, SD for Shut Down, LRCLK for Left Right Clock. Look up my video explaining I2S, that may help
@MannyCaruana
@MannyCaruana 6 ай бұрын
@@XTronical I agree hat LRCLK determines the channel of the current data stream, but there also needs to be something that tells each individual chip which channel to output. One chip has to output data while LRCLK is high and the other while LRCLK is low. This is the function of the SD_MODE pin to give it its full and proper name. As you say, grounding this pin shuts things down. Different voltages on this pin (via pullup resistors) define the mode which can be Left or Right or Mono. No connection gives Left channel only. As you have tested with stereo tracks and everything works, I can only think that one of the chips must be a MAX98357B which defaults to right channel if left unconnected. Otherwise I fail to see how two identical chips, wired the same way and fed the same data can output different sounds.
@XTronical
@XTronical 6 ай бұрын
Right, some apologies but also I'm not sure you've listened to the video closely. Firstly yes, you have to do something to the boards to get stereo but it's nothing to do with the SD pin. I forgot about that bit in my replies, but it's been a while since I did this video but sorry for forgetting that. But at just 50 seconds in it tells you to watch my earlier video on setting these boards up for stereo as I won't be covering that again in this one, I even emphasise how important it is to do this. You must have missed this information or forgot I'd mentioned it. So that should clear that up. Once again, sorry for any confusion caused.
@InterplainMusic
@InterplainMusic 4 жыл бұрын
How many Rum and Coke did you have lol
@XTronical
@XTronical 4 жыл бұрын
Ha ha, not enough! You must have been a sub for quite a while, not mentioned rum and coke in ages!
@InterplainMusic
@InterplainMusic 4 жыл бұрын
@@XTronical yes, I have been programming for a few years. Made my own 3d printer with a laser cut frame. And programmed Marlin. And made a few Arduino projects. Like to watch and learn things like what you do. Been programming a ESP2866 WiFi module to control my 3d printer. I upgraded the memory chip on it to 4mb from 1.
@XTronical
@XTronical 4 жыл бұрын
Hey, wow, the stuff you've done is fantastic. I really like that music too. I have very little talent for music unfortunately, wish I had some! Do you want me to use your stuff in a future (probably next) video and give you a shout out?
@InterplainMusic
@InterplainMusic 4 жыл бұрын
Thanks for taking the time to pop over to my page much appreciated. I would be very happy for you to use some of my tracks. Not sure which is best suited. But I do record most days. I have many tracks you could use. My email is interplain1@gmail.com I will remove this when you have read it. And replied to this. Not sure if you can personal message within KZbin. Not found it if you can.
@XTronical
@XTronical 4 жыл бұрын
I've read it (sorry for taking so long), will contact you. You tube used to do a messaging sort of thing, but not anymore
@Brian_Of_Melbourne
@Brian_Of_Melbourne 4 жыл бұрын
Perhaps a few more "Take Two!" calls would be better rather just mucking about? We all make mistakes, but not everyone want to watch them.
@XTronical
@XTronical 4 жыл бұрын
And some prefer this style, ever heard the phrase "you can't please all of the people all of the time". From your recent comments you don't like my style, you don't like my hobby approach, why the heck do you keep watching? I avoid things that I don't like and don't have to do. Bizarre! Vote with your eyes and don't watch.
@Elnasir
@Elnasir 2 жыл бұрын
Stop trying to be funny, it is distracting
@XTronical
@XTronical 2 жыл бұрын
Just don't watch then, loads of other channels.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Play MP3 Files on ESP32 Without Codec Chip: Easy Guide
8:51
atomic14
Рет қаралды 96 М.
I Made The Ultimate Cheating Device
9:39
ChromaLock
Рет қаралды 1,9 МЛН
Cheap and Easy to Use ESP32 Screen!
8:21
Brian Lough
Рет қаралды 184 М.
Forget WiFi! This Wireless Method is WAY Better? (ESP-NOW)
12:14
GreatScott!
Рет қаралды 762 М.
Bizzare Shifter
18:04
upir
Рет қаралды 450 М.