Skip to content

Add measure loop selection and persistent session state - #34

Merged
agourlay merged 9 commits into
agourlay:masterfrom
kot13:master
Nov 1, 2026
Merged

agourlay merged 9 commits into
agourlay:masterfrom
kot13:master

Conversation

@kot13

@kot13 kot13 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Thank you for ruxguitar — it’s an excellent, focused tab player: fast to open GP files, clear UI, and solid playback. For daily practice I was missing two things; this PR adds both.

  1. Loop a measure range — drag to select measures (yellow highlight), press Space to loop only that section. A simple click still seeks without selecting (with a small drag threshold so clicks don’t turn into selection). Selection is shared across tracks when switching parts.

  2. Persistent session — last opened GP path, track, tempo, master volume, playback position (measure/beat), and measure selection are saved under ~/.config/ruxguitar/config.json and restored on the next launch. Opening a different file manually resets tab-related settings to defaults; auto-reopen on startup still restores the previous session for the same file.

Test plan

  • Open a GP file, click a measure — seeks, no yellow selection
  • Drag across measures — yellow range; Space loops that range
  • Switch track — selection remains visible
  • Quit and restart — same file, track, tempo, volume, position, and selection restore
  • Open another GP via dialog — tempo/volume/position reset; new file is saved as last tab
  • cargo test passes locally

Notes

Playback loop uses the existing playback timeline (measure_loop_tick_range / first_playback_ticks), not a separate MIDI rebuild.

Павел Муркин and others added 3 commits October 26, 2026 19:18
Support click-drag measure range selection with visual highlight and
loop the selected measures when starting playback with Space. Click
without dragging still seeks without selecting, using a movement
threshold to avoid accidental selection.

Save and restore session fields in ~/.config/ruxguitar/config.json:
last tab file, track, tempo, volume, cursor measure/beat, and measure
selection. Auto-open the last tab on startup; reset tempo, volume, and
position when the user opens a different GP file manually.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@agourlay agourlay self-assigned this Oct 26, 2026
@agourlay

Copy link
Copy Markdown
Owner

Thanks a lot for the contribution!

I will play with the features and review it in the coming days.

agourlay and others added 6 commits November 1, 2026 12:58
- send the events just before the loop end instead of dropping them
- restore the loop start tempo on every pass
- keep the loop in step with the selection while playing
- resume in place when paused inside the loop
- end the loop after the first pass of the last selected measure, and
  never build an empty range (unplayed alternative endings)
- remember the canonical tab path so a relative CLI path still reopens
- drop a pending startup restore when that load fails
- save the session on window close before exiting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The loop wrap lived in the audio callback, where no test reached it, and
it dropped the time that ran past the loop end, so each pass restarted up
to one audio buffer early. MidiSequencer::step now advances, plays what
is left before the loop end, and restarts at the loop start carrying that
overshoot, returning both event windows for the callback to play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The loop range was built from the seek ticks, where a measure the
playback never reaches (an unused alternative ending) borrows the tick
of the measure before it, so a selection starting or ending on one
looped the wrong measures. The range now uses each measure's first
occurrence, skips unplayed measures at either edge, and takes the start
tempo and the cursor jump from the first measure that really plays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The notes in the last buffer of a pass were started and released before
the buffer was rendered, leaving only their release tail. The sequencer
step now reports where in its time the loop end falls, and the callback
renders up to that point before releasing the notes and starting the
next pass, so the restart lands on the loop end within a synth block.

Also clarify which repeats a measure loop includes, and drop an unused
Default derive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The selection fill was a fixed semi-transparent yellow that overpowered
the notes and ignored the theme. It now blends a little of the theme's
primary color into its background, like the string lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the session as a whole defaulted when absent. A session saved
before a field was added would fail to parse, and read_config would
then reset the whole config, losing the tabs folder too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agourlay
agourlay merged commit 89291d8 into agourlay:master Nov 1, 2026
3 checks passed
@agourlay

agourlay commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks again!

I took the liberty to fix some minor things, I will release soon 👍

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