Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#2,085 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
2.6k
Forks
459
Merge medio
1 d 8 h
PR fusionados (30 d)
39

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cuthbertLab/music21

Todos los issues de cuthbertLab/music21

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.