What exists now
As of the fix that came with this issue, an over-full bar is reported:
Measure 1 holds 1.2500 whole notes in voice 1 but 4/4 allows 1.0000 —
an excess of 0.2500. The music was imported as written; nothing was moved
to the next bar or dropped.
Measure.add also refuses one outright, throwing MeasureCapacityException.
What does not exist
Nothing re-bars. Write five quarters into a 4/4 bar and you get five
quarters in one bar, drawn crammed together. There is no pass that takes the
overflow and carries it into the next measure.
Why this is a feature and not a bug fix
Re-barring restructures somebody's document, and every way of doing it makes a
musical decision that the caller may not want:
- Does the overflowing figure split? A half note starting on beat 4 of a 4/4
bar cannot simply move — half of it belongs in this bar. The engraved answer
is a quarter tied across the barline, which means synthesising a note that was
never written and a tie that was never asked for.
- What happens to the bars after it? Pushing an overflow into bar 2 usually
overflows bar 2, so the operation cascades to the end of the piece and every
bar number after the first change moves.
- Which voice? Capacity is per voice. An overflow in voice 2 must not
disturb voice 1's barlines.
- Is it even wrong? A cadenza, an unmetered passage and a deliberately
over-full bar in contemporary notation are all real. Silently "fixing" them
would be a worse defect than the silence this issue replaced.
So it must be something the caller asks for, not something an importer does
on its way past.
Proposed shape
A pure function over the model, not a mutation and not a parser behaviour:
/// Re-bars [staff] so no measure exceeds its meter, splitting and tying
/// figures that straddle a barline.
Staff rebar(Staff staff, {bool tieSplitNotes = true});
- Returns a new
Staff; the input is untouched (ADR-005: layout and editing
decisions are values).
- Reports what it did — how many bars were added, which notes were split — the
same way the parsers report what they could not read.
- Available to the importers as an opt-in, never as a default.
Acceptance criteria
- Five quarters in a 4/4 bar become 4 + 1, with the fifth in a new measure.
- A half note straddling the barline becomes two quarters joined by a tie, and
MidiMapper sounds it as ONE note of the original length.
- A pickup bar is left alone.
- An over-full voice 2 does not move voice 1's barlines.
- The result passes
warnOverfullMeasures with no warnings.
- Round-trips:
staffToMusicXML(rebar(s)) re-imports to the same music.
Requested by a user testing the Live Editor, who typed a fifth quarter into a
4/4 bar and reasonably expected either a refusal or the note to move on.
What exists now
As of the fix that came with this issue, an over-full bar is reported:
Measure.addalso refuses one outright, throwingMeasureCapacityException.What does not exist
Nothing re-bars. Write five quarters into a 4/4 bar and you get five
quarters in one bar, drawn crammed together. There is no pass that takes the
overflow and carries it into the next measure.
Why this is a feature and not a bug fix
Re-barring restructures somebody's document, and every way of doing it makes a
musical decision that the caller may not want:
bar cannot simply move — half of it belongs in this bar. The engraved answer
is a quarter tied across the barline, which means synthesising a note that was
never written and a tie that was never asked for.
overflows bar 2, so the operation cascades to the end of the piece and every
bar number after the first change moves.
disturb voice 1's barlines.
over-full bar in contemporary notation are all real. Silently "fixing" them
would be a worse defect than the silence this issue replaced.
So it must be something the caller asks for, not something an importer does
on its way past.
Proposed shape
A pure function over the model, not a mutation and not a parser behaviour:
Staff; the input is untouched (ADR-005: layout and editingdecisions are values).
same way the parsers report what they could not read.
Acceptance criteria
MidiMappersounds it as ONE note of the original length.warnOverfullMeasureswith no warnings.staffToMusicXML(rebar(s))re-imports to the same music.Requested by a user testing the Live Editor, who typed a fifth quarter into a
4/4 bar and reasonably expected either a refusal or the note to move on.