ESP32 Audio DMA Settings Explained - dma_buf_len and dma_buf_count

Поділитися
Вставка
  • Опубліковано 27 лис 2024

КОМЕНТАРІ • 81

  • @atomic14
    @atomic14  3 роки тому +4

    Interested in ESP32 Audio: ua-cam.com/play/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD.html
    Looking for all my ESP32 projects: ua-cam.com/play/PL5vDt5AALlRdN2KyL30l8j7kLCxhDUrNw.html

    • @OMNI_INFINITY
      @OMNI_INFINITY 2 місяці тому

      So CPU writes the buffer to RAM and then the DMA controller sends it to the DAC? Seems so.

  • @jse-shack825
    @jse-shack825 Рік тому +6

    Your ESP32 I2S audio series is the best of its kind on UA-cam, thanks for all the knowledge! A quick note on the I2S config struct: The way it is set up on some of your github repos causes the DMA-buffer pointer to be reset after the buffer has been read completely. This effectively causes the I2S peripheral to always send the last buffer worth of audio even when no call to "i2s_write()" is being made. You effectively can't turn it off. To fix this, set the ".tx_desc_auto_clear" in the config struct to "true". I hope this helps some people who also got confused on why the I2S peripheral seems to have "a life of its own".

  • @andrewkieran8942
    @andrewkieran8942 3 роки тому +7

    I expect that those graphic effects showing data flowing to and from devices and buffers took a lot of time to produce, and I thank you for all of that effort. They really helped to clarify your explanation.

  • @dominikwinkler2718
    @dominikwinkler2718 3 роки тому +17

    Thank you so much for this explanation! So happy! This was exactly what I was looking for!
    Also nice to see that you react on the my and others demand on this topic.
    This video will become a fundamential for every ESP32 user who wants to process audio data!
    Thank you!!!!!!!

    • @atomic14
      @atomic14  3 роки тому +1

      I was getting a lot of questions around it. The problem is, it is really complicated. There's a lot of interaction going on with buffers in your own application. This video barely scratches the surface!

  • @miketony2069
    @miketony2069 3 роки тому +2

    Why can't education be this clear, concise, and approachable. Another wonderful tutorial.

  • @mrmf4712
    @mrmf4712 Рік тому

    I fell asleep twice, but that does not make video less informative. Brilliant!

  • @bhupiistersingh4097
    @bhupiistersingh4097 2 роки тому

    After looking at your M5Core2 audio visualizer, i was like not i need to find a good tutorial explaining configuration of I2S peripheral configs. Guess what, i was glad that i found video on this topic made by you itself. Thanks a ton for the efforts!!!

  • @kamran_aghlami
    @kamran_aghlami 3 роки тому +6

    I'm thankful that you decided to share your knowledge with us, amazing content, best of luck!

    • @atomic14
      @atomic14  3 роки тому +1

      Thanks! And thanks for watching :)

  • @QueirozVini
    @QueirozVini Рік тому +1

    This video is simply awesome. Your didactics is amazing, and the visualizations you provided are really, really helpful to understand the concepts.
    Thank you very much!

  • @rodrigo_dm
    @rodrigo_dm 3 роки тому +1

    ooooooh yes. I'm so glad you posted this. I'm gonna tackle the ESP32 I2S in a month and already watched your other videos. Thank you so much for sharing.

    • @atomic14
      @atomic14  3 роки тому +2

      It was really useful for me to actually sit down and think about this subject - I've hadn't really applied any thought to what the values should be up until now.

    • @NielsNL68
      @NielsNL68 3 роки тому

      @@atomic14 i thank you for that, although this was very useful already, somehow i would have loved it much more when you ended with a walkytalky moment with much better audio because of the better settings of the DMA settings.

    • @NielsNL68
      @NielsNL68 3 роки тому

      One thing i was wondering about the DMA settings in relation of the walky talky using esp-now because of the package size of 200 bytes per message would you agree that setting the DMA size to 200 and the number of buffers higher?

    • @atomic14
      @atomic14  3 роки тому +1

      @@NielsNL68 That's a really interesting question, the code in the walkie-talkie is a little bit more complicated (maybe it can be simplified) as the I2S reading is decoupled from the sending, so there is an application buffer that is filled up with samples as well. We could make the DMA buffer quite small and have a buffer count high enough to allow for the sending time of the esp-now packet. There are a lot of leavers we can play with :)

    • @atomic14
      @atomic14  3 роки тому +3

      @@NielsNL68 That would have been a great demo - I'm kicking myself now for not showing an example of the buffers overflowing and what the audio sounds like when that happens.

  • @lopes33
    @lopes33 2 роки тому +1

    A really good explanation and impresive animations. You should make more of this type of videos. Ty

  • @pascallongpre7797
    @pascallongpre7797 3 роки тому

    Thanks a lot for this! This information was really lacking in the "documentation" I found on the internet! Great visuals also!

  • @MicroMasjien
    @MicroMasjien 10 місяців тому

    Thanks for the very clear explanation and recommendations. If I could have given two thumbs up, I would have!

  • @avejst
    @avejst 3 роки тому +1

    Great video as always 👍
    Thanks for sharing your experience with all of us 👍😀

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 3 роки тому

    Nice video, not tried audio on a ESP32 yet. But now it looks like i should give it ago.

  • @DustinWatts
    @DustinWatts 3 роки тому +1

    Very interesting! Thanks for an in depth explanation!

  • @davidgardener1152
    @davidgardener1152 Рік тому

    super helpful video! thanks so much for these esp audio videos.

  • @jimsnodgrass8454
    @jimsnodgrass8454 Рік тому

    Yes , it was useful in confirming these DMA optimizations are WAY too complex for me to work with.
    I'm going to look over your project links .. For Now I really want to HEAR what typical receptions sound like across a pair of WalkiTaklies, and how pricy the h/w needed is.. .. Thank you. jimS

  • @AdityaMehendale
    @AdityaMehendale 3 роки тому +1

    Great animation/visualization at 6:58 :)
    If I may: the "k" in "kilo" (kBPS, kHz, km, kg, etc) should not be capitalized, as per SI/IUPAC rules. The uppercase K us reserved for absolute temperature (longform unit: kelvin*, with a lowercase k*), named after Lord Kelvin^ (with an uppercase K^).

    • @atomic14
      @atomic14  3 роки тому +1

      That is a very good point. I need to be more careful as it's very easy to get confused with units and cause all sorts of problems!

  • @NaturalbornOfTheVoid804
    @NaturalbornOfTheVoid804 9 місяців тому

    Very nice video! Is there a way to know which dma buffer is used every time if we have 2 buffers for example?

  • @10e999
    @10e999 3 роки тому

    This is sooo good. Thanks for your great examples.

  • @Gauthamphongalkar
    @Gauthamphongalkar 3 роки тому

    Thanks for in-depth explanation.

  • @ytubeleo
    @ytubeleo 3 роки тому +2

    Did you come across anything saying why they limited the buffer length to 1024 samples? It's no problem since we can simply increase the buffer number, but perhaps there are times when it would have been better to use longer buffers and interrupt the CPU less. Also, does dma_buf_count have a limit? I mean, could I use 1000 buffers that are just 8 samples long for example? Perhaps for some real-time control application or the like.
    Thanks for this very useful video - UA-cam has been lacking a video on this!

    • @atomic14
      @atomic14  3 роки тому +2

      There's nothing I could find on why there's an upper limit. And it feels slightly arbitrary as it's measured in samples - so if you're doing 8-bit samples it's 1K, 32-bit samples it 4K. I think there is probably a max limit of 4K on each DMA descriptor. The only limit you have on the buf count is the physical memory available - there is overhead for each DMA buffer that is allocated to maintain the linked list but I don' think it is that much.

  • @ahmedahmed-yg5fl
    @ahmedahmed-yg5fl 2 роки тому

    thank you 💖💖💖 . i was want to understand the dma count

  • @GoatZilla
    @GoatZilla 3 роки тому

    I think it would be neat to cover single ADC multichannel DMA sampling on the ESP32.

  • @chall3ng3r
    @chall3ng3r 3 роки тому +1

    Very well explained 👍

  • @rklauco
    @rklauco 3 роки тому +1

    Very informative, thanks!

    • @atomic14
      @atomic14  3 роки тому

      Thanks - I'm glad it was helpful.

  • @franciscogaray2129
    @franciscogaray2129 3 роки тому +1

    Good video, I have a question? I2S is only for audio application or it's possible other uses. Sorry for my bad English

    • @atomic14
      @atomic14  3 роки тому

      No need to apologise, it's a really good question. I2S generally always used for audio, but it's quite a simple protocol so you could hijack it for other uses. The ESP32 supports a weird parallel mode which can be used to drive LCD displays! github.com/TobleMiner/esp_i2s_parallel

    • @franciscogaray2129
      @franciscogaray2129 3 роки тому

      @@atomic14 Thank you very much for your resply, Greetings from Peru South America

    • @ytubeleo
      @ytubeleo 3 роки тому +2

      I2S (Inter-IC Sound) is a serial, synchronous communication protocol that is usually used for transmitting audio data between two digital audio devices.
      With the ESP32, I2S is commonly used for reading from the internal ADC via DMA buffers without having to interrupt the CPU for every sample. The ADC signal may or may not be audio, but the faster you want to read (up to around 150 kHz for the ADC, I believe), the more useful I2S and DMA is. I believe they could have used just about any protocol to connect to the DMA but I2S presumably seemed like the best option.
      (FYI, the internal ADC is noisy and only really achieves about 7-Bit precision and 6 kHz bandwidth (3 dB cut-off). You can improve the precision by averaging many samples and by adding a capacitor. It also reads zero until the signal is above 0.1-0.2 V.)
      ESP32 contains two I2S peripherals. These peripherals can be configured to input and output sample data via the I2S driver.
      I2S0 can also be used for transmitting PDM (Pulse-density modulation) signals.
      The I2S peripherals also support LCD mode for communicating data over a parallel bus, as used by some LCD displays and camera modules.
      docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html

  • @jackflash6377
    @jackflash6377 2 роки тому

    Suppose I wanted to take the I2S data from a microphone (INMP441) and feed it to a I2S DAC without processing. Just in and out, mono sound signal.
    How would you set up the buffers? Can the ESP32 fill one buffer from the Mic while feeding another buffer to the DAC? I suppose it would need 2 DMA controllers?

  • @sushrutthakur8836
    @sushrutthakur8836 3 роки тому +1

    What are the total no of dma buffers in esp32 ?? What's the maximum value we can use?

    • @atomic14
      @atomic14  3 роки тому +1

      You're limited to the internal SRAM - which is shared between your running application and anything else that is needed.
      In my tests I managed to allocate a total of around 100K before the application started to crash. I assume that there is some internal upper limit on the actual value for the number of buffers, but I did not hit that before running out of RAM.

  • @gmuraly1876
    @gmuraly1876 2 роки тому +1

    Hi, can DMA transfer be used for receiving UART data in ESP32WROOM? If yes, can you share its sample code? I want to receive the OTA update bin through UART from GSM modem connected to UART

    • @gmuraly1876
      @gmuraly1876 2 роки тому

      Can you pls reply to my query?

    • @atomic14
      @atomic14  2 роки тому

      I'm afraid I don't know the answer to your question, do you need to use DMA? The docs for the UART are here. I think you may just need to use interrupts and read the data as required. docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/uart.html

  • @zoyamchuang2806
    @zoyamchuang2806 3 роки тому

    Thanks a lot. Can this kind of project modify to real-time voice modulator with INMP441 and SPK.

  • @dulcegarcia1757
    @dulcegarcia1757 2 роки тому

    Hi! It's a good video!!
    I have a question about the dma buffer. Is possible to use an I2S microphone and I2S DAC in the same time?
    I know that the ESP32 contains two I2S peripherals, but you said in the video "we can only start processing the buffer once the DMA controller has finished transferring data to it", and I am somewhat confused.
    I will really appreciate your answer.

    • @atomic14
      @atomic14  2 роки тому +1

      The two peripherals work independently from each other and have their own DMA buffers so you'll be fine using them both at the same time.

    • @dulcegarcia1757
      @dulcegarcia1757 2 роки тому

      @@atomic14 Many thanks for the prompt reply!

  • @bhupiistersingh4097
    @bhupiistersingh4097 2 роки тому

    What would be the correct way of converting the values obtained from micro controller into -db values?

  • @noweare1
    @noweare1 5 місяців тому

    Question about the math. A sample is 2 bytes so if we change 176k Bytes/sec to samples/sec we get 88200 samples/sec so 8 sample buffer would be 8/88200=91 usec per sample . I guess you figured the time for both left and right channels which would double my time then we are the same?

    • @noweare1
      @noweare1 4 місяці тому

      I went over this again and yes a sample would include both channels.

  • @oliverbertel824
    @oliverbertel824 3 роки тому

    Nice video.
    What program do you use for animation?

    • @atomic14
      @atomic14  3 роки тому +1

      I use a combination of manim - github.com/3b1b/manim and my own homegrown animation library (which is definitely not ready for public consumption).

  • @medb2322
    @medb2322 3 роки тому

    have u ever worked on a decibel meter project if it is I want to know which sound sensor is the best one to use thank you

  • @zoomingh
    @zoomingh 3 роки тому

    Thank you soo match for this.
    I was looking for something like it
    Plz
    Can you give link to download the complete project?
    I am a student, and I need it to complete my work, I have 2 months
    Plzzz
    Ths

  • @tryssss
    @tryssss 3 роки тому +1

    nice video

  • @EdGull
    @EdGull 3 роки тому

    Огромное спасибо за Ваши видео! Отдельная благодарность за качественные субтитры. Субтитры идеально переводятся на русский язык.

    • @atomic14
      @atomic14  3 роки тому

      Переводчик Google потрясающий.

  • @aarriikknn33ll
    @aarriikknn33ll 3 роки тому

    Hi i got some questions regarding bluetooth audio using esp32, where can i get into contact with you? Thanks!

    • @atomic14
      @atomic14  3 роки тому

      I can be contacted via the channel page. I don't know much about Bluetooth audio yet though!

    • @aarriikknn33ll
      @aarriikknn33ll 3 роки тому

      @@atomic14 Oh okay sure! No problem, I don't know much yet aswell. Currently I am just sitting with an issue, I have flashed my esp32 with the default espressif example code found under Bluetooth / bluedroid / a2dp sink / classic_bt but the volume bar is randomly going up and down on my phone, and when pressing volume buttons it doesn't change the volume.
      Do you know a better way by any chance on how to make a Bluetooth receiver using the esp32? I used a pcm5102 dac.
      (Oh yeah and thanks for the article you linked in one of my previous questions on your channel about the Bluetooth audio volume controller for in the shower, I (kinda) got the basics down and got it (kinda) working :)
      kind regards,
      Arik.

    • @aarriikknn33ll
      @aarriikknn33ll 3 роки тому

      @@atomic14 Sorry for interrupting maybe, but is this the channel page that you said you can be contacted trough? Or did I get it wrong? Have a good day!

    • @atomic14
      @atomic14  3 роки тому

      @@aarriikknn33ll On the About tab there's a button to view my email address.

    • @aarriikknn33ll
      @aarriikknn33ll 3 роки тому

      @@atomic14 Ohhh okey thanks, i did not know what you meant exactly.

  • @arduinoanalogico9042
    @arduinoanalogico9042 3 роки тому

    HELLO, IS IT HOW TO GET AUDIO FROM ADC PROCESS AND PLAY IN DAC? FOR EXAMPLE A GUITAR CHORUS?

    • @atomic14
      @atomic14  3 роки тому

      Have a look at the videos in this playlist: ua-cam.com/play/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD.html

  • @TheTurmanDreams
    @TheTurmanDreams 3 роки тому

    Great !!!!

  • @LittlePetieWheat
    @LittlePetieWheat 3 роки тому

    How do you create your animations please?

    • @atomic14
      @atomic14  3 роки тому +1

      Some of them (the text and the equations) are created using Manim - github.com/3b1b/manim (from the guy who runs www.3blue1brown.com/). The of them I've made in Apple Motion (which I'm trying to learn). And some of them I have a very simple animation framework that I've written in JavaScript. I'm still trying to find a tool that I really enjoy using...

  • @miguelq.l.9757
    @miguelq.l.9757 3 роки тому

    Genial