Skip to content

refactor(app): normalize all recorded audio to 16kHz at capture time#50

Merged
pasrom merged 1 commit intomainfrom
fix/audio-16khz-normalization
Mar 20, 2026
Merged

refactor(app): normalize all recorded audio to 16kHz at capture time#50
pasrom merged 1 commit intomainfrom
fix/audio-16khz-normalization

Conversation

@pasrom
Copy link
Copy Markdown
Owner

@pasrom pasrom commented Mar 20, 2026

Summary

  • App and mic audio are now resampled to 16kHz when saved, instead of preserving the native device sample rate
  • AudioConstants.targetSampleRate (app target) and speechSampleRate (audiotap package) replace all hardcoded 16000 literals
  • resampleFile() fast-paths with a file copy when the source is already at 16kHz (pipeline calls become no-ops)

Problem

Mickey Mouse / pitch artifacts occurred when the system output device ran at a rate other than 48kHz (e.g. 44100Hz on some Macs/AirPods setups), or when the app and mic tracks had mismatched sample rates that were silently mixed at the wrong ratio.

Test plan

  • All 559 unit tests pass (swift test)
  • All 29 E2E tests pass (swift test --filter E2E)
  • Build and smoke-test the app (./scripts/run_app.sh)
  • Record a meeting and verify no pitch artifacts in the transcription

What: App and mic audio are now resampled to 16kHz when saved instead
of preserving the native device sample rate. AudioConstants.targetSampleRate
(app) and speechSampleRate (audiotap) provide a single named constant.
resampleFile() fast-paths with a file copy when already at 16kHz.

Reasoning:
- Problem: Mickey Mouse / pitch artifacts when app output device runs
  at a rate other than 48kHz (e.g. 44100, 96000), or when app and mic
  tracks had mismatched rates that were silently mixed at the wrong ratio.
- Decision: resample to 16kHz at the source — MicCaptureHandler via
  existing AVAudioConverter, DualSourceRecorder via AudioMixer.resample()
  before saveWAV(). All WAVs on disk are now always 16kHz; pipeline
  resampleFile() calls become no-ops.
@github-actions github-actions bot added the chore Maintenance or non-functional changes label Mar 20, 2026
@pasrom pasrom merged commit 2b8059f into main Mar 20, 2026
11 checks passed
@pasrom pasrom deleted the fix/audio-16khz-normalization branch March 20, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance or non-functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant