EDIT: Added complete example at the bottom, for testing (non-working, small but complete).
At the top of a MusicXML file, you can define MIDI instruments with IDs, Channel, and Program information as follows (see this w3.org page for a full example)
<midi-instrument id="Piano">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
</midi-instrument>
<midi-instrument id="Harp">
<midi-channel>2</midi-channel>
<midi-program>2</midi-program>
</midi-instrument>
Then, later in the file, within a given <note> element, you can insert an <instrument id="PREVIOUSLY_DEFINED_ID"/> tag to switch to the defined MIDI channel and program (again, see example linked above for a complete copy-and-paste MRE) as follows:
<note default-x="250">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<instrument id="piano"/>
<voice>1</voice>
<type>16th</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note default-x="250">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<instrument id="harp"/>
<voice>1</voice>
<type>16th</type>
<stem>up</stem>
<staff>1</staff>
</note>
However, when I create a file following the syntax above, and I open it in a MusicXML compatible program (e.g. Musescore or Reaper), the <instrument id="BLAH/> has no effect on the MIDI channel or program Theoretically, the example given above should change from the defined "piano" to the defined "harp".
I am using a soundfont that does include channel and program information, so I don't think it's that. Furthermore, inspecting the MIDI data generated by converting or exporting the MusicXML file as MIDI shows no changes to the program or channel parameters.
I'm not sure whether this is a (1) syntax error on my part, (2) an interpretation error by the MusicXML readers (but I've tried multiple programs), or (3)...?
Thanks!
Minimal Reproducible Example for testing:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">
<identification>
<encoding>
<software>REAPER 6.25/OSX64</software>
<encoding-date>2021-08-08</encoding-date>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7</millimeters>
<tenths>40</tenths>
</scaling>
</defaults>
<part-list>
<score-part id="P1">
<part-name>Track 1</part-name>
<score-instrument id="piano">
<instrument-name>piano</instrument-name>
</score-instrument>
<score-instrument id="harp">
<instrument-name>harp</instrument-name>
</score-instrument>
<score-instrument id="flute">
<instrument-name>flute</instrument-name>
</score-instrument>
<midi-instrument id="piano">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
</midi-instrument>
<midi-instrument id="harp">
<midi-channel>2</midi-channel>
<midi-program>2</midi-program>
</midi-instrument>
<midi-instrument id="flute">
<midi-channel>3</midi-channel>
<midi-program>3</midi-program>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="540">
<attributes>
<divisions>16</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<direction placement="above">
<direction-type>
<metronome halign="left">
<beat-unit>quarter</beat-unit>
<per-minute>120</per-minute>
</metronome>
</direction-type>
<sound tempo="120"/>
</direction>
<note default-x="120">
<rest/>
<duration>32</duration>
<voice>1</voice>
<type>half</type>
<staff>1</staff>
</note>
<note default-x="250">
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<instrument id="flute"/>
<voice>1</voice>
<type>16th</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note default-x="280">
<rest/>
<duration>4</duration>
<voice>1</voice>
<type>16th</type>
<staff>1</staff>
</note>
<note default-x="330">
<rest/>
<duration>8</duration>
<voice>1</voice>
<type>eighth</type>
<staff>1</staff>
</note>
<note default-x="380">
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>8</duration>
<instrument id="piano"/>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note default-x="450">
<rest/>
<duration>8</duration>
<voice>1</voice>
<type>eighth</type>
<staff>1</staff>
</note>
<backup>
<duration>64</duration>
</backup>
<note default-x="250">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
<measure number="2" width="480">
<note default-x="60">
<rest/>
<duration>4</duration>
<voice>1</voice>
<type>16th</type>
<staff>1</staff>
</note>
<note default-x="110">
<pitch>
<step>E</step>
<alter>-1</alter>
<octave>4</octave>
</pitch>
<duration>8</duration>
<instrument id="harp"/>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note default-x="170">
<rest/>
<duration>4</duration>
<voice>1</voice>
<type>16th</type>
<staff>1</staff>
</note>
<note default-x="220">
<rest/>
<duration>16</duration>
<voice>1</voice>
<type>quarter</type>
<staff>1</staff>
</note>
<note default-x="380">
<rest/>
<duration>32</duration>
<voice>1</voice>
<type>half</type>
<staff>1</staff>
</note>
<backup>
<duration>64</duration>
</backup>
<note default-x="320">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
<measure number="3" width="480">
<note default-x="250">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup>
<duration>64</duration>
</backup>
<note default-x="250">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
<measure number="4" width="480">
<note default-x="250">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup>
<duration>64</duration>
</backup>
<note default-x="250">
<rest/>
<duration>64</duration>
<voice>1</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
</part>
</score-partwise>