Skip to content

RepeatBrackets are not applied to the second (left-hand) staff in piano scores from MusicXML. #1812

@seffka

Description

@seffka

music21 version

9.3.0

Operating System(s) checked
macOS Sequoia 15.5

Problem summary

If a piano score MusicXML contains a single part with two staffs, music21 represents
it as a two part score. If the MusicXML contains repeats with various endings,
they are converted to RepeatBracket objects, but added only to the first part.

As a result, music21 produce corrupted expanded version of the score (e.g., 8 bars in the right hand, and 10 in the lefthand).

Steps to reproduce

import music21

s = music21.converter.parse("example.xml")

print("Part 0----------------")
for e in s.parts[0].flat.getElementsByClass(music21.spanner.RepeatBracket):
    print(e)
print("----------------------")

print("Part 1----------------")
for e in s.parts[1].flat.getElementsByClass(music21.spanner.RepeatBracket):
    print(e)
print("----------------------")

expanded = s.expandRepeats()
measures_in_parts = [[measure for measure in part.getElementsByClass(music21.stream.Measure)] for part in expanded.parts]

print(f"Measures in expanded part#0: {len(measures_in_parts[0])}\nMeasures in expanded part#1: {len(measures_in_parts[1])}")

Expected vs. actual behavior
There should be identical output for Part#0 and Part#1: two RepeatBrackets, 8 bars when expanded.

More information

example.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions