Skip to content

feat: tablature staff tuning in mx::api - #469

Merged
webern merged 1 commit into
m/mxdev-keyprintfrom
m/mxdev-stafftune
Nov 1, 2026
Merged

webern merged 1 commit into
m/mxdev-keyprintfrom
m/mxdev-stafftune

Conversation

@webern

@webern webern commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

<staff-details> kept <staff-lines> but dropped every <staff-tuning>, so a guitar tab came
back with its lines and no record of what the strings are tuned to.

StaffData gains staffTunings, a list of the new StaffTuningData (line, step, alter, cents,
octave). Like staffLines, it is set on the measure whose attributes carry the staff-details and
is not carried forward to later measures. The reader honours the number attribute on
<staff-details>, and reads a <staff-details> that holds only tunings. The writer emits the
tunings between <staff-lines> and <staff-size>, as the schema orders them.

The tuning-step / tuning-alter / tuning-octave translation is shared with the existing scordatura
reader and writer through a small header-only helper (TuningFunctions.h), with no change to
scordatura behavior or diagnostics. A separate StaffTuningData type rather than reusing
AccordData: a staff tuning has a required line, an accord an optional string number.

musuite/testTablature1.xml, testTablature2.xml and testTablature3.xml now round-trip and are
pinned in the baseline. lysuite/ly71e_TabStaves.xml and recsuite/BrookeWestSample.xml lose
their tuning differences but still fail on other staff-details content (staff-type, capo,
show-frets, line-detail), which is not modeled here.

Testing

  • New MeasureDataTest cases: tuning round trip, alter and cents, tunings without staff-lines,
    two staves; new MeasureWriterTest case for the written <staff-tuning>
  • Existing scordatura tests pass unchanged
  • make api-test passes (6195 assertions in 716 test cases)
  • make api-roundtrip passes, 445 of 445 pinned files
  • make api-roundtrip-discover: 445 pass, no file that passed before now fails
  • Unity build (CMAKE_UNITY_BUILD_BATCH_SIZE=0) of the mx target compiles
  • make fmt-check passes

References

@webern webern added feature new feature request non-breaking fixes or implementation that do not require breaking changes api Affects the mx::api layer impl Affects the mx::impl layer ai Issues opened by, or through, a coding agent. labels Oct 28, 2026
@webern
webern added this pull request to stack #475 October 28, 2026 20:08
@webern
webern marked this pull request as ready for review October 29, 2026 07:10
@webern webern changed the title feat: round-trip tablature staff tuning in mx::api feat: tablature staff tuning in mx::api Oct 30, 2026
<staff-details> kept <staff-lines> but dropped every <staff-tuning>, so a
guitar tab came back with its lines and no record of what the strings are
tuned to.

StaffData gains staffTunings, a list of the new StaffTuningData (line, step,
alter, cents, octave). Like staffLines, it is set on the measure whose
attributes carry the staff-details. The reader fills it and the writer emits
the tunings between staff-lines and staff-size.

The tuning-step, tuning-alter and tuning-octave translation is shared with
the existing scordatura reader and writer through TuningFunctions.h, with no
change to scordatura behavior or diagnostics.

musuite/testTablature1.xml, testTablature2.xml and testTablature3.xml now
round-trip and are pinned in the baseline.
@webern
webern force-pushed the m/mxdev-stafftune branch from 6dd2e37 to 67358c1 Compare October 30, 2026 08:15
@webern
webern merged commit 1b7f647 into main Nov 1, 2026
8 of 16 checks passed
@webern
webern deleted the m/mxdev-stafftune branch November 1, 2026 14:09
webern added a commit that referenced this pull request Nov 1, 2026
## Summary

The barline documentation in the schema (complexType `barline`) says the
location attribute must
match where the barline occurs in the musical data, and that a left
barline "should be the first
element in the measure, aside from the print, bookmark, and link
elements."

`MeasureWriter` broke both halves of that:

- A left barline was written ahead of the measure's `<print>`. It now
follows the `<print>` (and
  still precedes `<attributes>`).
- A `location="middle"` barline was written at the end of the measure.
It is now written when the
write position reaches its tick: before a `<backup>`/`<forward>` that
moves past it, and after one
that lands on it. A middle barline whose tick no note reaches is still
written at the end.

Right barlines and barlines with no location are written where they were
before. No api change.
This also resolves the old TODO in `MeasureWriter.cpp` about barlines
landing in the wrong place.

Two corpus files now round-trip and are pinned:

- lysuite/ly46b_MidmeasureBarline.xml
- musetrainer/Bella_Ciao.xml (also relies on the harmony print-frame
change in #467)

The left-barline change removes a reorder from 7 of the 16 corpus files
that have
`<print>` followed by a left barline; the rest still fail for other
reasons.

Known limits, none of which occur in the corpus: a source that puts a
middle barline after a
`<backup>` gets it written in the earlier voice at the same tick (valid,
not byte-identical), and
a middle barline at the very end of a multi-voice measure is written
before the `<backup>`.

## Testing

- [x] New `MeasureWriterTest` cases: left barline after print, left
barline without print, middle
barline at its tick, after a forward, before a backup, unspecified
location stays last, and a
  middle barline no note reaches is written once at the end
- [x] `make api-test` passes (6212 assertions in 723 test cases)
- [x] `make api-roundtrip` passes, 447 of 447 pinned files
- [x] `make api-roundtrip-discover`: 447 pass, against 445 on the commit
below; no file lost its pass
- [x] `make fmt-check` passes

## References

- Stacked on #469
- Related to #208 (api round-trip pass-list coverage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent. api Affects the mx::api layer feature new feature request impl Affects the mx::impl layer non-breaking fixes or implementation that do not require breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant