---
title: Locating sound sources
heading: Finding where a sound comes from by the time difference of its arrival at separated microphones, bearings from one pair, positions from hyperbolas, delay estimates by cross-correlation and phase-transform weighting, and the accuracy limits set by sampling, bandwidth, signal-to-noise ratio and the speed of sound
eyebrow: S16 · Lesson 18 · Locating sound sources
xp: 50
---

::: hook
Two ears tell you where a sound comes from by the tiny delay between them, and engineered systems do the same with microphones: conference phones steer toward the talker, cities triangulate gunshots, and machine monitors pinpoint a leaking valve. The physics is just the speed of sound, but the engineering is in measuring a delay of microseconds from noisy signals, and in knowing how errors in that delay, or in the speed itself, turn into errors in position.
:::

::: play
- Two microphones a distance d apart hear a far source at angle θ from broadside. The curve is the angle implied by a measured delay τ, $\theta = \sin^{-1}(c\tau/d)$.
- Near broadside a small change in delay barely moves the bearing; near end-fire the curve steepens, and the same delay error gives a large bearing error.
- A wider spacing gives finer resolution but must stay under half a wavelength at the highest frequency to keep the delay unambiguous for narrowband signals.
:::

```sim plot
view: graph
x: t = -1..1
y: a = -90..90
slider: d = 0.05..1 = 0.2
plot: asin(t*1e-3*343/d)*180/pi | samples: 400 | label: bearing, degrees
```

::: predict
## Two microphones 0.2 m apart hear a source 0.30 ms earlier at one than the other. Sampled at 48 kHz without interpolation, about how precisely is the bearing known?

- [ ] To 0.01°
- [ ] To 0.3°
- [x] To a few degrees
- [ ] Not at all

::: reveal
The bearing is $\sin^{-1}(343 \times 0.0003/0.2)$ = 31°. One sample, 20.8 µs, moves the bearing by about $c\,\delta\tau/(d\cos\theta)$ = 0.042 rad, 2.4°. Interpolating the correlation peak between samples, as real systems do, refines it several times.
:::
:::

::: nameit
## Bearing from one pair

A plane wave arriving at angle θ from the broadside of two microphones d apart reaches one first by
$$\tau = \frac{d\sin\theta}c, \qquad \theta = \sin^{-1}\frac{c\tau}d$$
A delay error δτ gives a bearing error of about $c\,\delta\tau/(d\cos\theta)$: smallest at broadside, growing without limit toward end-fire. One pair can't tell a source in front from one behind (a cone of ambiguity); a third microphone resolves it in a plane.

## Position from hyperbolas

For a nearby source, each pair's delay fixes the difference of the source's distances to the two microphones, $c\tau$, which places it on one branch of a hyperbola with the microphones at its foci. Two independent differences from three microphones intersect at the source in a plane; four give a position in space. Errors in c scale every range difference in proportion: a 10 °C error in the assumed air temperature is a 1.7% error.

## Measuring the delay

The delay is where the cross-correlation of the two signals peaks. Reverberation and colored noise broaden that peak, so systems often whiten the cross-spectrum first, dividing each frequency by its magnitude (the **phase transform**, GCC-PHAT), which sharpens the peak to nearly an impulse. Fitting a parabola through the peak sample and its neighbors locates it to a fraction of a sample.

## Accuracy limits

For a signal of RMS bandwidth β and energy-to-noise ratio E/N₀, no unbiased estimator can measure a delay better than about
$$\sigma_\tau \approx \frac1{2\pi\beta\sqrt{2E/N_0}}$$
so broadband sounds (clicks, speech consonants, gunshots) locate far better than pure tones, and longer observations help through E.
:::

::: example
## Two sensors 400 m apart record a gunshot 0.5 s apart. How far is the source from the sensors' perpendicular bisector, in range difference, and how much does a 10 °C error in the assumed temperature move it?

::: solution
1. **Range difference.**
   $$\begin{aligned} \Delta r &= c\tau \\ &= 343 \times 0.5 \\ &= 171.5\ \text{m} \end{aligned}$$
   which puts the source on a hyperbola with the sensors at its foci.
2. **Temperature error.** Speed of sound goes as the square root of absolute temperature, so from 20 to 30 °C it rises by a factor of
   $$\sqrt{303.15/293.15} = 1.017$$
