Hi people,
I am working on my first project with sound localisation feature (with azimuth and distance calculation) and stuck on peak detection of the I2S2 part of T4 while I2S1 working great (all mics are INMP441).
When I connected all 4 mics and declare both I2S1 and I2S2 I am receiving no one mic are working with next plotting
As soon as I am removing(commenting) declaring of one of I2S1 or I2S2 audio input I am receiving perfectly working but only for 2 mics, that connected to I2S1 (but no matter which one I am turning off!)
What I am doing wrong?
I am working on my first project with sound localisation feature (with azimuth and distance calculation) and stuck on peak detection of the I2S2 part of T4 while I2S1 working great (all mics are INMP441).
When I connected all 4 mics and declare both I2S1 and I2S2 I am receiving no one mic are working with next plotting
As soon as I am removing(commenting) declaring of one of I2S1 or I2S2 audio input I am receiving perfectly working but only for 2 mics, that connected to I2S1 (but no matter which one I am turning off!)
What I am doing wrong?
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
/*
SD -> pin 8 (in1)/pin 5 (in2)
L/R -> GND/VCC (left/right channel)
WS -> pin 20 (LRCLK1)/pin 3 (LRCLK2)
SCK -> pin21 (BCLK1)/pin 4 (BCLK2)
*/
AudioInputI2S i2s1;
AudioInputI2S i2s2;
AudioAnalyzePeak peak_L1;
AudioAnalyzePeak peak_R1;
AudioAnalyzePeak peak_L2;
AudioAnalyzePeak peak_R2;
AudioConnection patchCord1(i2s1, 0, peak_L1, 0); //connect the Left mic to the Left peak detector
AudioConnection patchCord2(i2s1, 1, peak_R1, 0); //connect the Right mic to the Right peak detector
AudioConnection patchCord3(i2s2, 0, peak_L2, 0);//connect the Left mic to the Left peak detector
AudioConnection patchCord4(i2s2, 1, peak_R2, 0);//connect the Right mic to the Right peak detector
void setup() {
Serial.begin(9600);
AudioMemory(70);
}
elapsedMillis fps;
void loop() {
if (fps > 5) {
fps = 0;
float LeftPeak1 = peak_L1.read();//Return is from 0.0 to 1.0.
float RightPeak1 = peak_R1.read();//Return is from 0.0 to 1.0.
float LeftPeak2 = peak_L2.read();//Return is from 0.0 to 1.0.
float RightPeak2 = peak_R2.read();//Return is from 0.0 to 1.0.
Serial.print("L1: "); Serial.print(LeftPeak1 * 3000.0); Serial.print(" ");
Serial.print("R1: "); Serial.print(-RightPeak1 * 3000.0); Serial.print(" ");
Serial.print("L2: "); Serial.print(LeftPeak2 * 3000.0); Serial.print(" ");
Serial.print("R2: "); Serial.print(-RightPeak2 * 3000.0); Serial.print(" ");
Serial.println("");
}
}