Interested in ESP32 Audio: ua-cam.com/play/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD.html Looking for all my ESP32 projects: ua-cam.com/play/PL5vDt5AALlRdN2KyL30l8j7kLCxhDUrNw.html
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".
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.
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!!!!!!!
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!
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!!!
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!
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.
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.
@@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.
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?
@@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 :)
@@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.
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
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^).
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!
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.
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
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
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?
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.
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
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
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.
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?
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
@@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.
@@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!
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...
Interested in ESP32 Audio: ua-cam.com/play/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD.html
Looking for all my ESP32 projects: ua-cam.com/play/PL5vDt5AALlRdN2KyL30l8j7kLCxhDUrNw.html
So CPU writes the buffer to RAM and then the DMA controller sends it to the DAC? Seems so.
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".
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.
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!!!!!!!
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!
Why can't education be this clear, concise, and approachable. Another wonderful tutorial.
Thanks
I fell asleep twice, but that does not make video less informative. Brilliant!
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!!!
I'm thankful that you decided to share your knowledge with us, amazing content, best of luck!
Thanks! And thanks for watching :)
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!
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.
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.
@@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.
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?
@@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 :)
@@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.
A really good explanation and impresive animations. You should make more of this type of videos. Ty
Thanks a lot for this! This information was really lacking in the "documentation" I found on the internet! Great visuals also!
Thanks :)
Thanks for the very clear explanation and recommendations. If I could have given two thumbs up, I would have!
Great video as always 👍
Thanks for sharing your experience with all of us 👍😀
Thank you!
Nice video, not tried audio on a ESP32 yet. But now it looks like i should give it ago.
Very interesting! Thanks for an in depth explanation!
super helpful video! thanks so much for these esp audio videos.
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
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^).
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!
Very nice video! Is there a way to know which dma buffer is used every time if we have 2 buffers for example?
This is sooo good. Thanks for your great examples.
Thanks for in-depth explanation.
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!
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.
thank you 💖💖💖 . i was want to understand the dma count
I think it would be neat to cover single ADC multichannel DMA sampling on the ESP32.
Very well explained 👍
Thanks!
Very informative, thanks!
Thanks - I'm glad it was helpful.
Good video, I have a question? I2S is only for audio application or it's possible other uses. Sorry for my bad English
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
@@atomic14 Thank you very much for your resply, Greetings from Peru South America
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
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?
What are the total no of dma buffers in esp32 ?? What's the maximum value we can use?
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.
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
Can you pls reply to my query?
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
Thanks a lot. Can this kind of project modify to real-time voice modulator with INMP441 and SPK.
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.
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.
@@atomic14 Many thanks for the prompt reply!
What would be the correct way of converting the values obtained from micro controller into -db values?
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?
I went over this again and yes a sample would include both channels.
Nice video.
What program do you use for animation?
I use a combination of manim - github.com/3b1b/manim and my own homegrown animation library (which is definitely not ready for public consumption).
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
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
nice video
Огромное спасибо за Ваши видео! Отдельная благодарность за качественные субтитры. Субтитры идеально переводятся на русский язык.
Переводчик Google потрясающий.
Hi i got some questions regarding bluetooth audio using esp32, where can i get into contact with you? Thanks!
I can be contacted via the channel page. I don't know much about Bluetooth audio yet though!
@@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.
@@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!
@@aarriikknn33ll On the About tab there's a button to view my email address.
@@atomic14 Ohhh okey thanks, i did not know what you meant exactly.
HELLO, IS IT HOW TO GET AUDIO FROM ADC PROCESS AND PLAY IN DAC? FOR EXAMPLE A GUITAR CHORUS?
Have a look at the videos in this playlist: ua-cam.com/play/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD.html
Great !!!!
Thanks
How do you create your animations please?
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...
Genial