3. **Effect on position.** The range difference grows by 1.7%, about 3 m, and with it every computed position shifts.
4. **In practice.** Acoustic location systems therefore measure the air temperature, and wind, too, adds its component along each path.

**Answer:** the range difference is 171.5 m, and a 10 °C error in temperature changes it by 1.7%, about 3 m.
:::
:::

::: example
## A transient has an RMS bandwidth of 500 Hz and an energy-to-noise ratio of 20 dB at each microphone. What's the best delay accuracy, and what bearing accuracy does that give a 0.2 m pair at broadside?

::: solution
1. **Delay accuracy.** With E/N₀ = 100:
   $$\begin{aligned} \sigma_\tau &= \frac{1}{2\pi \times 500 \times \sqrt{200}} \\ &= 22.5\ \mu\text{s} \end{aligned}$$
   about one sample at 48 kHz.
2. **Bearing accuracy.** At broadside:
   $$\begin{aligned} \sigma_\theta &= c\sigma_\tau/d \\ &= \frac{343 \times 22.5 \times 10^{-6}}{0.2} \\ &= 0.039\ \text{rad} \end{aligned}$$
   or 2.2°.
3. **Improving it.** Widening the pair to 1 m, or doubling the bandwidth, cuts it proportionally.

**Answer:** the best delay accuracy is 22.5 µs, which gives a bearing accuracy of 0.039 rad (2.2°).
:::
:::

::: example
## What's the largest spacing two microphones can have so that a 4 kHz tone's delay is unambiguous from any direction?

::: solution
1. **When a delay is ambiguous.** For a tone, the correlation repeats every period, so delays up to ±T/2 are distinguishable.
2. **Largest spacing.** The largest delay, d/c at end-fire, must stay under half a period, so
   $$\begin{aligned} d &< \lambda/2 \\ &= 343/8000 \\ &= 4.3\ \text{cm} \end{aligned}$$
