I am working on a final project called sound source localization using Arduino Uno. I want to use two sound sensor to capture a sound. The nature of the sound is clap or speech sound. I want to use the cross correlation method to estimate the time delay between the microphones then find the position and angle. My supervisor said to me you have to store the values on analogRead in two arrays then cross correlation the element of two arrays. But i am struggle the cross correlation part. I will appreciate any help from you guys.
#define LED_NORTH 2
#define LED_SOUTH 4
#define MIC_NORTH A0
#define MIC_SOUTH A2
/* let's said we want to read 100 samples */
const unsigned int numReadings = 100;
unsigned int analogVals[numReadings];
unsigned int i = 0;
void setup() {
Serial.begin(115200);
pinMode(LED_NORTH, OUTPUT);
digitalWrite(LED_NORTH, LOW);
pinMode(LED_SOUTH, OUTPUT);
digitalWrite(LED_SOUTH, LOW);
}
void loop() {
int north = analogRead(MIC_NORTH);
Serial.printprintln(north);
int south = analogRead(MIC_SOUTH);
Serial.printprintln(south);
/* take numReadings # of readings and store into array */
for(unsigned int i = 0; i < numReadings; i++)
{
analogVals[i] = analogRead(A0);
delay(1000);
}