Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
How to connect 4 microphones and hear the voice at the same time?
-
I am trying to monitor the human heartbeat by using a microphone array. But there got some problems. Channels A and B work fine but channels C and D do not work. I don't know why this is happening. I am using the "through" example of the Arduino IDE.
-
Hi @XY
How are you connecting the microphones?
Please share your code so we can take a look at it. -
@CamilaSouza
Hi
this is my code#include <Audio.h> AudioClass *theAudio; /** * @brief Audio attention callback * * When audio internal error occurc, this function will be called back. */ static void audio_attention_cb(const ErrorAttentionParam *atprm) { puts("Attention!"); if (atprm->error_code >= AS_ATTENTION_CODE_WARNING) { exit(1); } } /** * @brief Setup audio through to I2s input to speaker * * Set output device to speaker <br> * Set input mic gain to 16.0 dB */ void setup() { /* start audio system */ theAudio = AudioClass::getInstance(); theAudio->begin(audio_attention_cb); puts("initialization Audio Library"); /* Set input source with first argument. * The second argument means source of I2s output. * If you set "I2sIn" as the first argument, please set "None" as the second argument. * Set speaker driver mode to LineOut with last argument. * If you want to change the speaker driver mode to other, * specify "AS_SP_DRV_MODE_1DRIVER" or "AS_SP_DRV_MODE_2DRIVER" * or "AS_SP_DRV_MODE_4DRIVER" as an argument. * */ int err = theAudio->setThroughMode(AudioClass::MicIn, AudioClass::None, true, 160, AS_SP_DRV_MODE_LINEOUT); if (err != AUDIOLIB_ECODE_OK) { printf("Through initialize error\n"); exit(1); } theAudio->setVolume(-160); if (err != AUDIOLIB_ECODE_OK) { printf("Set Volume error\n"); exit(1); } }
-
@CamilaSouza
Regarding the connection of the microphones, I used four analogue microphones, connected to the JP10 according to the connection on the official website. Since all four mics work on channels A and B, I think there is no problem with the connection method. -
Hey @XY
After some investigation:
Through sends the sound from microphone directly to speaker. And speaker has just 2 channels: Left and Right.
So the behavior you are experiencing is the normal one. Ch A sends to left channel and Ch B sends it to right channel.If you want to listen to the 4 channels there are two ways.
One is to save it in wav file. WAV format can support 4 channels in one file.
The other is software mixer. 4 channels data is coming as Ch1, Ch2, Ch3, Ch4, Ch1, Ch2, Ch3, Ch4..... So you can make a kind of audio mixer to mix Ch1 and Ch2, Ch3 and Ch4, and then, output to speaker as Left Right channel.