audio

@audio/measure-latency1.0.2

Round-trip latency

Round-trip latency — FFT cross-correlation peak between reference and loopback

Status
calibrated
Updated
Family
measure, 7 packages under it
Category
analysis
Licence
MIT
Dependencies
2 packages, all permissive: MIT
Downloads
1,127 last month
Tests
39 in audiojs/measure's CI, passed at eedcdd1,
import latency from '@audio/measure-latency'

Plays a reference signal, records the loopback, and locates the cross-correlation peak between them via FFT — a single play-record pass gives sample-exact round-trip delay (driver + interface + cable).

let { samples, seconds, confidence } = latency(recorded, reference, { fs })
Param Default
recorded — the loopback recording (Float32Array)
reference — the signal that was played (Float32Array)
fs 44100 sample rate

Returns:

Field
samples number round-trip delay of recorded relative to reference, in samples
seconds number samples / fs
confidence number cross-correlation peak sharpness — peak magnitude over mean magnitude; higher means a more reliable peak

Use when: calibrating a play-record loopback for latency compensation before other timing-sensitive measurements (IR capture, alignment).


Part of @audio/measure — the measure family umbrella.

MIT © audiojs