3. **Narrowband and broadband arrays.** Arrays for narrowband signals keep their spacing near half a wavelength (lesson 17's grating-lobe rule); broadband localizers can use much wider spacings because their correlation peaks don't repeat.

**Answer:** 4.3 cm, half a wavelength.
:::
:::

::: check
kind: parts
given: d = 0.1 | 0.25 | 0.5; u = 0.3 | 0.6 | 0.85; f = 16 | 48; let t = u*d/343*1e3

## Two microphones {d} m apart (c = 343 m/s) see a delay of {t} ms, sampled at {f} kHz.

::: part
answer: asin(343*t*1e-3/d)*180/pi
unit: °
tolerance: 0.5%

### What bearing from broadside does the delay imply?

::: misses
- [acos(343*t*1e-3/d)*180/pi] Measured from broadside the delay goes as the sine.
- [any] $\sin^{-1}(c\tau/d)$.
:::
:::

::: part
answer: 343/(f*1e3)/(d*cos(asin(343*t*1e-3/d)))*180/pi
unit: °
tolerance: 0.5%

### How much does one sample of delay change the bearing there?

::: misses
- [343/(f*1e3)/d*180/pi] Divide by cos θ too: the error grows away from broadside.
- [any] $c\,\delta\tau/(d\cos\theta)$.
:::
:::
:::

::: check
kind: parts
given: t = 0.05 | 0.4 | 1.2; T = 0 | 10 | 35; e = 5 | 10

## Two sensors record a sound {t} s apart; the air is at {T} °C, but the system assumes a temperature {e} °C lower.

::: part
answer: 331.3*sqrt(1 + T/273.15)*t
unit: m
tolerance: 0.5%

### What is the true range difference?

::: misses
- [343*t] Use the speed of sound at the actual temperature.
- [any] cτ with $c = 331.3\sqrt{1 + T/273.15}$.
:::
:::

::: part
answer: (331.3*sqrt(1 + T/273.15) - 331.3*sqrt(1 + (T - e)/273.15))*t
unit: m
tolerance: 0.5%

### By how much does the assumption understate it?

::: misses
- [any] The difference in c times τ.
:::
:::
:::

::: check
kind: parts
given: B = 100 | 500 | 2000; E = 10 | 20 | 30; d = 0.2 | 1

## A signal of RMS bandwidth {B} Hz reaches two microphones {d} m apart with an energy-to-noise ratio of {E} dB.

::: part
answer: 1/(2*pi*B*sqrt(2*10^(E/10)))*1e6
unit: µs
tolerance: 0.5%

### What is the smallest delay error an unbiased estimator can achieve?

::: misses
- [1/(2*pi*B*sqrt(10^(E/10)))*1e6] The bound uses 2E/N₀.
- [any] $1/(2\pi\beta\sqrt{2E/N_0})$.
:::
:::

::: part
answer: 343/(2*pi*B*sqrt(2*10^(E/10)))/d*180/pi
unit: °
tolerance: 0.5%

### What bearing error is that at broadside?

::: misses
- [any] $c\sigma_\tau/d$.
:::
:::
:::

::: check
kind: parts
given: f = 1 | 4 | 8

## A narrowband source near {f} kHz must be located by one microphone pair without ambiguity from any direction.

::: part
answer: 343/(2*f*1e3)*100
unit: cm
tolerance: 0.5%

### What is the widest spacing allowed?

::: misses
- [343/(f*1e3)*100] The delay must stay within half a period: d < λ/2.
- [any] λ/2.
:::
:::
:::

::: check
kind: parts
given: a = 0.3 | 0.6 | 0.8; b = 1 | 1.2; c = 0.9 | 1

## A cross-correlation peaks at sample k with value {b}, flanked by {a} at k − 1 and {c} at k + 1.

::: part
answer: (a - c)/(2*(a - 2*b + c))
unit: samples
tolerance: 1%

### By how many samples does a parabola through the three points shift the peak from k?

::: misses
- [(c - a)/(2*(a - 2*b + c))] Check the sign: the peak moves toward the larger neighbor.
- [any] $\frac{y_{-1} - y_{+1}}{2(y_{-1} - 2y_0 + y_{+1})}$.
:::
:::
:::

::: check
kind: choice

## Why do localization systems often whiten the cross-spectrum (the phase transform) before finding the correlation peak?

- [ ] It removes the noise entirely
- [x] Dividing each frequency by its magnitude keeps only the phase, which carries the delay, so strong low-frequency content and room resonances no longer broaden the peak, and it becomes sharp
- [ ] It converts the delay to a frequency
- [ ] It makes the microphones more sensitive

::: misses
- [1] Noise remains; it's the peak's shape that improves.
- [3] The delay stays a delay.
- [4] It's a processing step, not a hardware change.
:::
:::

::: check
kind: derivation
vars: d = 0.05..2, t = 0..0.00015, s = 0.000001..0.0001

## Two microphones d apart (c = 343 m/s) measure a delay τ with error δτ.

::: step
answer: asin(343*t/d)

### What bearing, in radians, does the delay imply?
:::

::: step
answer: 343*s/(d*cos(asin(343*t/d)))

### About how large is the bearing error?
:::

::: right
Right. Spacing helps in proportion; steep angles near end-fire hurt.
:::
:::

::: explain
## Why do broadband sounds locate much more precisely than pure tones?

::: model
A delay is measured by sliding one signal against the other until they match best. For a pure tone, every shift by one period matches equally well, so the correlation is a long ripple with no single peak, and its peaks are as broad as half a period. A broadband sound contains many frequencies whose ripples line up only at the true delay and cancel elsewhere, giving a single sharp peak whose width is about one over the bandwidth. The sharper the peak, the less noise can move it, so accuracy improves in proportion to bandwidth, and clicks, consonants and gunshots are far easier to locate than whistles.
:::
:::

::: practice
::: check
given: d = 0.15 | 0.4; t = 0.1 | 0.3
answer: asin(343*t*1e-3/d)*180/pi
unit: °
tolerance: 0.5%

## Bearing: {d} m pair, {t} ms delay?

::: misses
- [any] $\sin^{-1}(c\tau/d)$.
:::
:::

::: check
given: B = 300 | 1000; E = 15 | 25
answer: 1/(2*pi*B*sqrt(2*10^(E/10)))*1e6
unit: µs
tolerance: 0.5%

## Delay bound: {B} Hz bandwidth, {E} dB?

::: misses
- [any] $1/(2\pi\beta\sqrt{2E/N_0})$.
:::
:::

::: check
given: f = 0.5 | 1 | 2 | 4 | 6 | 8
answer: 343/(2*f*1e3)*100
unit: cm
tolerance: 0.5%

## Largest unambiguous spacing at {f} kHz?

::: misses
- [any] λ/2.
:::
:::
:::
