Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

MusicXML `<segno/>` in a `<barline>` isn't read, so expandRepeats() fails

Aperta
#2,083 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, xml
Ambito
data

Direzione di ricerca

The MusicXML importer lives in music21/musicxml, where barline children are parsed; the segno is read for directions but not for <barline>. Start by reproducing with the snippet in the issue and checking what expandRepeats() sees in music21/repeat.py. Done when a segno inside <barline> is attached to the measure so the D.S. expansion gives C, D, E, D, E, with a regression test added beside the existing repeat tests.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

music21 version

10.5.0

Problem summary

MusicXML allows a <segno> (and a <coda>) inside a <barline>, as well as in a direction. The importer doesn't read it from a barline, so a later D.S. has no segno to go to, and expandRepeats() raises.

Steps to reproduce

from music21 import converter

def measure(number, step, before="", after=""):
    return (f'<measure number="{number}">{before}<note><pitch><step>{step}</step>'
            f'<octave>4</octave></pitch><duration>4</duration><type>whole</type></note>{after}</measure>')

xml = f'''<score-partwise version="4.0">
  <part-list><score-part id="P1"><part-name>Music</part-name></score-part></part-list>
  <part id="P1">
    {measure(1, "C", "<attributes><divisions>1</divisions></attributes>")}
    {measure(2, "D", '<barline location="left"><segno/></barline>')}
    {measure(3, "E", after="<direction><direction-type><words>D.S.</words></direction-type></direction>")}
  </part>
</score-partwise>'''

converter.parse(xml, format='musicxml').expandRepeats()

Expected vs. actual behavior

Expected the notes ['C', 'D', 'E', 'D', 'E']. Actual:

music21.repeat.ExpanderException: cannot expand Stream: badly formed repeats or repeat expressions

Writing the same segno as <direction><direction-type><segno/></direction-type></direction> gives the expected result, so only the barline placement is affected.

Lingua principale
Python
Stelle
2.6k
Fork
459
Merge medio
1g 7h
PR unite (30g)
40

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cuthbertLab/music21

Tutte le issue di cuthbertLab/music21

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.