Play MP3 Files on ESP32 Without Codec Chip: Easy Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • We're playing MP3 files with no additional hardware! As always, big thanks to www.PCBWay.com/?from=atomic for sponsoring this video.
    We're messing around with more audio in this video. This time we're looking at decoding and playing back MP3 files on the ESP32 - all done in software, no fancy codec chips required.
    0:00 Why MP3?
    2:55 Decoding MP3 Data
    3:40 Headphone output using the built-in DAC
    5:58 I2S Output to the MAX98537 Amplifier
    8:06 Bonus content - volume control!
    Here's a link to the record-breaking shortest published song: • Napalm Death - You Suffer
    Here's my ESP32 audio playlist - there's a lot of gems in there for you to watch: • ESP32 Audio
    And here's the code: github.com/atomic14/esp32-pla...
    You can get a headphone jack breakout board here (Amazon affiliate link): amzn.to/3wdinpW
    ----
    Patreon: / atomic14
    ko-fi: ko-fi.com/atomic14
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 77

  • @mojo_jojo
    @mojo_jojo 2 ปีที่แล้ว +4

    Thanks for adding the part about the partition tables. That something I was having issues with on one of my projects. Finally I understood how it works

    • @atomic14
      @atomic14  2 ปีที่แล้ว +3

      No problem - I didn't really understand it until I actually did that bit - the documentation is a bit all over the place.

  • @alanj5036
    @alanj5036 2 ปีที่แล้ว +8

    Terrific, and simple. Sounds great too! To compile in ESP32 arduino framework, just need to change I2S_COMM_FORMAT_STAND_I2S to I2S_COMM_FORMAT_I2S.

  • @MudahnyaCoding
    @MudahnyaCoding 2 ปีที่แล้ว +3

    I'm surprised a good channel like this only has a few subscribers, it should have more than 1 million subscribers

  • @SinanAkkoyun
    @SinanAkkoyun 2 ปีที่แล้ว

    Loving your videos since day 0.

  • @black_winghd1429
    @black_winghd1429 8 หลายเดือนก่อน

    Thank you so much! Immaking a silly little project and ive spent hours for a simple libary for simply directly plaiyng an mp3 file into a speaker from the esp32. Saved my day

    • @atomic14
      @atomic14  7 หลายเดือนก่อน

      That’s great! I can’t claim any credit for the MP3 code. Someone much more clever than me made that.

  • @theunderdog2205
    @theunderdog2205 2 ปีที่แล้ว +2

    Another excellent video thank you once again.

    • @atomic14
      @atomic14  2 ปีที่แล้ว +3

      Thanks - was good fun to make. I had no idea that decoding the MP3 data would be so easy. Definitely a case of standing on the shoulders of giants...

  • @sharpbends
    @sharpbends 2 ปีที่แล้ว +1

    Excellent explanation and demonstration :-)

  • @dimmoos757
    @dimmoos757 2 ปีที่แล้ว +1

    Excellent and practical. Thank you so much!

    • @atomic14
      @atomic14  2 ปีที่แล้ว +1

      Glad you liked it.

  • @ihorivlev8479
    @ihorivlev8479 ปีที่แล้ว +4

    the noise might be caused by delays during data processing (stalls caused by buffer reallocation for example)

  • @peter.stimpel
    @peter.stimpel 2 ปีที่แล้ว

    off-topic: nice reference :) thanks for bringing up memories from long time ago

  • @kickthejetengine
    @kickthejetengine 2 ปีที่แล้ว +1

    I’m working on a project that uses I2S with an esp32 on a custom pcb. I actually have a working version already but have slight noise and would love larger volume and possibly a physical volume control. I would love to get some advice on my schematic. I found your video and you seem to have the knowledge I lack. Let me know if you’d be open to some consulting, paid obviously.

  • @maureljulien
    @maureljulien ปีที่แล้ว +1

    Hello !
    Thank you so much for this extremely detailed and useful video !
    Would you please help me on this :
    - for direct DAC output to headphone thru RC, what R value have you implemented ? EDIT : ok you answered 500-2kohm in the vid sorry ;) I've searched for DAC max output current, some say 12mA, other 40mA, would you know about that ? What's you experience on this ?
    - for MAX98357 option, in order to use same stereo headphones, how should I connect both MAX N-output together ? Is it possible to connect them directly on jack ground ?(I suppose not...)
    Thank you so much for all the content you're sharing, it is truly helpful!!

  • @jumadhaheri
    @jumadhaheri 2 ปีที่แล้ว

    Fantastic gave me an idea of making a story teller for my kids

    • @atomic14
      @atomic14  2 ปีที่แล้ว +1

      That’s a great idea - if you get a module with 16mb of flash then you can actually store quite a bit of audio.

  • @timothycarson1771
    @timothycarson1771 2 ปีที่แล้ว

    Excellent as always. for a future project could you add DSP processing?

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      That's a great idea!

  • @marcozatarain9630
    @marcozatarain9630 2 ปีที่แล้ว +1

    Nice, have you thought about adding AVS Alexa voice services to Marvin?

  • @arduinoguru7233
    @arduinoguru7233 ปีที่แล้ว

    2:34 even @ 45kbps song can be hearable with quite a bit of (glitches), my own experience was with PCM 8bit and 4k sampling rate, (yes I go as low as that), even recorded songs were recognizable, and I saved plenty of space, BTW there is Speech codecs that save even more space.

  • @TheDradge
    @TheDradge ปีที่แล้ว +1

    Where is the link to the stereo MAX98537 board? It says in the video you've linked to the design files. Thanks.

  • @embeddedjunction9204
    @embeddedjunction9204 ปีที่แล้ว +1

    hello, can u help me. i want to play two different music on both internal DAC in esp32 at same time (1st one is play on pin25 & 2nd one is on pin26 at same time) please help!

  • @miguelmelgarejo973
    @miguelmelgarejo973 6 หลายเดือนก่อน

    Hello, thank you for the tutorial. I am going to try minimp3 library but don't know if I should use all the code downloaded from GitHub or just if taking the minimp3.h header file would be enough as the whole library is not so light.

  • @HEILZEUS
    @HEILZEUS 2 หลายเดือนก่อน

    does there exist an I2S interface that doesn't have an amplifier and only gives analog outputs ? I want to use dual TPA3110 amplifiers after the Max amplifier, but it shuts down for some reason.

  • @LightGameFrameworks
    @LightGameFrameworks 8 หลายเดือนก่อน

    I'm so happy, my first esp32 is showing up in the mail today! That image of a microSD-card adapter strapped directly to the breadboard has me all kinds of excited.
    Can code be loaded then run from a micro-sd in this manner, or would it be data only?
    I suppose the biggest factor is the size of ram on the chip, but I would love a hot-pluggable library of programs...

    • @atomic14
      @atomic14  8 หลายเดือนก่อน

      As far as I know it’s not possible to load code from the SD Card - sorry.

  • @adamkoxxl
    @adamkoxxl 9 หลายเดือนก่อน +1

    Good video. I would use FATFS or LittleFS instead because SPIFFS is not being developed anymore and is buggy, especially when you reach about 80%+ of total capacity.

  • @CoolshrimpModz
    @CoolshrimpModz 7 หลายเดือนก่อน

    I cant seem to get this to work with internal DAC, I have 25/26 to the amp to small speakers. Playing a song with tones works, but can’t play a wav or mp3 file off a microSD it plays a constant clicking hum.

  • @raphanunu6912
    @raphanunu6912 5 หลายเดือนก่อน

    Helpfull indeed, but not enough for me, that's anyway a good start, thx.

  • @gearscodeandfire
    @gearscodeandfire 11 หลายเดือนก่อน

    Found this from a search, subbed when i saw Napalm
    Death 7"

  • @steubens7
    @steubens7 ปีที่แล้ว

    at 6:55 it says there's a link to the video about that board, but there's only a link to a playlist

  • @aimeiz1
    @aimeiz1 3 หลายเดือนก่อน

    I tried to compile project using Visual Studio Code and Platformio, but it failed. I got some error message related to compiler configuration rather than code itself. I prepared project to compile it u8sing Arduino IDE. To make it simple I put all libraries together with main code to the same catalog and modified #include paths accordingly. It compiled and uploaded, also uploaded mp3 file to spiffs. Set configuration to ESP32 DAC. It doesn't play - ports 25 and 26 shows arrount 0 vaoltage on the scope. Maybe my porting to Arduino IDE is not as it should be?? Could somebody who succeeded to compile and run it using Arduino IDE publish ported project?

  • @devvratarya4985
    @devvratarya4985 2 ปีที่แล้ว

    what is the rating of capacitors connected to headphone jack

  • @thexht7927
    @thexht7927 ปีที่แล้ว

    But how do you upload the mp3 to esp32?

  • @WistrelChianti
    @WistrelChianti 2 ปีที่แล้ว

    is the situation with the capacitor due to the signal on the DAC being offset AC? i.e. the pin is DC (never negative) so is it essentially chucking out 1.6V when silence is played meaning the speaker, if there is a speaker involved, would only ever move half way? Therefore, if you put a capacitor in you get a brief moment of noise while the cap charges to 1.6V and then Voltage is effectively zero. When the DAC output goes up, this is passed while the cap charges, and when it goes down, the Cap discharges. This way the speaker sees AC?

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      The speaker would move half way for silence and then oscillate around that half way point instead of oscillating around its "neutral" point - so it will still work, but it's not ideal. There's some good explanations here as to why that is bad: electronics.stackexchange.com/questions/233230/why-are-dc-signals-bad-for-loud-speakers

    • @WistrelChianti
      @WistrelChianti 2 ปีที่แล้ว

      @@atomic14 thanks.. I think that's an affirmation that I was on the right track?

    • @WistrelChianti
      @WistrelChianti 2 ปีที่แล้ว

      @@atomic14 Thanks for the link! Interesting read and indeed hadn't considered that you are pulling more current when applying an unchanging DC voltage to a speaker. That said. If you are outputting a square wave say that is default off at zero volts, doesn't seem to be too much issue with putting it to a speaker, just means you'll only get movement in one direction. Not ideal but not the end of the world either. In the case of the DAC though, I'm assuming the wave is oscilating about the 1.65V mark, in which case using a capacitor to get rid of that offset would be a good idea. Otherwise would be defaulting to having it stuck half way out in one direction and not moving.

  • @dukedougal16
    @dukedougal16 2 ปีที่แล้ว +1

    Can mp3 be played using micropython?

  • @poepflater
    @poepflater 2 ปีที่แล้ว

    reminded of early sound cards

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      Good old 8-bit quality :)

  • @noevandenbranden1229
    @noevandenbranden1229 2 ปีที่แล้ว +3

    It would be interesting to see the ESP32 receiving the sound data over WiFi. The bitrate for the audio is quite low so shouldn’t be a problem. Like a DIY audio chromecast!

    • @bestlowspecgamer7196
      @bestlowspecgamer7196 9 หลายเดือนก่อน

      exactly, I am looking for it now...any idea to achieve this on esp32

  • @alexandresetto3808
    @alexandresetto3808 ปีที่แล้ว +1

    Hi there, tks for the code example, but... I need some help, I having some errors in the code, could you help me to understand whats is happening Please? See below the VSCODE errors message.
    .
    "message": "narrowing conversion of 'sample_rate' from 'int' to 'uint32_t' {aka 'unsigned int'}",
    "message": "missing initializer for member 'i2s_driver_config_t::mclk_multiple' [-Wmissing-field-initializers]",
    "message": "missing initializer for member 'i2s_pin_config_t::mck_io_num' [-Wmissing-field-initializers]",
    Tks so much.

    • @davidgardener1152
      @davidgardener1152 ปีที่แล้ว

      yes im getting these too. did u find a fix?

  • @alfem
    @alfem 2 ปีที่แล้ว

    Awesome video! I can't find the link to the breakout board you mention at 6:49. Should I blame my old eyes or it is not in the video description?

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      I've added this link (amazon affiliate link) to the description - amzn.to/3wdinpW these look the same as the ones I have - though I'm not actually sure where my one came from...

    • @alfem
      @alfem 2 ปีที่แล้ว

      @@atomic14 I am afraid I misunderstood your comment about the breakout board. It is little more that a stereo socket but I thought it included some amplifiying chip. Thanks anyway!

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      @@alfem Sorry - yes - it just avoids you having to chop up your headphone cable. If you're looking for an analogue amplifier then there are a few good breakout boards available: www.adafruit.com/product/2130 though if you want an amplifier then I'd use the I2S output and a MAX98537 board.

  • @joshuaisaacs8970
    @joshuaisaacs8970 9 หลายเดือนก่อน

    Would be great if there was the code side of this for the project to work, the wiring is really quite simple

    • @atomic14
      @atomic14  9 หลายเดือนก่อน

      In the description

  • @xianfengwuk1590
    @xianfengwuk1590 ปีที่แล้ว +1

    Nice. Thinks for your share. Love from china. Good luck for you.

    • @atomic14
      @atomic14  ปีที่แล้ว

      Thank you very much!

  • @burhanbudak6041
    @burhanbudak6041 2 ปีที่แล้ว

    I wish OPUS for music and voice was made ready for Bluetooth wireless earbuds.

  • @agustinsida8877
    @agustinsida8877 ปีที่แล้ว +1

    "haha how silly, 1.3 sec song". Then I read the title.

  • @dukedougal16
    @dukedougal16 2 ปีที่แล้ว +1

    Can mp3 be played to a bluetooth speaker?

    • @orfrantjavierrivera
      @orfrantjavierrivera 2 ปีที่แล้ว

      i had the same question, if you find some clue, please tell me

  • @Gabrielpimgomes
    @Gabrielpimgomes ปีที่แล้ว

    Ei atômico, ou quem esteja vendo, sou brasileiro, use o google tradutor.
    gostaria que alguém me ajuda. uso arduino ide, com codigos .ino.
    mas seus arquivo no github não tem esta extensão, pergunta, como faço para gravar seu código no esp 32 por ide arduino?

  • @davidgardener1152
    @davidgardener1152 ปีที่แล้ว

    do you have any tipe for how to port this over to arduino IDE? im having a nightmare trying to do it!

    • @atomic14
      @atomic14  ปีที่แล้ว +1

      I’ve just fixed some compilation errors that was stopping it building with the latest esp-idf. That might help.

    • @davidgardener1152
      @davidgardener1152 ปีที่แล้ว

      @@atomic14 oh wow thanks so much for the response! I will try again. this is via platform IO yes?

  • @BBBA_
    @BBBA_ ปีที่แล้ว

    I like ONE OF THESE NIGHTS 1975.

  • @Morpheus.theDreamlord
    @Morpheus.theDreamlord ปีที่แล้ว

    Лайк за Napalm Death ;)

  • @BBBA_
    @BBBA_ ปีที่แล้ว

    I am tired of getting the warning on ASK FM.

  • @envy7818
    @envy7818 2 ปีที่แล้ว

    Excellent
    I was trying to decode RTP stream using the same way but unfortunately not successfully
    if you can support me with this I will be grateful to you
    thank you.

  • @anderesgooglekonto6869
    @anderesgooglekonto6869 2 ปีที่แล้ว

    Is it pissible to Copy Ur Code for this ?

    • @atomic14
      @atomic14  2 ปีที่แล้ว +1

      Code is all on GitHub - feel free to use it for whatever you need.

    • @anderesgooglekonto6869
      @anderesgooglekonto6869 2 ปีที่แล้ว

      @@atomic14 thank you for the fast reply :)

  • @DaleDix
    @DaleDix 5 หลายเดือนก่อน

    Hello

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 2 ปีที่แล้ว

    sounded better without my hearing aids. 😃

    • @atomic14
      @atomic14  2 ปีที่แล้ว

      When I was making it, I was just thinking, I'll plug this into the line in, get a nice recording, it will sound great. So many computers in the house - not a single one has a line-in input!

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 2 ปีที่แล้ว

      @@atomic14 My desktop one still has, but it's getting a bit long in the tooth. Now it all moved over to USB. but then I still love the sound of records.