编辑:在底部添加了完整的示例,用于测试(不工作,小但完整)。
在 MusicXML 文件的顶部,您可以定义具有 ID、通道和程序信息的 MIDI 乐器,如下所示(请参阅此w3.org 页面以获取完整示例)
<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>
然后,在文件的后面,在给定的<note>
元素中,您可以插入一个<instrument id="PREVIOUSLY_DEFINED_ID"/>
标签以切换到定义的 MIDI 通道和程序(再次,请参阅上面链接的示例以获取完整的复制和粘贴 MRE),如下所示:
<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>
但是,当我按照上述语法创建文件并在 MusicXML 兼容程序(例如 Musescore 或 Reaper)中打开它时,<instrument id="BLAH/>
对 MIDI 通道或程序没有影响 理论上,上面给出的示例应该从定义的“钢琴”到定义的“竖琴”。
我正在使用包含频道和节目信息的声音字体,所以我不认为是这样。此外,检查通过将 MusicXML 文件转换或导出为 MIDI 生成的 MIDI 数据显示程序或通道参数没有变化。
我不确定这是(1)我的语法错误,(2)MusicXML阅读器的解释错误(但我尝试了多个程序),还是(3)......?
谢谢!
用于测试的最小可重现示例:
<?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>