]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tricks.itely
release: 1.3.138
[lilypond.git] / Documentation / user / tricks.itely
1 @c -*-texinfo-*-
2 @c Note:
3 @c
4 @c A menu is needed before every deeper *section nesting of @nodes
5 @c Run M-x texinfo-all-menus-update
6 @c to automagically fill in these menus
7 @c before saving changes
8
9 @ignore
10
11 TODO
12   * cue notes
13   * different staff sizes
14   * font selection
15
16   * move some stuff to refman
17   * merge some stuff with refman entries
18   
19   * add @ref{}s to lilypond-internals:
20      @rgrob{Name} to grob
21      @reng{Name} to engraver
22
23   there's a very simple, very general noXXX mechanism; try
24
25 noop    \property Staff.VoltaBrace = #'()
26 yes: \property Staff.VoltaBracket = #'((meta .  ((interfaces . ()))))
27
28
29   visibility?
30   brew_molecule?
31 @end ignore
32
33
34 @node Tricks
35 @chapter Tricks
36
37 @menu
38 * Manual beam settings::        Manual beam settings
39 * Engraver hacking::            Engraver hacking
40 * Part combiner::               Part combiner
41 * Markup text::                 Markup text
42 * Apply hacking::               Apply hacking
43 * Embedded TeX::                Embedded TeX
44 * Embedded PostScript::         Embedded PostScript
45 @end menu
46
47
48 @node Manual beam settings
49 @section Manual beam settings
50 @cindex beams
51 @cindex beam settings
52 @cindex manual beams
53
54
55 @c auto knees
56
57
58 @cindex @code{no-stem-extend}
59
60 Conventionally, stems and beams extend to the middle staff line.  This
61 extension can be controlled through @code{Voice.Stem}'s grob-property
62 @code{no-stem-extend}:
63
64 @quotation
65 @lilypond[fragment,relative,verbatim]
66   \grace a'8 a4
67   \property Voice.Stem \set #'no-stem-extend = ##t
68   \grace g8 g4 [g8 g]
69 @end lilypond
70 @end quotation
71
72 The beam symbol can be tweaked through @code{Voice.Beam}'s
73 grob-properties @code{height} and @code{staff-position},
74 in staff-spaces.
75
76 Set @code{height} to zero, to get horizontal beams:
77
78 @quotation
79 @lilypond[fragment,relative,verbatim]
80   \property Voice.Beam \set #'direction = #1
81   \property Voice.Beam \set #'height = #0
82   [a''8 e' d c]
83 @end lilypond
84 @end quotation
85
86 Here's how you'd specify a weird looking beam that instead of being
87 horizontal, falls two staff spaces:
88
89 @quotation
90 @lilypond[fragment,relative,verbatim]
91   \property Voice.Beam \set #'staff-position = #2
92   \property Voice.Beam \set #'height = #-2
93   [c'8 c] 
94 @end lilypond
95 @end quotation
96 @cindex @code{default-neutral-direction}
97
98 The direction of a perfectly centred beams can be
99 controlled through @code{Voice.Beam}'s grob-property
100 @code{default-neutral-direction}
101
102 @quotation
103 @lilypond[fragment,relative,verbatim]
104   [b''8 b]
105   \property Voice.Beam \set #'default-neutral-direction = #-1
106   [b b]
107 @end lilypond
108 @end quotation
109
110 There are several ways to calculate the direction of a beam.
111 @table @code
112 @item majority
113 number count of up or down notes
114 @item mean
115 mean center distance of all notes
116 @item median
117 mean centre distance weighted per note
118 @end table
119
120 You can spot the differences of these settings from these simple
121 examples:
122
123 @quotation
124 @lilypond[fragment,relative,verbatim]
125   [d''8 a]
126   \property Voice.Beam \set #'dir-function = #beam-dir-mean
127   [d a] 
128   \property Voice.Beam \set #'dir-function = #beam-dir-median
129   [d a]
130 @end lilypond
131 @end quotation
132
133 @quotation    
134 @lilypond[fragment,relative,verbatim]
135   \time 3/8;
136   [d''8 a a]
137   \property Voice.Beam \set #'dir-function = #beam-dir-mean
138   [d a a] 
139   \property Voice.Beam \set #'dir-function = #beam-dir-median
140   [d a a] 
141 @end lilypond
142 @end quotation
143
144 These beam direction functions are defined in @file{scm/beam.scm}.  If
145 your favourite algorithm isn't one of these, you can hook up your own.
146
147
148
149 @node Engraver hacking
150 @section Engraver hacking
151
152 No time signature, no barlines... 
153 @lilypond[verbatim]
154 \score {
155   \notes \relative c'' {
156     a b c d
157     d c b a
158   }
159   \paper {
160     linewidth = -1.;
161     \translator {
162       \StaffContext
163       whichBar = #""
164       \remove "Time_signature_engraver";
165     }
166   }
167 }
168 @end lilypond
169
170 No staff, no clef, squash pitches
171 @lilypond[verbatim]
172 \score {
173   \notes { c4 c4 c8 c8 }
174   \paper {
175     linewidth = -1.;
176     \translator {
177       \StaffContext
178       \remove Staff_symbol_engraver;
179       \consists Pitch_squash_engraver;
180       \remove Clef_engraver;
181     }
182   }
183 }
184 @end lilypond
185
186
187
188 @node Markup text
189 @section Markup text
190
191
192 @ignore
193
194
195 #(define text-flat '((font-relative-size . -2 ) (music "accidentals--1")))
196
197   \property VoiceCombineStaff.instrument = #`((kern . 0.5) (lines
198     "2 Clarinetti" (rows "     (B" ,text-flat ")")))
199
200     % Ugh, markup burps
201     \property StaffCombineStaff.instrument = #'((kern . 0.5)
202     (lines "Violoncello" (rows "     e") (rows "Contrabasso")))
203
204
205 @end ignore
206
207
208
209 Metrome hack...
210
211 [todo: hack this into C++, use \tempo]
212
213 @lilypond[verbatim]
214 #(define note '(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
215 #(define eight-note `(rows ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3")))))
216 #(define dotted-eight-note `(rows ,eight-note (music "dots-dot")))
217
218 \score {
219   \notes\relative c'' {
220     a1^#`((rows (font-relative-size . -1)) ,dotted-eight-note " = 64")
221   }
222   \paper {
223     linewidth = -1.;
224     \translator{
225       \ScoreContext
226       TextScript \override #'font-shape = #'upright
227     }
228   }
229 }
230 @end lilypond
231
232
233 @c  equalizer
234
235
236 @node Apply hacking
237 @section Apply hacking
238
239 [Add Parenthesed note head example?]
240
241 [Add Smart transpose example?]
242
243
244 @lilypond[verbatim]
245 music = \notes { c'4 d'4( e'4 f'4 }
246
247 #(define (reverse-music music)
248   (let* ((elements (ly-get-mus-property music 'elements))
249          (reversed (reverse elements))
250          (span-dir (ly-get-mus-property music 'span-direction)))
251     
252     (ly-set-mus-property music 'elements reversed)
253     
254     (if (dir? span-dir)
255         (ly-set-mus-property music 'span-direction (- span-dir)))
256     
257     (map reverse-music reversed)
258     
259     music))
260
261 \score {
262   \context Voice {
263     \music
264     \apply #reverse-music \music
265   }
266   \paper { linewidth = -1.; }
267 }
268 @end lilypond
269
270 @node Embedded TeX
271 @section Embedded TeX
272 @lilypond[fragment,relative,verbatim]
273   a''^"3 $\\times$ \\`a deux"
274 @end lilypond
275
276 @node Embedded PostScript
277 @section Embedded PostScript
278
279 Arbitrary lines and curves not supported...
280
281 [TODO:] Make a direct postscript command?
282
283 @lilypond[verbatim]
284 \score {
285   \notes \relative c'' {
286     a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
287     -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
288     b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
289     s2
290     a'1
291   }
292   \paper { linewidth = 70 * \staffspace; }
293 }
294 @end lilypond