Thanks for the reply. Her are our set up and code.
We connect the 4 ICS52000 microphone array from
https://www.notwired.co/products/detail/nwaudics52000-notwired-co/605574/
with the Teensy 4.1 as shown in the following figure
Specifically, we connect
--------------------------------------------------------------------
Microphone array pin <-------> Teensy 4.1 Pin
1,3,5,7,9 <-------> GND
2 <-------> 3.3V
6 <--------> 8
8 <--------> 21
10 <-------> 20
-----------------------------------------------------------------------
according to the audio design tool suggestion
and the microphone array data sheet
------------------------------------------------------------------------
Here is the code, which basically record 10 second of data from
one microphone and then save the data to the SD card.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#define SDCARD_CS_PIN BUILTIN_SDCARD
/////////////////////////////////////////////////////////////////////////////////
int a=0;
////////////////////////////////////////////////////////////////////////////////
unsigned int tsamplemillis = 10000;
int16_t* buffer1;
int16_t* buffer2;
File frec;
////////////////////////////////////////////////////////////////////////////////
AudioInputTDM tdm1;
AudioRecordQueue queue1;
AudioRecordQueue queue2;
AudioConnection patchCord1(tdm1, 0, queue1, 0);
AudioConnection patchCord2(tdm1, 1, queue2, 0);
////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
AudioMemory(512);
// Initialize the SD card
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here if no SD card, but print a message
while (1) {
Serial.println("Unable to access the SD card");
delay(1000);
}
}
while (!Serial);
Serial.println("Begin");
}
void loop() {
if(a<1){
record();
continueRecording();
stopRecording();
a = 1;
}
}
void record()
{
frec = SD.open("ICS52000.raw", FILE_WRITE);
if (frec) {
Serial.println("File Open");
}
}
void continueRecording() {
int data = 0, num = 0;
elapsedMillis recordingTime = 0;
queue1.begin();------------------------------------------------------------------------
------------------------------------------------------------------------
queue2.begin();
while (recordingTime < tsamplemillis)
{
data = queue1.available();
if (data > 0)
{
buffer1 = queue1.readBuffer();
buffer2 = queue2.readBuffer();
queue1.freeBuffer();
queue2.freeBuffer();
for (int i = 0; i < 128; i ++)
{
frec.write(highByte(buffer2[i])); // LSB
frec.write(lowByte(buffer1[i])); // Middle Byte
frec.write(highByte(buffer1[i])); // MSB
num++;
}
}
}
queue1.end(); //stop the background sampling
queue2.end();
Serial.print("num of samples written per channel:");
Serial.println(num);
}
void stopRecording() {
Serial.println("Finished recording.");
queue1.end();
queue2.end();
queue1.clear();
queue2.clear();
frec.close();
Serial.println("File close");
}
--------------------------------------------------------------------------------------------------------------------
I use a loudspeaker to play a 440 Hz sine signal close to the microphone array, I expect to witness the sine
waveform from the data.
But after I imported the data "ICS52000.raw" to the Audacity as raw data, 24 bit signed pcm, little endian ,one channel,
with sampling frequency of 44100 hz.
Here is that showed by Audacity
I can not see a sine waveform if even I zoom in to the data.