Changing MIDI output to one channel per voice: Difference between revisions
Appearance
Import snippet from LSR |
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series |
||
| 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 << | ||
Revision as of 18:54, 16 November 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
}
}