Skip to content

@hi-audio/latency-testRound-trip audio latency measurement

Web Component powered by Web Audio API. Headless API, multiple signal types, easy to embed in any Web Audio project.

Work in progress. The <latency-test> web component is currently in development. The API and examples described here reflect the planned interface. See CLAUDE_REVIEW.md for migration status.

Quick start

bash
npm install @hi-audio/latency-test
html
<latency-test id="lt"></latency-test>
<button onclick="document.getElementById('lt').start()">Test</button>

<script type="module">
  import '@hi-audio/latency-test'

  document.getElementById('lt').addEventListener('latency-result', (e) => {
    console.log(`${e.detail.latency} ms — ratio: ${e.detail.ratio.toFixed(2)} dB`)
  })
</script>

Key concepts

  • The component is headless by default — it exposes start() / stop() and fires events. No built-in button or result display.
  • Results are delivered via the latency-result CustomEvent ({ latency, ratio, timestamp }).
  • A reliability ratio above 18 dB indicates a trustworthy measurement.
  • Microphone access is requested on the first start() call.
  • For DAW or multi-context applications, pass your existing AudioContext via element.audioContext = ac before calling start().
  • Use recording-mode to select the capture backend: "mediarecorder" (v1 default, implemented) or "audioworklet" (v2 default, planned).
  • Use signal-type to select the measurement signal: "mls", "chirp", or "golay".
  • Use input-gain to apply a custom input gain (e.g. 50 to compensate for low Safari microphone levels).

Try it live

Coming soon. A live interactive demo will be available here once the component is published. It will let you test round-trip latency in your browser — with your own microphone and audio setup — before deciding whether to include the component in your project.

Origin

This component is the web component development branch of gilpanal/weblatencytest, a proof-of-concept associated with the paper presented at WAC 2025.

MIT License