Detecting Gunshots From Acoustic Sensor Networks
11 min read · updated August 11, 2026
Locating a sound source from a sensor network is not a machine learning problem. It is a geometry problem with a classifier bolted on the front, and almost every interesting failure lives in the geometry.
What a gunshot actually sounds like
A firearm discharge is not one acoustic event. If the projectile is supersonic, a microphone near its path records two: a ballistic shock wave, and then the muzzle blast. The shock wave is a pressure discontinuity dragged along behind the bullet, shaped like the letter N in the time domain, and it radiates from the trajectory rather than from the weapon. The muzzle blast is the expanding propellant gas, and that one does come from the shooter.
This matters more than any classifier detail. The shock wave arrives first at any sensor near the flight path, so a system that time-stamps the first impulsive onset and feeds it to a locator is localising the bullet’s path, not the person who fired. Systems that estimate shooter position from both events use the shock wave to recover the trajectory and the muzzle blast to fix the origin along it. A system working from muzzle blast alone is simpler, and it is the common case for city-scale networks where sensors sit on rooftops far from any trajectory.
The detector itself looks for a short broadband transient: rise time on the order of a millisecond, energy across the whole audible band rather than in harmonic partials, and a decay dominated by the environment rather than by the source. That description also fits a firework, a car backfire, a nail gun, a dropped steel plate and a door slam, which is the whole difficulty and the subject of the last section.
Why you measure differences, not times
You do not know when the shot happened. That leaves three unknowns in two dimensions — the source coordinates x and y, and the emission time t0 — against however many arrival times you have. Three sensors give three arrival times, which is exactly enough.
The usual formulation removes t0 first. Subtract one sensor’s arrival time from another’s and the emission time cancels, leaving a time difference of arrival. Multiply by the speed of sound and you have a difference of ranges: how much further the sound travelled to reach sensor A than sensor B. The set of points with a constant range difference to two fixed points is a hyperbola with those points as foci, so each pair of sensors contributes one curve and the source sits where the curves cross. Three sensors give two independent differences and therefore two curves.
Two hyperbolic branches can cross at two points, so three sensors can leave a genuine ambiguity that no amount of precision resolves. A fourth sensor kills it. So does a bounded coverage area, if one of the two candidates falls outside it, which is why a network laid out over the region it monitors is more forgiving than one on its edge.
A worked three-sensor fix
Put three sensors on a local grid in metres: A at (0, 0), B at (300, 0), C at (0, 300). Take the speed of sound as 343 m/s, its value in dry air at about 20 °C. Suppose the network records these two time differences, both relative to B, which heard the shot first:
t_A - t_B = 0.53578 s -> 343 * 0.53578 = 183.77 m t_C - t_B = 0.24423 s -> 343 * 0.24423 = 83.77 m at a 48 kHz sample rate those differences are 25,717 samples and 11,723 samples respectively
Now solve. Write rA, rB, rC for the unknown ranges from the source to each sensor. The measurements say rA - rB = 183.77 and rC - rB = 83.77. Substituting the sensor coordinates and squaring away the radicals gives two equations in x and y, and the solution is (400, 300). Check it by walking back the other way, which is the step worth doing because it is the one that catches a sign error:
rA = sqrt(400^2 + 300^2) = 500.00 m rB = sqrt(100^2 + 300^2) = 316.23 m rC = sqrt(400^2 + 0^2) = 400.00 m rA - rB = 500.00 - 316.23 = 183.77 m matches rC - rB = 400.00 - 316.23 = 83.77 m matches
In production nobody solves this in closed form, because with four or more sensors the equations are overdetermined and inconsistent — every measurement carries error, so no point satisfies all of them. The standard approach is least squares: pick the point minimising the sum of squared residuals between measured and predicted range differences, usually via a closed-form initialiser followed by Gauss-Newton refinement. The residual at the solution is your first quality signal. A fix with a large residual is a fix built from arrival times that do not describe a single point source, which usually means one sensor heard a reflection.
The error budget
Work through what actually limits accuracy, in order of how much damage each does.
- Sampling resolution is not the limit. At 48 kHz one sample is 20.8 microseconds, which is 7.1 mm of range difference. Nothing else on this list is anywhere near that good, so raising the sample rate to improve localisation is money spent on the wrong problem.
- Clock synchronisation usually is. A time difference between two boxes is only as good as the agreement between their clocks. One millisecond of offset is 0.34 m of range error. NTP over a general network drifts in the low milliseconds; a GPS-disciplined clock holds sub-microsecond, which is why sensors carry GPS receivers for timing as much as for position.
- Temperature moves the speed of sound. In air it is approximately 331.3 + 0.606 × T metres per second for T in degrees Celsius, so 0 °C gives 331.3 and 30 °C gives 349.5 — a 5.5% spread across a year. That scales every range difference. Get the temperature 20 degrees wrong on the 183.77 m difference above and you are 6.4 m out on that one measurement before geometry amplifies it. Wind adds an anisotropic term on top.
- Geometry amplifies or suppresses all of it. Geometric dilution of precision is the factor relating measurement error to position error, and it depends only on where the sensors are relative to the source. Three sensors close to collinear give a fix that is tight along the line and hopeless across it. A source outside the convex hull of the sensors is always worse than one inside it.
- Multipath is the one that bites in cities. If the direct path to a sensor is blocked by a building, the first arrival is a reflection off a facade, and the measured range is longer than the true one by the detour. This does not average out — it is a bias, not noise — and in a street canyon it dominates everything above.
- Everything here is 2D. A shot fired from a fifth floor is not on the ground plane, and a solver constrained to two dimensions projects it there, biasing the horizontal answer. Solving for altitude needs a fourth sensor and sensors that are not all at the same height.
False positives have a cost you cannot tune away
The classifier decides whether an impulsive transient was a gunshot. The locator then puts a coordinate on it, and in a deployed municipal system that coordinate becomes a dispatch. This is the part of the design where a threshold is not a modelling preference.
Public evidence on how often that dispatch is justified exists. The City of Chicago Office of Inspector General published an audit of the Chicago Police Department’s use of ShotSpotter in August 2021, covering 50,176 alerts confirmed as probable gunshots and dispatched between 1 January 2020 and 31 May 2021. Of the 41,830 of those that recorded a disposition, 4,556 — 9.1% — indicated that evidence of a gun-related criminal offence was found. The same report found a documented investigatory stop attributable to a specific alert in 2.1% of responses. The report is published in full by the Chicago OIG.
The engineering consequence is that raising recall is not free in the way it is for a music tagger. Every additional alert sends an armed response to a location, and a person standing at that location acquires suspicion by proximity to a machine’s output. That asymmetry argues for the same discipline as any other rare-event detector — see the prevalence arithmetic behind a home sound detector for why frame-level accuracy figures flatter these systems so badly — but it also argues for something no threshold provides: a human confirmation step, an audit trail of the audio behind each alert, and a published error rate. Whether a network should be deployed at all is not a question the acoustics answer, and a page about triangulation should not pretend otherwise.