Acoustic Localization


New member
Hi all,

I am starting a project with a Teensy 3.1. I want to use acoustic signals to provide the approximate position to a vehicle, i.e. the opposite of sound localization. I have a Teensy 3.1, analog microphone with amplifier board, and a Teensy audio adapter board coming within the next few days.

The algorithm is currently as such:
1. Initialize
2. Sample at 44.1 kHz for 0.2 seconds (lets say every 10 seconds)
3. Perform cross correlation of known signal and recorded signal
4. Find peak of absolute value of cross correlation
5. Repeat 2-5

Right now I am having trouble with 2. I have been unable to get a fixed sampling rate using the ADC library (by pedvide). I think the audio adapter board may help with this.

Any suggestions and advice is much appreciated

Try the File > Examples > Audio > Recorder example.

It writes the audio to SD card. You can probably edit the code to just put the data into a big array, instead of writing to SD.
Thank you for the suggestions.

Onehorse: That would be a better choice that the analog mic I have now. But it would not arrive in time to Germany.

Paul: The example has an I2S input, which as I understand samples at 44.1 kHz from a timer. I have been unsuccessful in controlling the Analog sampling rates, do you have a suggestion for that? I may sample faster and write a simple linear interpolation if I cannot.
Trying to do sound localization, I have teensy 4.0 and 4.1 what mic should I use? I would also like nano second time stamps and software to solve for latitude and longitude of sound source in this case poachers shooting at 2 am. I plan to have 4 or 5 mics.
There is no need for nanosecond resolution. The PPS from a GPS receiver will provide 10usec resolution for annabsolute time stamp. This is enough to triangulate the sound source with multiple mics. Any wheater proof mic with a wind ‘hat’ will do. But you will need a mic preamp and ADC and teensy for each mic. Best to cut everything below 500 Hz. Space out the mic as far as possible… 10s of meters to improve triangulation accuracy.

Then you need to somehow gather the data from all mics and do the actual triangulation. GSM chips for data coms can do this.

As you can see , this can become a elaborate project.