Using ADC to get multiple audio streams #694
-
I am trying to make an audio mixer and trying to figure out if arduino-audio-tools and/or the ESP32 are appropriate for this function. I plan to run audio to four different ADC1 pins. The sampler will presumably have to run at 4x the normal sampling rate and do a "round robin" on which input pin I'm using. The goal is to determine whether sound is present on each input pin -- effectively creating a 4 bit number covering all the possible scenarios. A gain factor for each input pin is then looked up in a table based on that 4 bit number. Each input pin data is multiplied by its respective gain factor, summed, and then output to a MAX98357A I2S Class D auto amplifier. Audio quality needs to be decent, but high fidelity music replication is unnecessary, the sound will be beeps, and tones, and voice not music. Latency is an issue, and more than .1 seconds of latency would be undesirable. Is this practical? Possible? I didn't really see any mention of doing the round robin with the input stream |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
I see quite a few challenges here. If you want to feed a signal directly to the ESP32, you need to make sure that the input voltage is in the expected range between 0 and 3.3V - oscillating around 1.6V. Dependent on your audio source you might get quite different values and in the worst case you might see positive and negative voltages oscillating around 0V! I found that the only easy way to do audio is to use the I2S interface (e.g. from the internal ADC. But this way you can get max 2 input channels). Collecting ADC values with a timer is slow and just a pain! In addition I would expect the audio quality to be quite poor! The best results you can get with some external audio ADCs. The ESP32 has 2 I2S ports, so you can attach max 2 of these which will give max 4 input channels (2 with separate left and right). But here as well you still need to make sure that your input is a line level. One of these I2S ports you can run in duplex mode to do the output to the MAX98357A, But to be sure what you really get using the internal ADCs driven by a timer, you would need to implement a prototype. The TimerCallbackAudioStream class might help to get started and you just need to implement the callback that provides the data. |
Beta Was this translation helpful? Give feedback.
-
I am not sure if there is an Arduino library for theses chips. Did you measure effective input voltage for your case ? |
Beta Was this translation helpful? Give feedback.
-
Before doing anything with a custom hardware board, I would suggest to build a hardware prototype with some modules: e.g. https://pcbartists.com/product/es8388-module/ |
Beta Was this translation helpful? Give feedback.
-
Hi, I was excited to come across a thread where someone had faced a similar challenge, and I hope it's okay to reopen the discussion. If it’s an inconvenience, I’m happy to start a new question instead! I’m curious to know if and how you eventually solved the problem you were facing. Any insights or advice would be greatly appreciated! I'm working on a project where I need to manage and prioritize three audio channels from three different radios. The audio quality doesn't need to be high-definition, but it’s crucial that the channels are sampled and prioritized correctly. The highest-priority channel should then be output via Bluetooth. Essentially, I'm aiming to create a multiplexer. Given the complexity of managing multiple channels, my idea is to use three analog Schmitt triggers to monitor the signals and send an "Audio ON" signal to a digital pin. A digital output would then switch the three analog signals to an I2C ADC. That would be avoid the problems of to many inputs. The software would handle the switching between the signals, similar to this project: Audio Switcher Arduino. |
Beta Was this translation helpful? Give feedback.
I see quite a few challenges here.
If you want to feed a signal directly to the ESP32, you need to make sure that the input voltage is in the expected range between 0 and 3.3V - oscillating around 1.6V. Dependent on your audio source you might get quite different values and in the worst case you might see positive and negative voltages oscillating around 0V!
I found that the only easy way to do audio is to use the I2S interface (e.g. from the internal ADC. But this way you can get max 2 input channels). Collecting ADC values with a timer is slow and just a pain! In addition I would expect the audio quality to be quite poor!
The best results you can get with some external audio ADCs. The E…