Skip to content

fix(synth): ensure we end playback fast at end of loops and songs#2647

Merged
Danielku15 merged 2 commits intodevelopfrom
feature/fast-end
Apr 9, 2026
Merged

fix(synth): ensure we end playback fast at end of loops and songs#2647
Danielku15 merged 2 commits intodevelopfrom
feature/fast-end

Conversation

@Danielku15
Copy link
Copy Markdown
Member

Issues

Fixes #2569

Proposed changes

This PR should fix the long lasting problems of hangs/hickups on end of songs or loops. While the old fixed already improved bits, this now really narrows down the root cause:

Problem 1: Depending on the soundfont and synth internals it can easily happen that we still have lingering voices. They even generate samples but might not be audible for humans. Due to this, when the audio output was buffering and playing samples, it kept pulling more and more samples until it eventually completed thanks to the envelope.
Problem 2: Depending on the buffering size of the output, it could additionally delay the shutdown of the synthesizer. We only checked after sample playback if we reached the end and reacted accordingly. If the output had already buffered a lot of "lingering voice audio" it would still play them to cleanly stop playing. With the default 500ms it might not be such a problem, but if timing is bad, the output might pull more samples before we decide to stop synthesizing.

To fix this problem we now do following:

  • We check on voices whether we have reached an inaudible gain and kill voices early in this case.
  • We now stop the synth also in the sample generation flow. If we detect there we are at the end, we do a fast ending of all voices (0.1ms typically). This way we prevent generation of a lot of samples the output might buffer.

Checklist

  • I consent that this change becomes part of alphaTab under it's current or any future open source license
  • Changes are implemented
  • New tests were added

Further details

  • This is a breaking change
  • This change will require update of the documentation/website

@Danielku15 Danielku15 self-assigned this Apr 9, 2026
@Danielku15 Danielku15 merged commit 03efb03 into develop Apr 9, 2026
5 checks passed
@Danielku15 Danielku15 deleted the feature/fast-end branch April 9, 2026 13:13
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.

Loop Boundary Overshoot Causes Audible Hiccup (Reactive Wrap Timing)

1 participant