Skip to content

Fix streaming audio startup de-click#374

Merged
ivan-digital merged 2 commits into
mainfrom
fix/streaming-player-declick
Jul 5, 2026
Merged

Fix streaming audio startup de-click#374
ivan-digital merged 2 commits into
mainfrom
fix/streaming-player-declick

Conversation

@ivan-digital

@ivan-digital ivan-digital commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Add configurable startup de-click handling to StreamingAudioPlayer without adding default playback latency for existing model integrations.

The default remains conservative: no startup pre-roll and a short 5 ms first-chunk fade. Clients that need stronger protection for neural codec startup transients can opt into a short zero pre-roll and longer fade-in through startupPrerollDuration and startupFadeInDuration.

The PR also exposes underflowCount so streaming clients can distinguish actual mid-phrase playback starvation from normal silence after generation completes.

Why

Some neural codec TTS streams can begin with a non-zero or low-frequency transient. Starting the audio engine directly on that first sample can produce an audible dull click/pop at phrase start. Making the stronger de-click behavior configurable lets affected clients fix that startup artifact without changing timing for other models that already start cleanly.

Regression Safety

  • Default startupPrerollDuration is 0, so existing playback paths do not gain extra startup latency.
  • Default startupFadeInDuration is 0.005, matching the previous short first-chunk fade window.
  • De-clicking is only applied to the first audible chunk of a generation.
  • Underflow accounting ignores normal silence after generation completion.

Validation

  • swift test --filter StreamingAudioPlayerTests
  • 25 tests passed

@ivan-digital ivan-digital marked this pull request as ready for review July 5, 2026 06:19
@ivan-digital ivan-digital merged commit da88fcb into main Jul 5, 2026
1 check passed
@ivan-digital ivan-digital deleted the fix/streaming-player-declick branch July 5, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant