Skip to content

Fix lag on large midis#72

Closed
LapisHusky wants to merge 1 commit intogrimmdude:masterfrom
LapisHusky:patch-1
Closed

Fix lag on large midis#72
LapisHusky wants to merge 1 commit intogrimmdude:masterfrom
LapisHusky:patch-1

Conversation

@LapisHusky
Copy link

This provides a fix for #25 where only one event per track could play each playLoop interval. This means that if there are multiple simultaneous events, they won't play all at the same time, which can be seen when playing black midis. This fix works by doing playLoops until there are no more events to play. This might not be the most efficient way to solve the issue, because it now needs to do a playLoop twice every time there's an event, but it's better than setting sampleRate to 0 which just makes the issue require more events to see.

This provides a fix for grimmdude#25 where only one event per track could play each playLoop interval. This means that if there are multiple simultaneous events, they won't play all at the same time, which can be seen when playing black midis. This fix works by doing playLoops until there are no more events to play. This might not be the most efficient way to solve the issue, because it now needs to do a playLoop twice every time there's an event, but it's better than setting sampleRate to 0 which just makes the issue require more events to see.
@grimmdude
Copy link
Owner

Closing this PR as the underlying issue has been addressed in a more thorough way. The current codebase now handles simultaneous events by collecting all events at or before the current tick in a single pass within track.handleEvent() and emitting them all at once, rather than requiring multiple playLoop iterations. Thanks for the contribution!

@grimmdude grimmdude closed this Mar 2, 2026
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.

2 participants