]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/new/engravers-one-by-one.ly
Docs: run convert-ly for 2.14.0.
[lilypond.git] / Documentation / snippets / new / engravers-one-by-one.ly
1 \version "2.14.0"
2
3 \header {
4   lsrtags = "contexts-and-engravers"
5
6   texidoc = "
7 The notation problem, creating a certain symbol, is handled by plugins.
8  Each plugin is called an Engraver. In this example, engravers are
9 switched on one by one, in the following order:
10
11 - note heads,
12
13
14 - staff symbol,
15
16
17 - clef,
18
19
20 - stem,
21
22
23 - beams, slurs, accents,
24
25
26 - accidentals, bar lines, time signature and key signature.
27
28
29
30 Engravers are grouped. For example, note heads, slurs, beams etc. form
31 a @code{Voice} context. Engravers for key signature, accidentals, bar
32 line, etc. form a @code{Staff} context.
33
34 "
35   doctitle = "Engravers one-by-one"
36 } % begin verbatim
37
38
39 %% sample music
40 topVoice = \relative c' {
41   \key d \major
42   es8([ g] a[ fis])
43   b4
44   b16[-. b-. b-. cis-.]
45   d4->
46 }
47
48 botVoice = \relative c' {
49   \key d \major
50   c8[( f] b[ a)]
51   es4
52   es16[-. es-. es-. fis-.]
53   b4->
54 }
55
56 hoom = \relative c {
57   \key d \major
58   \clef bass
59   g8-. r
60   r4
61   fis8-.
62   r8
63   r4
64   b'4->
65 }
66
67 pah = \relative c' {
68   r8 b-.
69   r4
70   r8 g8-.
71   r16 g-. r8
72   \clef treble
73   fis'4->
74 }
75
76 %
77 % setup for Request->Element conversion. Guru-only
78 %
79
80 MyStaff = \context {
81   \type "Engraver_group"
82   \name Staff
83
84   \description "Handles clefs, bar lines, keys, accidentals.  It can contain
85 @code{Voice} contexts."
86
87   \consists "Output_property_engraver"
88
89   \consists "Font_size_engraver"
90
91   \consists "Volta_engraver"
92   \consists "Separating_line_group_engraver"
93   \consists "Dot_column_engraver"
94
95   \consists "Ottava_spanner_engraver"
96   \consists "Rest_collision_engraver"
97   \consists "Piano_pedal_engraver"
98   \consists "Piano_pedal_align_engraver"
99   \consists "Instrument_name_engraver"
100   \consists "Grob_pq_engraver"
101   \consists "Forbid_line_break_engraver"
102   \consists "Axis_group_engraver"
103
104   \consists "Pitch_squash_engraver"
105
106   localKeySignature = #'()
107
108   % explicitly set instrumentName, so we don't get
109   % weird effects when doing instrument names for
110   % piano staves
111
112   instrumentName = #'()
113   shortInstrumentName = #'()
114
115   \accepts "Voice"
116 }
117
118
119 MyVoice = \context {
120   \type "Engraver_group"
121   \name Voice
122
123   \description "
124     Corresponds to a voice on a staff.  This context handles the
125     conversion of dynamic signs, stems, beams, super- and subscripts,
126     slurs, ties, and rests.
127
128     You have to instantiate this explicitly if you want to have
129     multiple voices on the same staff."
130
131   localKeySignature = #'()
132   \consists "Font_size_engraver"
133
134   % must come before all
135   \consists "Output_property_engraver"
136   \consists "Arpeggio_engraver"
137   \consists "Multi_measure_rest_engraver"
138   \consists "Text_spanner_engraver"
139   \consists "Grob_pq_engraver"
140   \consists "Note_head_line_engraver"
141   \consists "Glissando_engraver"
142   \consists "Ligature_bracket_engraver"
143   \consists "Breathing_sign_engraver"
144   % \consists "Rest_engraver"
145   \consists "Grace_beam_engraver"
146   \consists "New_fingering_engraver"
147   \consists "Chord_tremolo_engraver"
148   \consists "Percent_repeat_engraver"
149   \consists "Slash_repeat_engraver"
150
151   %{
152     Must come before text_engraver, but after note_column engraver.
153   %}
154   \consists "Text_engraver"
155   \consists "Dynamic_engraver"
156   \consists "Fingering_engraver"
157
158   \consists "Script_column_engraver"
159   \consists "Rhythmic_column_engraver"
160   \consists "Cluster_spanner_engraver"
161   \consists "Tie_engraver"
162   \consists "Tie_engraver"
163   \consists "Tuplet_engraver"
164   \consists "Note_heads_engraver"
165   \consists "Rest_engraver"
166 }
167
168
169 \score {
170   \topVoice
171   \layout {
172     \context { \MyStaff }
173     \context { \MyVoice }
174   }
175 }
176
177
178 MyStaff = \context {
179   \MyStaff
180   \consists "Staff_symbol_engraver"
181 }
182
183 \score {
184   \topVoice
185   \layout {
186     \context { \MyStaff }
187     \context { \MyVoice }
188   }
189 }
190
191 MyStaff = \context {
192   \MyStaff
193   \consists "Clef_engraver"
194   \remove "Pitch_squash_engraver"
195 }
196
197 \score {
198   \topVoice
199   \layout {
200     \context { \MyStaff }
201     \context { \MyVoice }
202   }
203 }
204
205 MyVoice = \context {
206   \MyVoice
207   \consists "Stem_engraver"
208 }
209
210 \score {
211   \topVoice
212   \layout {
213     \context { \MyStaff }
214     \context { \MyVoice }
215   }
216 }
217
218 MyVoice = \context {
219   \MyVoice
220   \consists "Beam_engraver"
221 }
222
223 \score {
224   \topVoice
225   \layout {
226     \context { \MyStaff }
227     \context { \MyVoice }
228   }
229 }
230
231 MyVoice = \context {
232   \MyVoice
233   \consists "Phrasing_slur_engraver"
234   \consists "Slur_engraver"
235   \consists "Script_engraver"
236 }
237
238
239 \score {
240   \topVoice
241   \layout {
242     \context { \MyStaff }
243     \context { \MyVoice }
244   }
245 }
246
247 MyStaff = \context {
248   \MyStaff
249   \consists "Bar_engraver"
250   \consists "Time_signature_engraver"
251 }
252
253 \score {
254   \topVoice
255   \layout {
256     \context { \MyStaff }
257     \context { \MyVoice }
258   }
259 }
260
261 MyStaff = \context {
262   \MyStaff
263   \consists "Accidental_engraver"
264   \consists "Key_engraver"
265 }
266 \score {
267   \topVoice
268   \layout {
269     \context { \MyStaff }
270     \context { \MyVoice }
271   }
272 }
273