Page 1 of 3

Four plus channels of audio recording with I2S

Posted: Sun Dec 08, 2019 7:14 pm
by cblondon
Hi all,

I've been working with a pair of INMP441 MEMS microphones, and the ESP32 has no problem capturing audio from them, and subsequently writing that to an SD card. My current program uses a single I2S channel to capture the data from the two mics, sampling at 44.1 kHz, 16 bits per sample.

My question is whether it is possible to capture more channels of audio than just two, and if so how I might go about doing that. I do understand that there is a second I2S channel on the ESP32, but that it cannot be operated for audio capture while the other channel is being used. If that's incorrect please advise!

Best,

CB

Re: Four plus channels of audio recording with I2S

Posted: Mon Dec 09, 2019 2:16 am
by ESP_Sprite
As far as I know, there's no reason you can't use it, but there's only one audio PLL, so you likely can't use it to record a stream on a random sample rate. Not sure how the driver implements it, but I'd guess you should be fine if you use a sample rate derived from the main PLL, or the same sample rate as the other I2S channel.

Re: Four plus channels of audio recording with I2S

Posted: Mon Dec 09, 2019 11:39 am
by cblondon
ESP_Sprite wrote:
Mon Dec 09, 2019 2:16 am
As far as I know, there's no reason you can't use it, but there's only one audio PLL, so you likely can't use it to record a stream on a random sample rate. Not sure how the driver implements it, but I'd guess you should be fine if you use a sample rate derived from the main PLL, or the same sample rate as the other I2S channel.

Thanks for your response. The reason I thought that it could not be done that way is from reading this doc:

https://docs.espressif.com/projects/esp ... s/i2s.html

...which states that for the Function: esp_err_ti2s_set_pin(i2s_port_ti2s_num, consti2s_pin_config_t*pin)
The I2S peripheral output signals can be connected to multiple GPIO pads. However, the I2S peripheral input signal can only be connected to one GPIO pad.

From this, it would seem that it is not possible to read from both I2S peripherals simultaneously.

Am I reading that incorrectly?

Re: Four plus channels of audio recording with I2S

Posted: Tue Dec 10, 2019 3:31 am
by ESP_Sprite
'the' is a bit misleading here (probably something to do with Chinese not having articles) but it is per I2S peripheral. If you have two I2S peripherals, you can assign an unique GPIO to either, totalling 2 I2S inputs. The idea behind the line is that you can use the GPIO matrix to route an I2S output to go to a bunch of pins in parallel, but you cannot do the same with input pins.

Re: Four plus channels of audio recording with I2S

Posted: Tue Dec 10, 2019 9:18 am
by cblondon
Thanks for that very helpful clarification. I'll give it a try!

Re: Four plus channels of audio recording with I2S

Posted: Mon Jan 13, 2020 11:41 am
by temponit
Sorry, I don’t quite understand what the program code will look like allowing you to simultaneously record more than 2 ADC channels while using 2 I2S.
I mean in the i2s_adc_dac example one ADC channel is recorded using one I2S.. Is there any ability to simultaneously ascque 3-4 adc channels with high (20-50K) sps per channel ?

Re: Four plus channels of audio recording with I2S

Posted: Tue Jan 14, 2020 3:07 am
by temponit
Some search gives that esp32_technical_reference_manual says:
Multiple-channel scanning mode; there is a pattern table that defines the measurement rule for each SAR
ADC. The scanning mode can be configured as a single mode, double mode, or alternate mode.


But API for pattern table has a lot of issues and not documented in IDF... The question is when is it planned to add pattern table functionality to the IDF API and docs?

Re: Four plus channels of audio recording with I2S

Posted: Wed Jan 06, 2021 11:38 pm
by anttok
@cblondon Could you summarize where you landed on this subject?

I just want to clarify that it is possible to have two microphones share the same 3 i2c pins and one i2c interface on the esp32 just by setting their jumper to L and R modes? I'm trying to build a four mic array for sound localization, and wondering how to handle that with the two i2c ports available. Any info much appreciated.

Re: Four plus channels of audio recording with I2S

Posted: Thu Jan 07, 2021 9:29 am
by cblondon
Yes, I was able to use both I2S interfaces on the ESP32, and was successful in simultaneously capturing four channels of audio. It did take some experimenting with bits to get both interfaces to work properly. I'm happy to share code if you'd like.

Re: Four plus channels of audio recording with I2S

Posted: Thu Jan 14, 2021 9:12 pm
by JoeCool
I'm happy to share code if you'd like.
Yes please share your code, I am also very interested in the solution.