Go Down

Topic: Need a Sound Localization sensor, or help me build one. (Read 11715 times) previous topic - next topic

fileark

I am interested in building a sound localization sensor, I can't find any on the market and I have found scarce information on anyone ever doing such with an Arduino. I did find one with a PIC, I will leave the link here.
http://www.elektor.com/magazines/2007/july-august/stereo-robot-ears.197459.lynkx

Sound localization is the process by which the human ear can detect and determine the origination of a sound based on volume difference, phase shift, ect. And more between the two ears.
http://en.wikipedia.org/wiki/Sound_localization

I have a bunch of electret condenser microphones, LM324 op amps to amplify the audio, in fact I have my mic amp circuit built I just need to sit down and debug and test.

One of my main areas of confusion is the formulas used to calculate phase shift. Sound may take about 500us to travel the distance from one ear to the other so I am worried that the arduino may not have the horse power and speed to do the necessary time delay calculations ect. I need to be able to perform a calculation in probably 50-100us to get say 25deg resolution (just a wild guess).

In closing, what I am really hoping for is a code sample of someone that has already traveled down this path to save me days or weeks of hacking it out on my own.

Any helpful comments and information is greatly appreciated. Thanks!

scjurgen


I am interested in building a sound localization sensor, I can't find any on the market and I have found scarce information on anyone ever doing such with an Arduino. I did find one with a PIC, I will leave the link here.
http://www.elektor.com/magazines/2007/july-august/stereo-robot-ears.197459.lynkx

Sound localization is the process by which the human ear can detect and determine the origination of a sound based on volume difference, phase shift, etc/


Quite a project, and not as easy as it sounds (lol, is about sound, no?).

So, some info to clean up (I worked on such stuff).

The exact origination of a sound using 2 mics is quite an undertaking, you need an artificial head (humans use head and ears as a directional filter) and DSP horse powers and it will be still not very correct if you use the human hearing as a model.

Phase shift will give you an estimation of the direction (it's actually a plane of directions, you get the same phase shift if i.e. the sound is above you, humans distinct this better because of filtering by head shape and ear) and what you need to work on is cross correlation (and it's related difficulties if you got for example sine waves at high frequencies a cross correlation of a continues signal has many correlations, that's why we can't locate very well a high pitched sirene sound). Cross correlation functions are simple math, but heavy duty, very useful in a noisy ambient. You can optimize a lot if you have sounds like clicks and a low noise environment, which will give you simple algorithms to detect when a relevant sound arrives and the estimation of the phase shift (actually a TDOA) . 

A very simple correlation function of two buffers is to create the absolute difference of the 2 buffers for a small windowsize and shifting the window for one of the 2 channels and finding the best match. Using upsampling you can get quite precise values even in noise but I guess too much work for an arduino (I use actually an ARM cortex 3 processor to do such advanced stuff).

Now, the biggest problem is the Arduino, quite a low sampling rate, not much power doing even simple floating point math. For the sample rate you could use external ADC converters (I use i.e. AD7811, and you need 2 of them to sync the sampling without relying on a MUX, possibly there are other ADC but I have them here). To make them sample at the same time you will give them a CONVST signal at the same moment and read the values one by one. Keep in mind that sound is FAST. Best results if you have high sampling rates i.e. (like 96Khz) using mics that are sensitive to high frequencies too.

That ought enough for now and I tried to explain in easy words. The science behind all this is very complex.
Good start for reading cool stuff about all this is Jens Blauert, Psychophysics of Human Sound Localization (Chapter 2 to get ideas about the math).

HTH


fileark

Scjurgen,  thanks for helping me understand a little more. I am looking into acquiring that book you mentioned. Previously I was incredulous that there was not a commercially available sound localization sensor ready to plug into the Arduino like the ping ultrasonic and all the other cool sensors out there. As I learn more about it I am starting to understand the rather large amount of complexity and the rather high hardware requirements in order to pull it off. That said, it is a noble challenge, and I wouldn't be here if I didn't enjoy learning and challenges.

Thanks for the info, I am going to look into hardware speeds and specs and check out other hardware packages like the one you mentioned.

scjurgen


I think to get a better feeling and hands-on-experience about these things it is in any case useful to do sampling with 2 mics but connecting them to a PC sound card, you will be much faster in creating a prototype using some serious debugger and stuff. BTW, a third mic on top of the other 2 and you get a nice additional value that could lead to height ;) .

You could also using the Arduino, sample the audio signals and send the data via serial to the pc and do there some analysis of the data you got, but this should be a second step. And well, the last step is transferring all that experience to an embedded system.

about the book: it is cool, but quite specific


robtillaart

A part of chapter 2 can be "looked inside" @ amazon: - http://www.amazon.com/Spatial-Hearing-Revised-Psychophysics-Localization/dp/0262024136
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

fileark

After some work here is my first stab at sound localization. I built it with some LM324Ns for OpAmps and comparators. It works only by volume comparison so it has a lot to be desired however it does work surprisingly well at very close range.

http://filear.com/index.php/arduino/90-diy-sound-localization-sensor

Phase two is to try doing phase shift comparison with an Arm Cortex M3. I'll let you know if I make any headway.

robtillaart


check the forum discussion of a few months ago - http://arduino.cc/forum/index.php/topic,52583.0.html
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sventar

Any progress? Please notify me since i am doing a project related.

Magician

http://forum.arduino.cc/index.php?topic=125860.0

Go Up