Skip to content

feat: Latency calibration UI with auto-detection and manual override #1106

@ChuxiJ

Description

@ChuxiJ

Problem

Audio output latency is not measured or compensated. This causes:

  1. Recording offset: Recorded audio is misaligned with the grid by the output latency amount
  2. Visual desync: Playhead position doesn't account for audio pipeline delay
  3. Live monitoring: Input monitoring has uncompensated round-trip latency

Without latency calibration, recording is unreliable and users cannot trust timing.

Proposed Solution

  1. Auto-detect: Read AudioContext.baseLatency + AudioContext.outputLatency on context creation
  2. Display: Show detected latency in Settings panel (in ms and samples)
  3. Manual override: Allow users to enter custom latency value (for external audio interfaces)
  4. Compensation: Offset recorded audio by the calibrated latency amount
  5. Visual compensation: Adjust playhead rendering to account for output latency

Technical Notes

  • Reference: TASK_QUEUE.md Sprint 2 backlog item
  • Key files: src/engine/AudioEngine.ts, src/components/dialogs/SettingsDialog.tsx
  • baseLatency supported in Chrome/Firefox/Safari; outputLatency Chrome-only
  • For unsupported browsers, fall back to manual entry with sensible default (10ms)

Acceptance Criteria

  • Settings panel shows detected audio latency
  • Users can manually override latency value
  • Recorded audio clips are offset-corrected by latency amount
  • Latency value persists across sessions
  • Fallback for browsers without outputLatency API
  • Unit test for latency compensation calculation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions