audio feedthrough on esc32-c3?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
freudent
 
Posts: 3
Joined: Fri Jul 01, 2022 6:04 pm

audio feedthrough on esc32-c3?

Post by freudent »

I need to construct an embedded device that
* performs a low-complexity transform on sound received on a mic
* output it to a loudspeaker
* with low (ideally 5ms or less) latency.
I've already protoytped the transform in python. I suspect that timing constraints will require me to port it to C/C++.

An I2S mic would be suitable for my needs, and I am happy to use the device's A2D or an i2s amplifier.

I understand electronics & digital interfacing, but haven't previously messed with this controller or i2s.

Since it has two i2s ports, an esc32-c3 seems suitable. Am I right?

I can't be the first to need audio feedthrough with this device. I'm hoping that someone can point me to a suitable configuration and sample program (or at least a library) that reads an i2c mic and simply feeds it out with suitable latency so that I can insert the filter.

Thanks, Eric

User avatar
freudent
 
Posts: 3
Joined: Fri Jul 01, 2022 6:04 pm

Re: audio feedthrough on esc32-c3?

Post by freudent »

btw: the on-chip 12 bit a2d and d2a are probably fine for my application, which only requires 2kHz sampling rate.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: audio feedthrough on esc32-c3?

Post by adafruit_support_mike »

You don't need two I2C buses. The protocol has two channels by default.

I2S uses time-domain multiplexing (TDM): the first N bits it reads or writes are assigned to the left channel, and the next N bits are assigned to the right channel. A more advanced variation makes it possible to use multiple 'frames', each with its own left and right channels, but the baseline version just flips between its left and right channels.

That means you can use an I2S mic and I2S speaker on any board that has an I2S bus.

The ESP32-C3 will work, but so will most of our other 32-bit microcontrollers. The SAMD21 in our M0 boards supports I2S, and so does the SAMD51 in our M4 boards.

Since you're doing signal processing, the latency from input to output will depend on the complexity of your algorithm and the size of your working buffer.

User avatar
freudent
 
Posts: 3
Joined: Fri Jul 01, 2022 6:04 pm

Re: audio feedthrough on esc32-c3?

Post by freudent »

Hi Mike,

Thanks so much for your reply. I initially thought of that configuration but found i2s controllers that could only be configured for input or output on both phases, but not one for input and the other for output.

I wrongly assumed that limitation was common. Might you be able to put me to demo code that sets up the i2s appropriately and transfers data? Also, are there libs that provide io pipelines or facilitate setting up interrupt handlers for the i2s io events?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: audio feedthrough on esc32-c3?

Post by adafruit_support_mike »

There are a couple of ways to approach the job. One is to use a single I2S_DATA pin and create two I2S 'handle' objects, one configured with I2S_STD_SLOT_ONLY_LEFT and the other configured with I2S_STD_SLOT_ONLY_RIGHT.

The other is to assign separate pins for reading and writing, which is easier if you can afford the extra pin. That's the method used in the Full_Duplex example in the ESP32 I2S library:

https://github.com/espressif/arduino-es ... Duplex.ino

Our own Adafruit_ZeroI2S library has similar options, but handles the single-line option differently. The .read() and .write() functions take two 32-bit integer arguments, one for data on the left channel, and one for data on the right channel. It also lets you use separate IN and OUT pins though.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”