Updated

Noise Direction Finder

Point your phone, turn in a circle, and follow a whine to its source.

Status: In field testing. It finds simulated sources accurately, and outdoors it picks the real 4.2 kHz whine out of the background clearly, but it hasn't led to the source yet.

What it is

Something in the neighbourhood started whining: a thin, high tone that seems to come from everywhere at once. This app turns a phone into a direction finder for it. The rear camera fills the screen, with a live spectrum, a compass tape and a radar map drawn on top. Tap the tone it has detected, or drag across the spectrum to choose a band, then turn slowly through a full circle. It records how loud that band is in every compass direction and puts a beam on the loudest bearing.

Walk toward the beam and scan again: the level rises about 6 dB each time the distance halves. Bearings taken from two or three spots and crossed on a map narrow it down further. That matters because hard walls reflect high pitches, so a single bearing can point at an echo. Tap the headphones to hear just the selected band, amplified by up to 60 dB, while you turn.

So far, a one-minute recording on a laptop showed the whine is a single steady tone at 4,210 Hz, stable to about 1 Hz and with no harmonics. Outdoors, the phone picks it out 22 dB above the background.

How it works

  • The microphone feeds a Web Audio AnalyserNode with echo cancellation, noise suppression and automatic gain control switched off. Automatic gain would quietly even out the very differences the scan measures.
  • The band level is either the loudest bin, refined by parabolic interpolation (best for a whine), or the total power in the band (for broadband noise). Tones are found in a 3-second average spectrum as narrow peaks that stand out from the noise floor on both sides, and the strongest become chips you can tap.
  • The heading is the compass direction of the camera's axis, from deviceorientationabsolute on Android and webkitCompassHeading on iOS. When the phone lies flat it falls back to the top edge.
  • While you turn, the unsmoothed level is averaged into 36 sectors of 10°, weighted by the time spent in each. The loudest sector, interpolated with its neighbours, gives the bearing, and the spread between the loudest and quietest sectors says how far to trust it. The smoothed meter would drag the bearing in the direction you turn, so the scan doesn't use it.
  • Listening isolates the band with a cascade of biquad filters. For narrow bands their Q is solved numerically against the filter's actual response, because the bilinear transform squeezes the bandwidth near Nyquist. Wide bands get Butterworth high- and low-pass edges. A limiter follows, and the compressor's built-in makeup gain is subtracted so the slider shows the true gain.
  • At 4.2 kHz the wavelength is about 8 cm, so a phone's microphone has almost no direction of its own. Most of the directivity comes from your body blocking sound from behind; cupping a hand behind the mic, or a cardboard cone around it, adds more.
  • The DSP and direction logic are pure functions with unit tests. Every push is linted, tested, built and deployed to GitHub Pages.

Built with

  • TypeScript
  • Web Audio
  • Device Orientation
  • Canvas
  • Vite
  • Vitest

Started