Skip to content

Automatic re-barring: carry an over-full bar's overflow into the next measure #46

Description

@alessonqueirozdev-hub

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiPublic surface, naming, deprecations, breaking changeseditorHit-testing, selection, editing, live playheadenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions