]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/changing-midi-output-to-one-channel-per-voice.ly
Run scripts/auxiliar/update-with-convert-ly.sh
[lilypond.git] / Documentation / snippets / changing-midi-output-to-one-channel-per-voice.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.16.0"
8
9 \header {
10   lsrtags = "contexts-and-engravers, midi, real-music"
11
12   texidoc = "
13 When outputting MIDI, the default behavior is for each staff to
14 represent one MIDI channel, with all the voices on a staff amalgamated.
15 This minimizes the risk of running out of MIDI channels, since there
16 are only 16 available per MIDI port, and most devices support only one
17 port.
18
19 However, by moving the @code{Staff_performer} to the @code{Voice}
20 context, each voice on a staff can have its own MIDI channel, as is
21 demonstrated by the following example: despite being on the same staff,
22 two MIDI channels are created, each with a different
23 @code{midiInstrument}.
24
25 "
26   doctitle = "Changing MIDI output to one channel per voice"
27 } % begin verbatim
28
29
30 \score {
31   \new Staff <<
32     \new Voice \relative c''' {
33       \set midiInstrument = #"flute"
34       \voiceOne
35       \key g \major
36       \time 2/2
37       r2 g-"Flute" ~
38       g fis ~
39       fis4 g8 fis e2 ~
40       e4 d8 cis d2
41     }
42     \new Voice \relative c'' {
43       \set midiInstrument = #"clarinet"
44       \voiceTwo
45       b1-"Clarinet"
46       a2. b8 a
47       g2. fis8 e
48       fis2 r
49     }
50   >>
51   \layout { }
52   \midi {
53     \context {
54       \Staff
55       \remove "Staff_performer"
56     }
57     \context {
58       \Voice
59       \consists "Staff_performer"
60     }
61     \tempo 2 = 72
62   }
63 }