Skip to content

Allow clicking on the score to seek during playback - #573

Open
benjamimo1 wants to merge 1 commit into
powertab:masterfrom
benjamimo1:playback-click-to-seek
Open

Allow clicking on the score to seek during playback#573
benjamimo1 wants to merge 1 commit into
powertab:masterfrom
benjamimo1:playback-click-to-seek

Conversation

@benjamimo1

Copy link
Copy Markdown

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, like liveChangePlaybackSpeed().
  • playEvents() now returns an enum rather than a bool, to distinguish reaching the end of the score from being interrupted by a stop or a seek.
  • Merging the MIDI events is now done once in playScore() rather than on each playEvents() call, since convertToAbsoluteTicks() asserts that the tracks aren't already in absolute ticks.
  • myIsPlaying is now set for the duration of the whole playback session rather than per playEvents() call, so that stopPlayback() can't observe it as false in between two seek iterations and let playback resume.

Fixes Issue(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.

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.
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