Allow clicking on the score to seek during playback - #573
Open
benjamimo1 wants to merge 1 commit into
Open
Conversation
Previously all clicks on the score were ignored while playing, so the only way to jump to a different part of the score was to stop playback, move the caret, and start again. Clicking on the staff now moves the caret and seeks playback to that location without interrupting the playback session. Clicks on other items (barlines, tempo markers, etc) are still ignored while playing, since those open editing dialogs. MidiPlayer::seekToLocation() records the requested location, which the playback loop polls alongside the existing stop flag. playScore() then restarts the loop from the new location, silencing any sounding notes and skipping the count-in. It is deliberately not a slot, since the MIDI thread's event loop is blocked while playback is running. Merging the MIDI events is now done once in playScore() rather than in playEvents(), as converting the tracks to absolute ticks is not idempotent. myIsPlaying is also now set for the duration of the whole session, so that stopPlayback() cannot observe it as false in between two seek iterations and let playback resume.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change(s)
Previously all clicks on the score were ignored while playing, so the only way to jump to a different part of the score was to stop playback, move the caret, and start again.
Clicking on the staff now moves the caret and seeks playback to that location without interrupting the playback session. Clicks on other items (barlines, tempo markers, etc) are still ignored while playing, since those open editing dialogs.
Some notes on the implementation:
MidiPlayer::seekToLocation()records the requested location, which the playback loop polls alongside the existing stop flag.playScore()then restarts the loop from the new location, silencing any sounding notes and skipping the count-in. It is deliberately not a slot, since the MIDI thread's event loop is blocked while playback is running - it's thread-safe and called directly, likeliveChangePlaybackSpeed().playEvents()now returns an enum rather than abool, to distinguish reaching the end of the score from being interrupted by a stop or a seek.playScore()rather than on eachplayEvents()call, sinceconvertToAbsoluteTicks()asserts that the tracks aren't already in absolute ticks.myIsPlayingis now set for the duration of the whole playback session rather than perplayEvents()call, so thatstopPlayback()can't observe it asfalsein between two seek iterations and let playback resume.Fixes Issue(s)