Go Down

Topic: Sound Localization (Read 6503 times) previous topic - next topic

Magician

Oct 06, 2012, 02:33 am Last Edit: Sep 07, 2014, 05:51 am by Magician Reason: 1
Arduino Leonardo, two servos,  LM317, 9 resistors, a few capacitors and prototyping board.
Just can't be less...

cyberteque

That is really cool!

circuit?

code?

Details please!!!

cyberteque

Yep!
I found it after I posted!

Great blog man!

codlink

"The video has been blocked in your country on copyright grounds."

How I love the US

Please do not quote this post as it is mine and no one else can use it without paying me 100 million dollars.
//LiNK

codlink

Nice setup.  And thanks for throwing up another vid!  Will be following your progress as I am looking for ways to localize sound with my project, but not quite at the stage for implementing it.
//LiNK

iroth

Very cool! thanks for sharing, and a nice blog!  :)

#6
Jan 24, 2013, 11:58 am Last Edit: Jan 24, 2013, 01:30 pm by johnfraiser Reason: 1
Really nice and extremely interesting project.

I am hoping to learn a great deal by studying your code. However I have a few questions that hopefully you won't mind answering.

Why do you constrain the values for the Y servo to 1500, 2100 and the X to 800, 1900?
So could i use the following to convert it to degrees?
Code: [Select]
rot = map(srvoPosn[y], 1500, 2100, 0, 180);

Also with regards to these lines,

Code: [Select]

if(faza[ind][i + MIRROR/2]) Serial.print(faza[ind][i + MIRROR/2]);
        else     Serial.print("n");


if the debug just prints "n" does it mean it is not correctly receiving audio?

Sorry for the very basic questions im just trying to understand the reasons behind what your doing and hopefully get a greater knowledge of FFT

Thank you
John

Magician

Quote
Why do you constrain the values for the Y servo to 1500, 2100 and the X to 800, 1900?
To keep wiring safe, power cable to board coming up from accumulators. It also good idea to put separate switch for servo motors, to prevent accidents during start up., or use a "delay switch"
Quote
So could i use the following to convert it to degrees?
Code:
rot = map(srvoPosn[y], 1500, 2100, 0, 180);
. Yes, srvoPosn will hold integrated value of the angle, if you keep same hardware set-up - motors moving with platform. Angle would depends on base positioning.  May be not very accurate, depends on servo specification non-linearity etc.
Quote
if the debug just prints "n" does it mean it is not correctly receiving audio?

Mark "n" easy distinguish in digits column, compare to "0" , if "n" printed - there is no data.

#8
Jan 24, 2013, 05:04 pm Last Edit: Jan 24, 2013, 05:08 pm by johnfraiser Reason: 1
Ok thats good I thought the mapping would work however was not sure. The setup I am using is slightly different to your in that I am not actually using any servos. I just wish to create a visualisation of the angle from the stationary base. Would this cause any issues with the data I am getting?

I shall have to try and understand then why I am not receiving any data as I seem to be receiving "n" .


Magician

Quote
I am not actually using any servos.
No, it 'd not work, motors is part of "negative feedback" loop.
You should calculate angle via arcsine(summa). I've mention this in section 3 of the blog,
"Absolute direction to sound source, and must include stage #5 - angle calculation via known delay time. Math is pretty simple, acrsine function, and at this point in program only one calculation per several frames would be necessary, so floating point math wouldn't be an issue at all. No LUT, scaling, rounding/truncation. Elementary school geometry knowledge - thats all you need."

So i am about to incredibly over simplify this process by the way i describe it however tell me if I am on the right lines.

If i take the time difference before you apply the negative feedback loop, or are they one in the same in terms of calculations?
Then use the function you described in your last post, arcsine function I can determine the angle in which the sound has come from?

Magician

There are 2 lines :
Code: [Select]
           if (count)    summa /= count;
           srvoPosn[y] -= summa; 

If you are not going to use servo, than you  need to change type of srvoPosn[] to "float", and remove code  "if / else" statement that follows. Than
Code: [Select]
  srvoPosn[y] = asin ( koeff * summa / 2048.0) * 180.0 / PI;
I'm not ready to give a coefficient "koeff" ,  sure it's would be proportional to distance between mic's - base, you have to find out from practice.   asin defined in -1 : +1.
http://www.cplusplus.com/reference/cmath/asin/

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

Code: [Select]

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

Magician

No, chunk of code is filtering multipath propagation / reverberation

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: [Select]

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

Go Up