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
13 there's a very simple, very general noXXX mechanism; try
15 noop \property Staff.VoltaBrace = #'()
16 yes: \property Staff.VoltaBracket = #'((meta . ((interfaces . ()))))
24 @macro keyindex {word}
29 @macro indexcode {word}
41 * Glissando:: Glissando
42 * Manual beam settings:: Manual beam settings
43 * Slur attachments:: Slur attachments
44 * Text spanner:: Text spanner
45 * Engraver hacking:: Engraver hacking
46 * Part combiner:: Part combiner
47 * Markup text:: Markup text
48 * Apply hacking:: Apply hacking
49 * Output property:: Output property
50 * Embedded TeX:: Embedded TeX
51 * Embedded PostScript:: Embedded PostScript
52 * Index:: Checking Feature index
59 @cindex broken arpeggio
60 @c @cindex ``doorlopend'' argpeggio
62 You can specify an arpeggio sign on a chord by issuing an
64 @c @code{\arpeggio}@indexcode{\arpeggio} request:
65 @code{\arpeggio} request:
66 @cindex @code{\arpeggio}
69 @lilypond[fragment,relative,verbatim]
70 \context Voice <c'\arpeggio e g c>
74 Typesetting of simultanious chords with arpeggios can be controlled with
75 the property @code{PianoStaff.connectArpeggios} @footnote{ FIXME:
76 connectArpeggios. Can't find the English terms for two kinds of
77 arpeggio (Dutch: gebroken arpeggio vs doorlopend arpeggio).} By
78 default, LilyPond prints broken arpeggios; when set to true, one
79 extended arpeggio sign is printed.
82 @lilypond[fragment,relative,verbatim]
84 \property PianoStaff.connectArpeggios = ##t
85 \context Staff \context Voice <c''\arpeggio e g c>
86 \context Staff=other \context Voice <c,\arpeggio e g>
95 A glissando line can be requested by issuing a
97 @c @code{\glissando}@indexcode{\glissando} request:
98 @code{\glissando} request:
99 @cindex @code{\glissando}
103 @lilypond[fragment,relative,verbatim]
108 Printing of the additional text @code{"gliss."} is currently not
112 @subsection Follow Thread
113 @cindex follow thread
114 @cindex staff switching
117 @c Documented here because it looks like a glissando.
118 A glissando-like line can be printed to connect notes whenever a thread
119 switches to another staff. This is enabled if the property
120 @code{PianoStaff.followThread}@indexcode{followThread} is set to true:
123 @lilypond[fragment,relative,verbatim]
124 \context PianoStaff <
125 \property PianoStaff.followThread = ##t
126 \context Staff \context Voice {
128 \translator Staff=two
131 \context Staff=two {\clef bass; \skip 1*2;}
136 @node Manual beam settings
137 @section Manual beam settings
139 @cindex beam settings
142 In some cases it may be necessary to override LilyPond's automatic
143 beaming algorithm. For example, the auto beamer will not beam over
144 rests, so if you want that, specify the begin and end point manually
145 using @code{[}@indexcode{[} and @code{]}@indexcode{]}:
148 @lilypond[fragment,relative,verbatim]
155 Similarly, for beams over bar lines:
158 @lilypond[fragment,relative,verbatim]
165 If you have specific wishes for the number of beams, you can fully
166 control the number of beams through the properties
167 @code{Voice.stemLeftBeamCount}@indexcode{stemLeftBeamCount};
170 @lilypond[fragment,relative,verbatim]
173 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
178 and @code{Voice.stemRightBeamCount}@indexcode{stemRightBeamCount}:
181 @lilypond[fragment,relative,verbatim]
184 \property Voice.autoBeamSettings
185 \set #'(end * * * *) = #(make-moment 1 4)
189 \property Voice.stemRightBeamCount = #1 b
190 \property Voice.stemLeftBeamCount = #1 b
195 Conventionally, stems extend to the middle staff line, and thus so do
196 beams. The extending of the stems can be controlled through
197 @code{Voice.Stem}'s grob-property
198 @code{no-stem-extend}@indexcode{no-stem-extend}:
201 @lilypond[fragment,relative,verbatim]
203 \property Voice.Stem \set #'no-stem-extend = ##t
208 The beam symbol can be tweaked through @code{Voice.Beam}'s
209 grob-properties @code{height-hs} and @code{y-position-hs}.
211 Set @code{height-hs} to zero, to get horizontal beams:
214 @lilypond[fragment,relative,verbatim]
215 \property Voice.Beam \set #'direction = #1
216 \property Voice.Beam \set #'height-hs = #0
221 Both are in half spaces. Here's how you'd specify a weird looking beam
222 that instead of beaing horizontal, falls two staff spaces (ie, four half
226 @lilypond[fragment,relative,verbatim]
227 \property Voice.Beam \set #'y-position-hs = #4
228 \property Voice.Beam \set #'height-hs = #-4
233 The direction of a perfectly centred beams can be
234 controlled through @code{Voice.Beam}'s grob-property
235 @code{default-neutral-direction}@indexcode{default-neutral-direction}
238 @lilypond[fragment,relative,verbatim]
240 \property Voice.Beam \set #'default-neutral-direction = #-1
245 There are several ways to calculate the direction of a beam.
247 [Ross] states that the majority of the notes dictates the
248 direction (and not the mean of "center distance")
250 But is that because it really looks better, or because he wants
251 to provide some real simple hands-on rules?
253 We have our doubts, so we simply provide all sensible alternatives:
257 number count of up or down notes
259 mean centre distance of all notes
261 mean centre distance weighted per note
264 You can spot the differences of these settings from these simple
268 @lilypond[fragment,relative,verbatim]
270 \property Voice.Beam \set #'dir-function = #beam-dir-mean
272 \property Voice.Beam \set #'dir-function = #beam-dir-median
278 @lilypond[fragment,relative,verbatim]
281 \property Voice.Beam \set #'dir-function = #beam-dir-mean
283 \property Voice.Beam \set #'dir-function = #beam-dir-median
288 These beam direction functions are defined in @file{scm/beam.scm}. If
289 your favourite algorithm isn't one of these, you can hook up your own.
293 @node Slur attachments
294 @section Slur attachments
296 The ending of a slur should whenever possible be attached to a note
297 head. Only in some instances where beams are involved, LilyPond may
298 attach a slur to a stem end. In some cases, you may want to override
299 LilyPond's decision, eg to attach the slur to the stem end. This can be
300 done through @code{Voice.Slur}'s grob-property @code{attachment}:
301 @c FIXME: make @ref{} to backend doco
304 @lilypond[fragment,relative,verbatim]
305 \property Voice.Slur \set #'direction = #1
306 \property Voice.Stem \set #'length = #5.5
309 \property Voice.Slur \set #'attachment = #'(stem . stem)
315 Trying Before | After example...
316 @c Fix rolled into 4.0a prerelease
318 @multitable @columnfractions .40 .40
321 @lilypond[fragment,relative,verbatim]
323 \set #'direction = #1
328 @lilypond[fragment,relative,verbatim]
330 \set #'direction = #1
334 \set #'attachment = #'(stem . stem)
341 Similarly, slurs can be attached to note heads even when beams are
342 involved (aka Ophee slurs):
345 @lilypond[fragment,relative,verbatim]
346 \property Voice.Slur \set #'direction = #1
347 \property Voice.Slur \set #'attachment = #'(head . head)
348 g''16()g()g()g()d'()d()d()d
352 If a slur would strike through a stem or beam, LilyPond will move the
353 slur away vertically (upward or downward). In some cases, this may
354 cause ugly slurs that you may want to correct:
357 @lilypond[fragment,relative,verbatim]
358 \property Voice.Stem \set #'direction = #1
359 \property Voice.Slur \set #'direction = #1
361 \property Voice.Slur \set #'attachment = #'(stem . stem)
366 LilyPond will increase the curvature of a slur trying to stay free of
367 note heads and stems. However, if the curvature would increase too much,
368 the slur will be reverted to its default shape. This decision is based
369 on @code{Voice.Slur}'s grob-property @code{beautiful} value. In some
370 cases, you may find ugly slurs beautiful, and tell LilyPond so by
371 increasing the @code{beautiful} value:
376 \notes \context PianoStaff <
378 \context Staff=up { s1 * 6/4 }
379 \context Staff=down <
381 \autochange Staff \context Voice
383 d,8( a' d f a d f d a f d )a
391 Slur \override #'beautiful = #5.0
392 Slur \override #'direction = #1
393 Stem \override #'direction = #-1
394 autoBeamSettings \override #'(end * * * *)
399 VerticalAlignment \override #'threshold = #'(5 . 5)
408 @section Text spanner
410 Have crescendo set a text spanner iso hairpin
411 @lilypond[fragment,relative,verbatim]
413 \property Voice.crescendoText = "cresc."
414 \property Voice.crescendoSpanner = #'dashed-line
421 @lilypond[fragment,relative,verbatim]
423 \property Voice.TextSpanner \set #'type = #'dotted-line
424 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
425 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
426 \property Staff.centralCPosition = #-13
427 a\spanrequest \start "text" b c a \spanrequest \stop "text"
432 @node Engraver hacking
433 @section Engraver hacking
435 No time signature, no barlines...
438 \notes \relative c'' {
447 \remove "Time_signature_engraver";
453 No staff, no clef, squash pitches
456 \notes { c4 c4 c8 c8 }
461 \remove Staff_symbol_engraver;
462 \consists Pitch_squash_engraver;
463 \remove Clef_engraver;
471 @section Part combiner
475 \context Staff = flauti <
477 \context Voice=one \partcombine Voice
478 \context Thread=one \notes\relative c'' {
479 c4 d e f | b,4 d c d | r2 e4 f | c4 d e f |
480 c4 r e f | c4 r e f | c4 r a r | a a r a |
481 a2 \property Voice.soloADue = ##f a |
483 \context Thread=two \notes\relative c'' {
484 g4 b d f | r2 c4 d | a c c d | a4. b8 c4 d
485 c r e r | r2 s2 | a,4 r a r | a r r a |
486 a2 \property Voice.soloADue = ##f a |
490 linewidth = 80 * \staffspace;
493 \consists Rest_engraver;
497 \remove Rest_engraver;
514 #(define note '(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
515 #(define eight-note `(rows ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3")))))
516 #(define dotted-eight-note `(rows ,eight-note (music "dots-dot")))
519 \notes\relative c'' {
520 a1^#`(rows ,dotted-eight-note " = 64")
526 TextScript \override #'font-shape = #'upright
533 @node Output property
534 @section Output property
536 @lilypond[fragment,relative,verbatim]
537 \outputproperty #(make-type-checker 'note-head-interface)
538 #'extra-offset = #'(2 . 3)
542 Don't move the finger 2, only text "m.d." ...
544 #(define (make-text-checker text)
545 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
548 \notes\relative c''' {
549 \property Voice.Stem \set #'direction = #1
550 \outputproperty #(make-text-checker "m.d.")
551 #'extra-offset = #'(-3.5 . -4.5)
554 \paper { linewidth = -1.; }
563 @section Apply hacking
566 music = \notes { c'4 d'4( e'4 f'4 }
568 #(define (reverse-music music)
569 (let* ((elements (ly-get-mus-property music 'elements))
570 (reversed (reverse elements))
571 (span-dir (ly-get-mus-property music 'span-direction)))
573 (ly-set-mus-property music 'elements reversed)
576 (ly-set-mus-property music 'span-direction (- span-dir)))
578 (map reverse-music reversed)
585 \apply #reverse-music \music
587 \paper { linewidth = -1.; }
592 LilyPond is more flexible than some users realise. Han-Wen could be
595 Just too funny not to include.
599 I've just entered a request on cosource.com :
601 http://www.cosource.com/cgi-bin/cos.pl/wish/info/387
603 Here's a copy of my feature request :
605 Your task, if you accept it is to implement a \smarttranspose
606 command> that would translate such oddities into more natural
607 notations. Double accidentals should be removed, as well as #E
608 (-> F), bC (-> B), bF (-> E), #B (-> C).
611 You mean like this. (Sorry 'bout the nuked indentation.)
613 Add IMPLEMENT_TYPE_P(Music, "music?"); to music.cc, and presto, done.
615 That's an easy $ 100; if I'd make $ 200/hour for every hour I worked
616 on Lily, I'd be very rich :)
621 #(define (unhair-pitch p)
622 (let* ((o (pitch-octave p))
623 (a (pitch-alteration p))
624 (n (pitch-notename p)))
627 ((and (> a 0) (or (eq? n 6) (eq? n 2)))
628 (set! a (- a 1)) (set! n (+ n 1)))
629 ((and (< a 0) (or (eq? n 0) (eq? n 3)))
630 (set! a (+ a 1)) (set! n (- n 1))))
633 ((eq? a 2) (set! a 0) (set! n (+ n 1)))
634 ((eq? a -2) (set! a 0) (set! n (- n 1))))
636 (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
637 (if (> n 7) (begin (set! o (+ o 1)) (set! n (- n 7))))
641 #(define (smart-transpose music pitch)
642 (let* ((es (ly-get-mus-property music 'elements))
643 (e (ly-get-mus-property music 'element))
644 (p (ly-get-mus-property music 'pitch))
645 (body (ly-get-mus-property music 'body))
646 (alts (ly-get-mus-property music 'alternatives)))
651 (map (lambda (x) (smart-transpose x pitch)) es)))
656 (smart-transpose alts pitch)))
661 (smart-transpose body pitch)))
666 (smart-transpose e pitch)))
670 (set! p (unhair-pitch (Pitch::transpose p pitch)))
671 (ly-set-mus-property music 'pitch p)))
676 music = \notes \relative c' { c4 d e f g a b c }
679 \notes \context Staff {
680 \transpose ais' \music
681 \apply #(lambda (x) (smart-transpose x (make-pitch 0 5 1)))
684 \paper { linewidth = -1.; }
690 @section Embedded TeX
691 @lilypond[fragment,relative,verbatim]
692 a''^"3 $\\times$ \\`a deux"
695 @node Embedded PostScript
696 @section Embedded PostScript
698 Arbitrary lines and curves not supported...
700 [TODO:] Make a direct postscript command?
704 \notes \relative c'' {
705 a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
706 -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
707 b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
711 \paper { linewidth = 70 * \staffspace; }
717 @section Checking Feature index