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

MusicXML import doesn't read `<midi-instrument>` changes in `<sound>`

Aperta
#2,085 4 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
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with SoundTagMixin.setSound in musicxml/xmlSoundParser.py, which currently handles only tempo, and with where the importer reads midi-instrument from score-part. Reproduce with the XML in the issue and check whether a sound inside a measure or direction is reached at all. The issue leaves open whether the change should become a new Instrument or another record, so settle that with the maintainers first. Done means the example yields program 73 at offset 4.0 and the related score-instrument case (#1696) is not made worse.

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

Descrizione

music21 version

10.5.0

Problem summary

A <sound> element can contain a <midi-instrument> that changes a part's program partway through, for example a doubler switching from violin to flute. The importer only reads <midi-instrument> from the <score-part>, so the whole part keeps its first program.

Steps to reproduce

from music21 import converter, instrument

xml = '''<score-partwise version="4.0">
  <part-list><score-part id="P1"><part-name>Music</part-name>
    <score-instrument id="P1-I1"><instrument-name>Doubler</instrument-name></score-instrument>
    <midi-instrument id="P1-I1"><midi-program>41</midi-program></midi-instrument>
  </score-part></part-list>
  <part id="P1">
    <measure number="1">
      <attributes><divisions>1</divisions></attributes>
      <note><pitch><step>C</step><octave>4</octave></pitch><duration>4</duration><type>whole</type></note>
    </measure>
    <measure number="2">
      <sound><midi-instrument id="P1-I1"><midi-program>74</midi-program></midi-instrument></sound>
      <note><pitch><step>D</step><octave>4</octave></pitch><duration>4</duration><type>whole</type></note>
    </measure>
  </part>
</score-partwise>'''

parsed = converter.parse(xml, format='musicxml')
print([(float(i.getOffsetInHierarchy(parsed)), i.instrumentName, i.midiProgram)
       for i in parsed.recurse().getElementsByClass(instrument.Instrument)])

Expected vs. actual behavior

Expected a second instrument, or some other record of the change, with program 73 at offset 4.0. Actual:

[(0.0, 'Doubler', 40)]

More information

Exporters usually write the change inside a direction, next to the printed cue, for example <direction><direction-type><words>Flute</words></direction-type><sound><midi-instrument id="P1-I1"><midi-program>74</midi-program></midi-instrument></sound></direction>. That's ignored too: SoundTagMixin.setSound in musicxml/xmlSoundParser.py only handles tempo.

Related: #1696, where the importer only reads a part's first <score-instrument>. Both are ways MusicXML encodes an instrument change partway through a part.

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.