I was inspired to create a SONAR system after working for
the Alaska Synthetic
Aperture RADAR Facility, since the microwave RADAR
digital signal processing tricks I learned on the job
work equally well for sound.
My SONAR system consists of a Radio Shack piezo speaker (black cylinder), my Mac's standard microphone (grey oval), a cardboard frame, and software of my own design. The basic idea is to play a short sound out the speaker, then listen as the sound echos off objects in the room-- since sound travels fairly slowly, far objects' echos arrive after those of nearby objects.
Since my Mac samples at 44.1 kHz, sound can only travel about 1/4 inch between samples, so the system should be capable of resolving distances down to 1/8 inch. It's not quite that good yet, but the distance resolution is very good.
The traces below are screen shots from my program-- distance runs left-to- right, then wraps around to the next line. The color represents the amount of echo received at that distance. Because of built-in delays in the Mac's sound hardware, the echos start somewhere on the third line. The setup is as above-- the sonar system is sending sound at a small cardboard target held by my tripod.
The initial burst of color
is the microphone hearing the sound directly. The smaller second
burst is the echo from the cardboard target. The other colors are
other objects in my room (couch, walls, me, ...) or noise.
This display animates at 10 frames per second (i.e., in real time),
but I've only shown 3 snapshots here. One pixel corresponds to about
1/8 inch of distance, so an entire line is about 5 feet.
I use an 18 kHz-bandwidth, linear FM, 1/20 second chirp, starting at 4 kHz. The echos are sampled at 44.1 kHz, 16-bit monophonic. I then correlate against the original chirp (using the FFT) to extract a compressed image. For more technical details, read the source code.