1 \input texinfo @c -*-texinfo-*-
2 @setfilename features.info
3 @settitle GNU LilyPond Features
7 * add more un/badly documented features
9 * add to/merge with refman
17 * Glissando:: Glissando
18 * Manual beam settings:: Manual beam settings
19 * Slur attachments:: Slur attachments
20 * Text spanner:: Text spanner
21 * Engraver hacking:: Engraver hacking
22 * Part combiner:: Part combiner
23 * Markup text:: Markup text
24 * Apply hacking:: Apply hacking
25 * Output property:: Output property
26 * Embedded TeX:: Embedded TeX
27 * Embedded PostScript:: Embedded PostScript
32 @lilypond[fragment,relative,verbatim,center]
40 @lilypond[fragment,relative,verbatim,center]
41 \context Voice <c'\arpeggio e g c>
44 @lilypond[fragment,relative,verbatim,center]
46 \property PianoStaff.connectArpeggios = ##t
47 \context Staff \context Voice <c''\arpeggio e g c>
48 \context Staff=other \context Voice <c,\arpeggio e g>
57 @lilypond[fragment,relative,verbatim,center]
61 @subsection Follow Thread
62 @lilypond[fragment,relative,verbatim,center]
64 \property PianoStaff.followThread = ##t
65 \context Staff \context Voice {
70 \context Staff=two {\clef bass; \skip 1*2;}
74 @node Manual beam settings
75 @section Manual beam settings
80 @lilypond[fragment,relative,verbatim,center]
87 Control number of beams...
89 @lilypond[fragment,relative,verbatim,center]
92 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
96 @lilypond[fragment,relative,verbatim,center]
99 \property Voice.autoBeamSettings
100 \set #'(end * * * *) = #(make-moment 1 4)
104 \property Voice.stemRightBeamCount = #1 b
105 \property Voice.stemLeftBeamCount = #1 b
109 Don't extend to middle line esp. for grace
111 @lilypond[fragment,relative,verbatim,center]
113 \property Voice.Stem \set #'no-stem-extend = ##t
121 @lilypond[fragment,relative,verbatim,center]
122 \property Voice.Beam \set #'direction = #1
123 \property Voice.Beam \set #'height-hs = #0
127 beam start-y beam-height
130 @lilypond[fragment,relative,verbatim,center]
131 \property Voice.Beam \set #'y-position-hs = #4
132 \property Voice.Beam \set #'height-hs = #-4
139 @lilypond[fragment,relative,verbatim,center]
141 \property Voice.Beam \set #'default-neutral-direction = #-1
145 There are several ways to calculate the direction of a beam.
147 [Ross] states that the majority of the notes dictates the
148 direction (and not the mean of "center distance")
150 But is that because it really looks better, or because he wants
151 to provide some real simple hands-on rules?
153 We have our doubts, so we simply provide all sensible alternatives:
157 number count of up or down notes
159 mean centre distance of all notes
161 mean centre distance weighted per note
164 You can spot the difference of these settings quite easily from these simple examples:
166 @lilypond[fragment,relative,verbatim,center]
168 \property Voice.Beam \set #'dir-function = #beam-dir-mean
170 \property Voice.Beam \set #'dir-function = #beam-dir-median
174 @lilypond[fragment,relative,verbatim,center]
177 \property Voice.Beam \set #'dir-function = #beam-dir-mean
179 \property Voice.Beam \set #'dir-function = #beam-dir-median
184 @node Slur attachments
185 @section Slur attachments
187 Override attachments...
188 @lilypond[fragment,relative,verbatim,center]
189 \property Voice.Slur \set #'direction = #1
190 \property Voice.Stem \set #'length = #5.5
193 \property Voice.Slur \set #'attachment = #'(stem . stem)
201 @c Ugh, ugh @multitable is broken in texinfo-4.0
203 @c We'll have to postpone this before/after representation until
204 @c jcn3 is rolled into texinfo...
206 @multitable @columnfractions .40 .40
209 @lilypond[fragment,relative,verbatim,center]
211 \set #'direction = #1
216 @lilypond[fragment,relative,verbatim,center]
218 \set #'direction = #1
222 \set #'attachment = #'(stem . stem)
230 @lilypond[fragment,relative,verbatim,center]
231 \property Voice.Slur \set #'direction = #1
232 \property Voice.Slur \set #'attachment = #'(head . head)
233 g''16()g()g()g()d'()d()d()d
237 Steep slur correct...
238 @lilypond[fragment,relative,verbatim,center]
239 \property Voice.Stem \set #'direction = #1
240 \property Voice.Slur \set #'direction = #1
242 \property Voice.Slur \set #'attachment = #'(stem . stem)
247 @lilypond[verbatim,center]
249 \notes \context PianoStaff <
251 \context Staff=up { s1 * 6/4 }
252 \context Staff=down <
254 \autochange Staff \context Voice
256 d,8( a' d f a d f d a f d )a
264 Slur \override #'beautiful = #5.0
265 Slur \override #'direction = #1
266 Stem \override #'direction = #-1
267 autoBeamSettings \override #'(end * * * *)
272 VerticalAlignment \override #'threshold = #'(5 . 5)
280 @section Text spanner
282 Have crescendo set a text spanner iso hairpin
283 @lilypond[fragment,relative,verbatim,center]
285 \property Voice.crescendoText = "cresc."
286 \property Voice.crescendoSpanner = #'dashed-line
293 @lilypond[fragment,relative,verbatim,center]
295 \property Voice.TextSpanner \set #'type = #'dotted-line
296 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
297 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
298 \property Staff.centralCPosition = #-13
299 a\spanrequest \start "text" b c a \spanrequest \stop "text"
304 @node Engraver hacking
305 @section Engraver hacking
307 No time signature, no barlines...
308 @lilypond[verbatim,center]
310 \notes \relative c'' {
319 \remove "Time_signature_engraver";
325 No staff, no clef, squash pitches
326 @lilypond[verbatim,center]
328 \notes { c4 c4 c8 c8 }
333 \remove Staff_symbol_engraver;
334 \consists Pitch_squash_engraver;
335 \remove Clef_engraver;
343 @section Part combiner
345 @lilypond[verbatim,center]
347 \context Staff = flauti <
349 \context Voice=one \partcombine Voice
350 \context Thread=one \notes\relative c'' {
351 c4 d e f | b,4 d c d | r2 e4 f | c4 d e f |
352 c4 r e f | c4 r e f | c4 r a r | a a r a |
353 a2 \property Voice.soloADue = ##f a |
355 \context Thread=two \notes\relative c'' {
356 g4 b d f | r2 c4 d | a c c d | a4. b8 c4 d
357 c r e r | r2 s2 | a,4 r a r | a r r a |
358 a2 \property Voice.soloADue = ##f a |
362 linewidth = 80 * \staffspace;
365 \consists Rest_engraver;
369 \remove Rest_engraver;
383 @lilypond[verbatim,center]
384 #(define note '(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
385 #(define eight-note `(rows ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3")))))
386 #(define dotted-eight-note `(rows ,eight-note (music "dots-dot")))
389 \notes\relative c'' {
390 a1^#`(rows ,dotted-eight-note " = 64")
396 TextScript \override #'font-shape = #'upright
403 @node Output property
404 @section Output property
406 @lilypond[fragment,relative,verbatim,center]
407 \outputproperty #(make-type-checker 'note-head-interface)
408 #'extra-offset = #'(2 . 3)
412 Don't move the finger 2, only text "m.d." ...
413 @lilypond[verbatim,center]
414 #(define (make-text-checker text)
415 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
418 \notes\relative c''' {
419 \property Voice.Stem \set #'direction = #1
420 \outputproperty #(make-text-checker "m.d.")
421 #'extra-offset = #'(-3.5 . -4.5)
424 \paper { linewidth = -1.; }
433 @section Apply hacking
435 @lilypond[verbatim,center]
436 music = \notes { c'4 d'4( e'4 f'4 }
438 #(define (reverse-music music)
439 (let* ((elements (ly-get-mus-property music 'elements))
440 (reversed (reverse elements))
441 (span-dir (ly-get-mus-property music 'span-direction)))
443 (ly-set-mus-property music 'elements reversed)
446 (ly-set-mus-property music 'span-direction (- span-dir)))
448 (map reverse-music reversed)
455 \apply #reverse-music \music
457 \paper { linewidth = -1.; }
462 LilyPond is more flexible than some users realise. Han-Wen could be
465 Just too funny not to include.
469 I've just entered a request on cosource.com :
471 http://www.cosource.com/cgi-bin/cos.pl/wish/info/387
473 Here's a copy of my feature request :
475 Your task, if you accept it is to implement a \smarttranspose
476 command> that would translate such oddities into more natural
477 notations. Double accidentals should be removed, as well as #E
478 (-> F), bC (-> B), bF (-> E), #B (-> C).
481 You mean like this. (Sorry 'bout the nuked indentation.)
483 Add IMPLEMENT_TYPE_P(Music, "music?"); to music.cc, and presto, done.
485 That's an easy $ 100; if I'd make $ 200/hour for every hour I worked
486 on Lily, I'd be very rich :)
490 @lilypond[verbatim,center]
491 #(define (unhair-pitch p)
492 (let* ((o (pitch-octave p))
493 (a (pitch-alteration p))
494 (n (pitch-notename p)))
497 ((and (> a 0) (or (eq? n 6) (eq? n 2)))
498 (set! a (- a 1)) (set! n (+ n 1)))
499 ((and (< a 0) (or (eq? n 0) (eq? n 3)))
500 (set! a (+ a 1)) (set! n (- n 1))))
503 ((eq? a 2) (set! a 0) (set! n (+ n 1)))
504 ((eq? a -2) (set! a 0) (set! n (- n 1))))
506 (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
507 (if (> n 7) (begin (set! o (+ o 1)) (set! n (- n 7))))
511 #(define (smart-transpose music pitch)
512 (let* ((es (ly-get-mus-property music 'elements))
513 (e (ly-get-mus-property music 'element))
514 (p (ly-get-mus-property music 'pitch))
515 (body (ly-get-mus-property music 'body))
516 (alts (ly-get-mus-property music 'alternatives)))
521 (map (lambda (x) (smart-transpose x pitch)) es)))
526 (smart-transpose alts pitch)))
531 (smart-transpose body pitch)))
536 (smart-transpose e pitch)))
540 (set! p (unhair-pitch (Pitch::transpose p pitch)))
541 (ly-set-mus-property music 'pitch p)))
546 music = \notes \relative c' { c4 d e f g a b c }
549 \notes \context Staff {
550 \transpose ais' \music
551 \apply #(lambda (x) (smart-transpose x (make-pitch 0 5 1)))
554 \paper { linewidth = -1.; }
560 @section Embedded TeX
561 @lilypond[fragment,relative,verbatim,center]
562 a''^"3 $\\times$ \\`a deux"
565 @node Embedded PostScript
566 @section Embedded PostScript
568 Arbitrary lines and curves not supported...
570 [TODO:] Make a direct postscript command?
572 @lilypond[verbatim,center]
574 \notes \relative c'' {
575 a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
576 -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
577 b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
581 \paper { linewidth = 70 * \staffspace; }