Changing MIDI output to one channel per voice: Difference between revisions
Appearance
Import snippet from LSR |
mNo edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 3: | Line 3: | ||
However, by moving the <code>Staff_performer</code> to the <code>Voice</code> context, each voice on a staff can have its own MIDI channel, as is demonstrated by the following example: despite being on the same staff, two MIDI channels are created, each with a different <code>midiInstrument</code>. | However, by moving the <code>Staff_performer</code> to the <code>Voice</code> context, each voice on a staff can have its own MIDI channel, as is demonstrated by the following example: despite being on the same staff, two MIDI channels are created, each with a different <code>midiInstrument</code>. | ||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
\score { | \score { | ||
\new Staff << | \new Staff << | ||
| Line 40: | Line 40: | ||
</lilypond> | </lilypond> | ||
[[Category:Contexts and engravers]] | |||
[[Category:Midi]] | [[Category:Midi]] | ||
[[Category:Real music]] | [[Category:Real music]] | ||
[[Category:Included in the official documentation]] | [[Category:Included in the official documentation]] | ||
[[Category:Snippet]] | |||
Latest revision as of 19:15, 16 December 2025
When outputting MIDI, the default behavior is for each staff to represent one MIDI channel, with all the voices on a staff amalgamated. This minimizes the risk of running out of MIDI channels, since there are only 16 available per track.
However, by moving the Staff_performer to the Voice context, each voice on a staff can have its own MIDI channel, as is demonstrated by the following example: despite being on the same staff, two MIDI channels are created, each with a different midiInstrument.
\version "2.24"
\score {
\new Staff <<
\new Voice \relative c''' {
\set midiInstrument = "flute"
\voiceOne
\key g \major
\time 2/2
r2 g-"Flute" ~
g fis ~
fis4 g8 fis e2 ~
e4 d8 cis d2
}
\new Voice \relative c'' {
\set midiInstrument = "clarinet"
\voiceTwo
b1-"Clarinet"
a2. b8 a
g2. fis8 e
fis2 r
}
>>
\layout { }
\midi {
\context {
\Staff
\remove "Staff_performer"
}
\context {
\Voice
\consists "Staff_performer"
}
\tempo 2 = 72
}
}