Skip to content

Fix harsh noise by only synthesizing samples while playing#1330

Merged
Danielku15 merged 1 commit into
developfrom
feature/fix-harsh-noise
Dec 29, 2023
Merged

Fix harsh noise by only synthesizing samples while playing#1330
Danielku15 merged 1 commit into
developfrom
feature/fix-harsh-noise

Conversation

@Danielku15
Copy link
Copy Markdown
Member

Issues

Fixes #1298

Proposed changes

There was a race condition between the audio workers and the main synthesizer components when the playback finished. The sequence was roughly:

  1. The last samples of the song are synthesized and the sequencer finishes.
  2. The audio output still has samples to play so it continues, but we stop synthesizing new samples as we are finished.
  3. The last samples are played the synthesizer marks the playback as finished.
  4. At the same time like 3. the output already has requested again new samples for being played.
  5. The output is stopped as part of 3.
  6. As the output already requested samples we start synthesizing the related buffers.
  7. We the midi sequencer is out of sync with the main synth time.
  8. When we now start playing again the midi sequencer finishes too early and we never reach the end time as we send only 0-byte buffers to the output.
  9. We end up hanging on the output side and never complete resulting in weird samples to be played.

We fix this problem by checking on the synthesizer side whether we are currently playing and do not synthesize any samples. This prevents the sequence above by avoiding step 6.

Checklist

  • I consent that this change becomes part of alphaTab under it's current or any future open source license
  • Changes are implemented
  • Existing builds tests pass
  • 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 Dec 29, 2023
@Danielku15 Danielku15 merged commit a8bb1a7 into develop Dec 29, 2023
@Danielku15 Danielku15 deleted the feature/fix-harsh-noise branch December 29, 2023 11:59
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.

When playing for the second time to the end, it cannot be stopped and emits a harsh noise.

1 participant