Skip to content

gp7: read <Program> from GeneralMidi/MidiConnection (AT fallback path)#48

Merged
kaizenman merged 1 commit intogp67-supportfrom
fix/gp7-generalmidi-program-fallback
Apr 22, 2026
Merged

gp7: read <Program> from GeneralMidi/MidiConnection (AT fallback path)#48
kaizenman merged 1 commit intogp67-supportfrom
fix/gp7-generalmidi-program-fallback

Conversation

@kaizenman
Copy link
Copy Markdown
Owner

Block-by-block walk found one more alphaTab-parity gap.

alphaTab `_parseGeneralMidi` reads `` into `track.playbackInfo.program`. `_parseSound` later overwrites with the first sound's program when `` is present.

PyGuitarPro only read the program from ``. For a file that has `GeneralMidi` / `MidiConnection` `` but no `` block (minimal or GP6-era exports), the program was silently lost.

Fix. Added `` fallback inside the `GeneralMidi` / `MidiConnection` / `MIDISettings` loop in `_read_track`. When `` is also present, PGP's later "mirror first sound onto channel" still wins — same precedence as alphaTab.

pytest tests/ — 1609 passed, 0 skipped.

Reading every remaining AT method line-by-line found one more gap.

alphaTab's _parseGeneralMidi reads <Program> into
track.playbackInfo.program. _parseSound later overwrites that with
the first sound's program when <Sounds> is present. PyGuitarPro only
read the program from <Sounds> — for a file that has GeneralMidi
<Program> but no <Sounds> block (minimal / GP6-era exports), the
program was lost.

- Reader (src/guitarpro/gp7.py): added <Program> fallback in the
  GeneralMidi / MidiConnection / MIDISettings loop. When <Sounds>
  is also present, _read_track's later "mirror first sound onto
  channel" still wins — same precedence as alphaTab.

pytest tests/ — 1609 passed, 0 skipped.
@kaizenman kaizenman merged commit 974da56 into gp67-support Apr 22, 2026
kaizenman pushed a commit that referenced this pull request Apr 22, 2026
…lback

gp7: read <Program> from GeneralMidi/MidiConnection (AT fallback path)
kaizenman added a commit that referenced this pull request Apr 22, 2026
* Fix GP3 writeOldChord/readOldChord asymmetry

writeOldChord unconditionally wrote 6 fret ints after firstFret, but
readOldChord only reads them when firstFret != 0 (matching the Guitar Pro
byte layout). When a chord with firstFret == 0 was written and then read
back, 24 unread bytes remained in the stream, misaligning every following
read. The typical symptom was a later note's bend type byte being read as
-1, raising "ValueError: -1 is not a valid BendType".

Fix: only write the fret list when firstFret is non-zero.

Added tests/Chord Old Format.gp3 (derived from Chords.gp3 with the first
chord's newFormat set to False and firstFret set to 0). Without the fix
the new test fails with the exact error above; with the fix it passes.

---------

Co-authored-by: kaizenman <kaizenman@users.noreply.github.com>
Co-authored-by: Sviatoslav Abakumov <dust.harvesting@gmail.com>
kaizenman added a commit that referenced this pull request Apr 22, 2026
…lback

gp7: read <Program> from GeneralMidi/MidiConnection (AT fallback path)
@kaizenman kaizenman deleted the fix/gp7-generalmidi-program-fallback branch April 22, 2026 13:24
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