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

MusicXML writer: Ottavas that start or end in the middle of a multi-voice measure get the wrong notes from the other voices

Aperta
#1,718 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

The bug is in music21's MusicXML export of Ottavas across multiple voices in one measure. Start by reproducing it with the measure 127-128 snippet attached to the issue, then check how the octave-shift start and stop are emitted relative to each voice's notes. Done means the exported XML keeps only the correct notes inside the octave-shift span for both voice orders. The issue has no agreed design, so confirm the expected MusicXML structure with maintainers before writing a fix.

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

Descrizione

music21 version

9.2.0b2

Problem summary
MusicXML written from a music21 score that has an Ottava that ends in the middle of voice 2 will have the octave-shift stop after the appropriate note in voice 2, but the octave-shift'ed section will include all the notes in voice 1. I'm assuming (but haven't yet seen) that if the last note in the Ottava is in the middle of voice 1, then all the notes in voice 2 will be left out, even though some of them should be in the octave-shift'ed section. A similar thing can happen with an Ottava that starts in the middle of a multi-voice measure, with notes in the non-starting voice being left out or included inappropriately, depending on which voice comes first in the MusicXML file produced.

Steps to reproduce
The example I have is measures 127 and 128 of the right hand staff in Beethoven's Piano Sonata 32 Movement 2.
Measures127and128

Measure 127's right hand staff has one voice, but measure 128's right hand staff has two voices. The Ottava spans from the first note in measure 127 through the first four notes in voice 2 of measure 128. Voice 1 in measure 128 has a hidden dotted quarter rest (which extends beyond the end of the ottava) followed by three 16th notes that are not in the Ottava. In the music21 score, all the correct notes are in the Ottava, and the start and end notes are correctly the very first and very last notes that should be octave-shifted (first note is the dotted eighth note E5, last note is the 16th note Ab4). The resulting written MusicXML file does have the octave-shift start just before the E5, and the octave-shift stop just after the Ab4 (yay), but... the entirety of measure 128's voice 1 is emitted before voice2, so all of voice 1 (including those three 16th notes) is incorrectly included in the octave-shift'ed section.

Measure127And128.musicxml.snippet.txt

Any advice?
I intend to fix this myself, but I need some advice about what the MusicXML should actually look like (I am no MusicXML expert).

The only solution I can come up with (still using the same example) is to emit (in measure 128) a partial voice 1 (up through the Ab4), then back up and emit partial voice 2 (just the hidden dotted quarter rest), then emit the octave-shift stop, then emit the rest of voice 1, then back up and emit the rest of voice 2. Of course this would have to be generalized to handle octave-shift start as well, and to deal with any number of voices, etc.

Do I have that right? I suspect I will have to do a quick scan for Ottavas that have this issue, because before I start exporting a measure to MusicXML I will need to know to do partial voices in that measure. I won't be able to wait until I encounter a note that is in an Ottava, since I may have already incorrectly emitted an entire voice at that point.

Any advice from @mscuthbert or @jacobtylerwalls?

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.