Sound Localization

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

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?

rot = map(srvoPosn[y], 1500, 2100, 0, 180);

Also with regards to these lines,

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

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"

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.

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.

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" .

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?

There are 2 lines :

           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

  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

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

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.

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

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.

@johnfraiser

Please, can you post the whole code, because it's not available anymore on the original website (all Download-Links are dead). And the author is not answering requests via email or forum account.

Thanks in advanced.

bump

Yeah, I was sort of interested but NONE of the links work. No videos, no BLOG. The blog link works, but then says it can't find the requested URL - or something.

Why do people post things with music when they are prone to blocking or even complete removal by youtube?

WAS interested, but for the trouble it is causing, I shall wait and see what happens.

Yes, the Author fixed the links to the website, but not for the downloads. The Author is still active here in the forum, but is not answering forum messages, website comments or emails.

So, the only hope is that maybe another user has that download stuff and can upload it in this forum.

Hi,

I attached a sketch to first post. If there are bugs, please, report back.

Currently working on DUE version, same concept but w/o servo, visualization on android tablet, like in the last blog post

  • ultrasonic 3D radar.

Not sure, if you can watch video posted over youtube for this last project - ultrasonic radar, counters show dead activity in the last 2 weeks, probably Z-government of the world block the channel.
Keep visiting.

Published, DUE version of the sound localization project. As there is visual display, I called it Sound Camera.
http://coolarduino.wordpress.com/2014/09/12/sound-camera/

Thanks. DUE version would be also good.

Hi There,

I was wondering if you have a video demonstrating your product. I have no technical experience but i'm looking for a component like this for one my product ideas so i hope you are willing to share this video.