]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tricks.itely
patch::: 1.3.139.jcn1
[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 * Markup text::                 Markup text
41 * Apply hacking::               Apply hacking
42 * Embedded TeX::                Embedded TeX
43 * Embedded PostScript::         Embedded PostScript
44 @end menu
45
46
47 @node Manual beam settings
48 @section Manual beam settings
49 @cindex beams
50 @cindex beam settings
51 @cindex manual beams
52
53
54 @c auto knees
55
56
57 @cindex @code{no-stem-extend}
58
59 Conventionally, stems and beams extend to the middle staff line.  This
60 extension can be controlled through @code{Voice.Stem}'s grob-property
61 @code{no-stem-extend}:
62
63 @quotation
64 @lilypond[fragment,relative,verbatim]
65   \grace a'8 a4
66   \property Voice.Stem \set #'no-stem-extend = ##t
67   \grace g8 g4 [g8 g]
68 @end lilypond
69 @end quotation
70
71 The direction of a perfectly centred beams can be
72 controlled through @code{Voice.Beam}'s grob-property
73 @code{default-neutral-direction}
74
75 @quotation
76 @lilypond[fragment,relative,verbatim]
77   [b''8 b]
78   \property Voice.Beam \set #'default-neutral-direction = #-1
79   [b b]
80 @end lilypond
81 @end quotation
82
83 There are several ways to calculate the direction of a beam.
84 @table @code
85 @item majority
86 number count of up or down notes
87 @item mean
88 mean center distance of all notes
89 @item median
90 mean centre distance weighted per note
91 @end table
92
93 You can spot the differences of these settings from these simple
94 examples:
95
96 @quotation
97 @lilypond[fragment,relative,verbatim]
98   [d''8 a]
99   \property Voice.Beam \set #'dir-function = #beam-dir-mean
100   [d a] 
101   \property Voice.Beam \set #'dir-function = #beam-dir-median
102   [d a]
103 @end lilypond
104 @end quotation
105
106 @quotation    
107 @lilypond[fragment,relative,verbatim]
108   \time 3/8;
109   [d''8 a a]
110   \property Voice.Beam \set #'dir-function = #beam-dir-mean
111   [d a a] 
112   \property Voice.Beam \set #'dir-function = #beam-dir-median
113   [d a a] 
114 @end lilypond
115 @end quotation
116
117 These beam direction functions are defined in @file{scm/beam.scm}.  If
118 your favourite algorithm isn't one of these, you can hook up your own.
119
120
121
122 @node Engraver hacking
123 @section Engraver hacking
124
125 No time signature, no barlines... 
126 @lilypond[verbatim]
127 \score {
128   \notes \relative c'' {
129     a b c d
130     d c b a
131   }
132   \paper {
133     linewidth = -1.;
134     \translator {
135       \StaffContext
136       whichBar = #""
137       \remove "Time_signature_engraver";
138     }
139   }
140 }
141 @end lilypond
142
143 No staff, no clef, squash pitches
144 @lilypond[verbatim]
145 \score {
146   \notes { c4 c4 c8 c8 }
147   \paper {
148     linewidth = -1.;
149     \translator {
150       \StaffContext
151       \remove Staff_symbol_engraver;
152       \consists Pitch_squash_engraver;
153       \remove Clef_engraver;
154     }
155   }
156 }
157 @end lilypond
158
159
160
161 @node Markup text
162 @section Markup text
163
164
165 @ignore
166
167
168 #(define text-flat '((font-relative-size . -2 ) (music "accidentals--1")))
169
170   \property VoiceCombineStaff.instrument = #`((kern . 0.5) (lines
171     "2 Clarinetti" (rows "     (B" ,text-flat ")")))
172
173     % Ugh, markup burps
174     \property StaffCombineStaff.instrument = #'((kern . 0.5)
175     (lines "Violoncello" (rows "     e") (rows "Contrabasso")))
176
177
178 @end ignore
179
180
181
182 Metrome hack...
183
184 [todo: hack this into C++, use \tempo]
185
186 @lilypond[verbatim]
187 #(define note '(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
188 #(define eight-note `(rows ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3")))))
189 #(define dotted-eight-note `(rows ,eight-note (music "dots-dot")))
190
191 \score {
192   \notes\relative c'' {
193     a1^#`((rows (font-relative-size . -1)) ,dotted-eight-note " = 64")
194   }
195   \paper {
196     linewidth = -1.;
197     \translator{
198       \ScoreContext
199       TextScript \override #'font-shape = #'upright
200     }
201   }
202 }
203 @end lilypond
204
205
206 @c  equalizer
207
208
209 @node Apply hacking
210 @section Apply hacking
211
212 [Add Parenthesed note head example?]
213
214 [Add Smart transpose example?]
215
216
217 @lilypond[verbatim]
218 music = \notes { c'4 d'4( e'4 f'4 }
219
220 #(define (reverse-music music)
221   (let* ((elements (ly-get-mus-property music 'elements))
222          (reversed (reverse elements))
223          (span-dir (ly-get-mus-property music 'span-direction)))
224     
225     (ly-set-mus-property music 'elements reversed)
226     
227     (if (dir? span-dir)
228         (ly-set-mus-property music 'span-direction (- span-dir)))
229     
230     (map reverse-music reversed)
231     
232     music))
233
234 \score {
235   \context Voice {
236     \music
237     \apply #reverse-music \music
238   }
239   \paper { linewidth = -1.; }
240 }
241 @end lilypond
242
243 @node Embedded TeX
244 @section Embedded TeX
245 @lilypond[fragment,relative,verbatim]
246   a''^"3 $\\times$ \\`a deux"
247 @end lilypond
248
249 @node Embedded PostScript
250 @section Embedded PostScript
251
252 Arbitrary lines and curves not supported...
253
254 [TODO:] Make a direct postscript command?
255
256 @lilypond[verbatim]
257 \score {
258   \notes \relative c'' {
259     a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
260     -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
261     b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
262     s2
263     a'1
264   }
265   \paper { linewidth = 70 * \staffspace; }
266 }
267 @end lilypond