i will like some help on this.to do a sum of square of individually on each mic.Measure the sum of the squares of the most recent 50 or so samples, once that is over a certain threshold on either input start logging.this is what i have done.but there are some mistake i think.thank you.
Code:
#define SAMPLE 1024
int main()
{
for(int i=0;i<SAMPLE;i++)
{
t.start();
while(t.read_ms()<SAMPLE_PERIOD)// wait until the next sample time....
{
left_results[i]=leftmic.read();
right_results[i] = rightmic.read();
}
t.reset();
for(int a=0;a<50;a++)
{
sumleft[a]+=left_results[i]*left_results[i];
sumright[a]+=right_results[i]*right_results[i];
pc.printf("%.3f , %.3f\n\r", sumleft[a],sumright[a]);
if(a==50)
{
if(sumleft[a]>2||sumright[a]>2)
{
a=0;
correlate(left_results,right_results);
angle(peakoffset);
}
}
}
}
}