Multi-Device Acoustic Source Localization: Implementation Principles
This article explains how to build a multi-device acoustic source localization system using a distributed microphone array formed by everyday devices. It covers the system architecture, band-pass filtering for narrowband transient sounds, clock synchronization as the accuracy bottleneck, pairwise time-difference estimation with cross-correlation and GCC-PHAT, hyperbolic least-squares solving, manual position calibration, and adaptive device placement. It also summarizes engineering practices around sampling, triggering, privacy, result presentation, and speed-of-sound correction, along with a real case that demonstrates the approach.
1. Background: Why You Can Hear It but Cannot Find It
After moving into a new home, I stored a large number of unopened cardboard boxes in the storage room. Every now and then, a short electronic “beep” came from somewhere among them. This kind of sound has three typical characteristics: each occurrence lasts only a very short time, the intervals between occurrences are long, and the volume is low. Human hearing relies on interaural time differences and level differences to judge direction, but with a baseline of only about a dozen centimeters, the direction estimate becomes highly unreliable for a faint source that has been reflected and absorbed by cardboard boxes. Searching by opening boxes one by one would destroy the existing stacking arrangement and is costly.
In engineering terms, this is a “narrowband transient source localization” problem, the same class of problem as microphone arrays for conference rooms, locating abnormal equipment alarms, and acoustic detection of pipeline leaks. The core idea is to expand the “two human ears” into a distributed microphone array and replace auditory intuition with algorithms.
2. Overall Architecture
The system has four layers:
- Acquisition layer: several phones, tablets, and computers open the same page in a browser and authorize microphone access, with no client installation required.
- Synchronization layer: one of the devices plays a calibration tone to establish a common time reference for all recordings.
- Computation layer: band-pass filtering, frequency feature matching, pairwise time-difference estimation, and geometric solving.
- Interaction layer: device positions are marked and dragged on a map, and the system outputs candidate regions and suggests where to add new devices.
The web page was chosen as the entry point because it is difficult to deploy native applications uniformly across devices from different brands and operating systems, while browser audio capture is already sufficient for this compute pattern of low sampling rates and short uploads.
3. Key Techniques and Implementation Details
3.1 Spectral Filtering of the Target Sound
Ambient noise is broadband and non-stationary, whereas the energy of an electronic beep is concentrated in a very narrow band. Applying the fast Fourier transform to audio frames and comparing the energy distribution when the target sound is present versus absent is enough to determine a band-pass interval. Correlation is then computed only inside that band, which significantly improves the signal-to-noise ratio.
import numpy as npdef bandpass(x, fs, lo, hi):X = np.fft.rfft(x)f = np.fft.rfftfreq(len(x), 1 / fs)X[(f < lo) | (f > hi)] = 0 # keep only the target bandreturn np.fft.irfft(X, n=len(x))def detect(signal, fs, lo=2000, hi=4000, ratio=3.0):y = bandpass(signal, fs, lo, hi)env = np.abs(y)return env.max() > ratio * np.median(env) # peak/median criterion
3.2 Clock Synchronization: The Accuracy Ceiling of the Whole Approach
The speed of sound is about 343 m/s, so a 1 ms synchronization error corresponds to roughly 34 cm of position error, while the target accuracy is on the order of 40 cm. The synchronization error therefore has to be pushed below one millisecond. In practice, a reference device plays a sound, all devices record, and the waveforms are sent back. Because the arrival time of the sound at each device has an unknown delay, absolute timestamps cannot be used directly. Instead, the arrival position of the reference tone in each recording serves as a common anchor, aligning all waveforms to the same relative time axis. If this step is done poorly, all subsequent time-difference estimation is invalid.
3.3 Pairwise Time-Difference Estimation
Cross-correlate the band-pass signals of devices i and j; the difference in the peak position gives the relative delay:
def delay(a, b, max_lag):n = len(a) + len(b)corr = np.fft.irfft(np.fft.rfft(a, n) * np.conj(np.fft.rfft(b, n)), n)corr = np.concatenate((corr[-max_lag:], corr[:max_lag + 1]))return np.argmax(corr) - max_lag # unit: samples
For better robustness, normalized cross-correlation can be applied first, together with GCC-PHAT weighting (magnitude normalization of the cross-power spectrum) to suppress spurious peaks caused by room reverberation.
3.4 From Time Differences to Coordinates
Each device pair provides one range-difference constraint, i.e. a hyperbola equation. Combining constraints from multiple pairs, the source coordinates are solved iteratively by least squares:
$
|p - si| - |p - s_j| = c \cdot \Delta t{ij}
$
where $c$ is the speed of sound, $p$ is the source position to be found, and $s_i$ is the coordinate of a device. Because the equations are nonlinear, a linearized initial value is usually computed first, followed by Gauss-Newton or gradient descent iteration. Note that when the device geometry is nearly collinear, the hyperbolas are nearly parallel and the solution diverges badly. This is a geometric dilution of precision problem and must be improved by adjusting the device layout.
3.5 Position Calibration and Adaptive Device Placement
Automatically determining the relative positions of devices is often not accurate enough, so the ability to drag icons on a map and mark positions manually is retained, trading a small amount of manual input for a large overall accuracy gain. When the residual is large, the system can compute the “most uncertain region” from the current geometry and suggest adding a device in that direction, trading one more recording for a contraction of the localization region.
4. Engineering Practices
- Sampling rate and window: when the target band is high, the sampling rate needs enough headroom; the analysis window should cover the complete transient, usually a few hundred milliseconds.
- Triggering strategy: listen during long periods of silence plus threshold-triggered recording, avoiding continuous uploads that consume bandwidth and battery.
- Privacy boundary: capture only short clips when triggered, extract features locally before uploading, and clearly inform users of the capture scope.
- Result presentation: output a probability heatmap or a candidate radius rather than a single point coordinate, which better matches the real error distribution.
- Speed-of-sound correction: temperature changes the speed of sound, so for higher accuracy it can be corrected using the ambient temperature.
If this capability is moved to the cloud, object storage can hold the captured clips, a message queue can smooth out traffic peaks, a container platform can host the solving tasks, and logging plus monitoring and alerting services can track trigger frequency. The relevant general product categories of Baidu AI Cloud can serve as a reference for this hosting approach.
5. Validation and Extensions
Following the process above, the source was finally pinned down inside one cardboard box: an old carbon monoxide detector that had been packed away by mistake, which explains all the characteristics of “long intervals, short duration, low volume.” The case shows that distributed terminals are already a ready-made sensor network, and with basic signal processing and geometric solving, vague human perception can be turned into a quantifiable coordinate estimate. The same method transfers to alarm source tracing, abnormal-noise inspection, and coarse localization of children or pets.
