Pages: 1 [2]   Go Down
Author Topic: Sound Localization  (Read 3779 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So as well as the code for determine the position of the servos that you mentioned should i also remove this

Code:
for ( uint8_t i = 2; i < MIRROR; i++)  // LIMITS: 150 HZ
        {                                      // Electrical grid interference, Motor Vibration.
          vremn = 0;                                       
          if ((x_r[0][i] != -1) && (x_r[1][i] != -1))
          {
            vremn = x_r[0][i] - x_r[1][i];           
            if (vremn >  1024) vremn -= 2048;
            if (vremn < -1024) vremn += 2048;
           
            vremn = (32 * vremn) / i;                                   
            vremn -= 256;                      // MIC Time Offset Correction (1 ADC, 25 usec delay).

          if (lokaVect[directin][i] < vremn) lokaVect[directin][i] += srvoAccl[directin];
          if (lokaVect[directin][i] > vremn) lokaVect[directin][i] -= srvoAccl[directin];
          }
        }

Or just a section of this, as it is filtering the motor sound right?

Thank you
John
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, chunk of code is filtering multipath propagation / reverberation
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the code i am currently employing however i am fairly sure my coefficient is completely wrong. I understand it should have a relation to the distance of the microphones but not sure how to calculate or determine what this should be. Do I need to workout what the average time it would take for the sound to travel the distance between them and use that as the coefficient?

I have tried a few completely random values for this but as im sure you can guess had no positive results.

Code:
float coefficient = 400;
float soundAngleY = srvoPosn[y];
soundAngleY = asin (coefficient * summa / 2048.0) * 180.0 / PI;
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Key is the arcsin function definition [-1; +1].  Print out "summa" via serial and see what you get. Than you adjust coeff. so total parameter passing to arcsin would be -1 < p < 1.
 Sound wave coming "flat" to both mics, should produce summa=0, shifting left-right 'd change sign and magnitude.
Logged

Pages: 1 [2]   Go Up
Jump to: