ZodiusInfuser
Member
Hi,
I am doing a project at work involving I2S microphone capture and analysis with the Teensy 3.5. I have been having success with two microphones, the SPH0645LM4H (https://www.adafruit.com/product/3421), but now want to expand that to four. Unfortunately when I switch my code from AudioInputI2S to AudioInputI2SQuad, the output I get from all four AudioRecordQueue buffers is 0 on the "right" channels, and -32768 on the "left" channels. I have confirmed that all four microphones work in stereo mode, so am at a loss as to what the problem is.
As I am not using Audio Shields, so unable to verify with the PassThroughQuad sketch, here is an example with record queues to usb serial that illustrates the problem:
Stereo serial monitor output
(mics seem to have a DC offset but are capturing correctly)
Quad serial monitor output
(no mics capture correctly)
I am using Arduino 1.8.10 with Teensyduino 1.48, on Windows 10. Also attached pictures of my circuit in case I'm doing anything silly there.
Any help with this issue would be greatly appreciated!
I am doing a project at work involving I2S microphone capture and analysis with the Teensy 3.5. I have been having success with two microphones, the SPH0645LM4H (https://www.adafruit.com/product/3421), but now want to expand that to four. Unfortunately when I switch my code from AudioInputI2S to AudioInputI2SQuad, the output I get from all four AudioRecordQueue buffers is 0 on the "right" channels, and -32768 on the "left" channels. I have confirmed that all four microphones work in stereo mode, so am at a loss as to what the problem is.
As I am not using Audio Shields, so unable to verify with the PassThroughQuad sketch, here is an example with record queues to usb serial that illustrates the problem:
Code:
#include <Audio.h>
#define USE_QUAD
#ifdef USE_QUAD
AudioInputI2SQuad i2s1; //This doesn't work
#else
AudioInputI2S i2s1; //This works
#endif
AudioRecordQueue queue1;
AudioRecordQueue queue2;
AudioConnection patchCord1(i2s1, 0, queue1, 0);
AudioConnection patchCord2(i2s1, 1, queue2, 0);
#ifdef USE_QUAD
AudioRecordQueue queue3;
AudioRecordQueue queue4;
AudioConnection patchCord3(i2s1, 2, queue3, 0);
AudioConnection patchCord4(i2s1, 3, queue4, 0);
#endif
void setup()
{
AudioMemory(120);
Serial.begin(115200);
delay(2000);
queue1.begin();
queue2.begin();
#ifdef USE_QUAD
queue3.begin();
queue4.begin();
#endif
}
void loop()
{
#ifdef USE_QUAD
if(queue1.available() >= 1 && queue2.available() >= 1 && queue3.available() >= 1 && queue4.available() >= 1)
#else
if(queue1.available() >= 1 && queue2.available() >= 1)
#endif
{
byte bufferA[256];
byte bufferB[256];
memcpy(bufferA, queue1.readBuffer(), 256);
memcpy(bufferB, queue2.readBuffer(), 256);
queue1.freeBuffer();
queue2.freeBuffer();
#ifdef USE_QUAD
byte bufferC[256];
byte bufferD[256];
memcpy(bufferC, queue3.readBuffer(), 256);
memcpy(bufferD, queue4.readBuffer(), 256);
queue3.freeBuffer();
queue4.freeBuffer();
#endif
for(int i = 0; i < 256; i+= 2)
{
int32_t aVal = (int16_t)bufferA[i] + (int16_t)(((int32_t)bufferA[i + 1]) << 8);
int32_t bVal = (int16_t)bufferB[i] + (int16_t)(((int32_t)bufferB[i + 1]) << 8);
Serial.print(aVal);
Serial.print(",");
Serial.print(bVal);
Serial.print(",");
#ifdef USE_QUAD
int32_t cVal = (int16_t)bufferC[i] + (int16_t)(((int32_t)bufferC[i + 1]) << 8);
int32_t dVal = (int16_t)bufferD[i] + (int16_t)(((int32_t)bufferD[i + 1]) << 8);
Serial.print(cVal);
Serial.print(",");
Serial.print(dVal);
#endif
Serial.println(",4095,-4095"); //Added to force Arduino plotter to keep a fixed scale
}
}
}
Stereo serial monitor output
(mics seem to have a DC offset but are capturing correctly)
Quad serial monitor output
(no mics capture correctly)
I am using Arduino 1.8.10 with Teensyduino 1.48, on Windows 10. Also attached pictures of my circuit in case I'm doing anything silly there.
Any help with this issue would be greatly appreciated!