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 . ()))))
31 * Glissando:: Glissando
32 * Manual beam settings:: Manual beam settings
33 * Slur attachments:: Slur attachments
34 * Text spanner:: Text spanner
35 * Engraver hacking:: Engraver hacking
36 * Part combiner:: Part combiner
37 * Markup text:: Markup text
38 * Apply hacking:: Apply hacking
39 * Output property:: Output property
40 * Embedded TeX:: Embedded TeX
41 * Embedded PostScript:: Embedded PostScript
46 @lilypond[fragment,relative,verbatim,center]
54 @lilypond[fragment,relative,verbatim,center]
55 \context Voice <c'\arpeggio e g c>
58 @lilypond[fragment,relative,verbatim,center]
60 \property PianoStaff.connectArpeggios = ##t
61 \context Staff \context Voice <c''\arpeggio e g c>
62 \context Staff=other \context Voice <c,\arpeggio e g>
71 @lilypond[fragment,relative,verbatim,center]
75 @subsection Follow Thread
76 @lilypond[fragment,relative,verbatim,center]
78 \property PianoStaff.followThread = ##t
79 \context Staff \context Voice {
84 \context Staff=two {\clef bass; \skip 1*2;}
88 @node Manual beam settings
89 @section Manual beam settings
94 @lilypond[fragment,relative,verbatim,center]
101 Control number of beams...
103 @lilypond[fragment,relative,verbatim,center]
106 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
110 @lilypond[fragment,relative,verbatim,center]
113 \property Voice.autoBeamSettings
114 \set #'(end * * * *) = #(make-moment 1 4)
118 \property Voice.stemRightBeamCount = #1 b
119 \property Voice.stemLeftBeamCount = #1 b
123 Don't extend to middle line esp. for grace
125 @lilypond[fragment,relative,verbatim,center]
127 \property Voice.Stem \set #'no-stem-extend = ##t
135 @lilypond[fragment,relative,verbatim,center]
136 \property Voice.Beam \set #'direction = #1
137 \property Voice.Beam \set #'height-hs = #0
141 beam start-y beam-height
144 @lilypond[fragment,relative,verbatim,center]
145 \property Voice.Beam \set #'y-position-hs = #4
146 \property Voice.Beam \set #'height-hs = #-4
153 @lilypond[fragment,relative,verbatim,center]
155 \property Voice.Beam \set #'default-neutral-direction = #-1
159 There are several ways to calculate the direction of a beam.
161 [Ross] states that the majority of the notes dictates the
162 direction (and not the mean of "center distance")
164 But is that because it really looks better, or because he wants
165 to provide some real simple hands-on rules?
167 We have our doubts, so we simply provide all sensible alternatives:
171 number count of up or down notes
173 mean centre distance of all notes
175 mean centre distance weighted per note
178 You can spot the difference of these settings quite easily from these simple examples:
180 @lilypond[fragment,relative,verbatim,center]
182 \property Voice.Beam \set #'dir-function = #beam-dir-mean
184 \property Voice.Beam \set #'dir-function = #beam-dir-median
188 @lilypond[fragment,relative,verbatim,center]
191 \property Voice.Beam \set #'dir-function = #beam-dir-mean
193 \property Voice.Beam \set #'dir-function = #beam-dir-median
198 @node Slur attachments
199 @section Slur attachments
201 Override attachments...
202 @lilypond[fragment,relative,verbatim,center]
203 \property Voice.Slur \set #'direction = #1
204 \property Voice.Stem \set #'length = #5.5
207 \property Voice.Slur \set #'attachment = #'(stem . stem)
215 @c Ugh, ugh @multitable is broken in texinfo-4.0
217 @c We'll have to postpone this before/after representation until
218 @c jcn3 is rolled into texinfo...
220 @multitable @columnfractions .40 .40
223 @lilypond[fragment,relative,verbatim,center]
225 \set #'direction = #1
230 @lilypond[fragment,relative,verbatim,center]
232 \set #'direction = #1
236 \set #'attachment = #'(stem . stem)
244 @lilypond[fragment,relative,verbatim,center]
245 \property Voice.Slur \set #'direction = #1
246 \property Voice.Slur \set #'attachment = #'(head . head)
247 g''16()g()g()g()d'()d()d()d
251 Steep slur correct...
252 @lilypond[fragment,relative,verbatim,center]
253 \property Voice.Stem \set #'direction = #1
254 \property Voice.Slur \set #'direction = #1
256 \property Voice.Slur \set #'attachment = #'(stem . stem)
261 @lilypond[verbatim,center]
263 \notes \context PianoStaff <
265 \context Staff=up { s1 * 6/4 }
266 \context Staff=down <
268 \autochange Staff \context Voice
270 d,8( a' d f a d f d a f d )a
278 Slur \override #'beautiful = #5.0
279 Slur \override #'direction = #1
280 Stem \override #'direction = #-1
281 autoBeamSettings \override #'(end * * * *)
286 VerticalAlignment \override #'threshold = #'(5 . 5)
294 @section Text spanner
296 Have crescendo set a text spanner iso hairpin
297 @lilypond[fragment,relative,verbatim,center]
299 \property Voice.crescendoText = "cresc."
300 \property Voice.crescendoSpanner = #'dashed-line
307 @lilypond[fragment,relative,verbatim,center]
309 \property Voice.TextSpanner \set #'type = #'dotted-line
310 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
311 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
312 \property Staff.centralCPosition = #-13
313 a\spanrequest \start "text" b c a \spanrequest \stop "text"
318 @node Engraver hacking
319 @section Engraver hacking
321 No time signature, no barlines...
322 @lilypond[verbatim,center]
324 \notes \relative c'' {
333 \remove "Time_signature_engraver";
339 No staff, no clef, squash pitches
340 @lilypond[verbatim,center]
342 \notes { c4 c4 c8 c8 }
347 \remove Staff_symbol_engraver;
348 \consists Pitch_squash_engraver;
349 \remove Clef_engraver;
357 @section Part combiner
359 @lilypond[verbatim,center]
361 \context Staff = flauti <
363 \context Voice=one \partcombine Voice
364 \context Thread=one \notes\relative c'' {
365 c4 d e f | b,4 d c d | r2 e4 f | c4 d e f |
366 c4 r e f | c4 r e f | c4 r a r | a a r a |
367 a2 \property Voice.soloADue = ##f a |
369 \context Thread=two \notes\relative c'' {
370 g4 b d f | r2 c4 d | a c c d | a4. b8 c4 d
371 c r e r | r2 s2 | a,4 r a r | a r r a |
372 a2 \property Voice.soloADue = ##f a |
376 linewidth = 80 * \staffspace;
379 \consists Rest_engraver;
383 \remove Rest_engraver;
397 @lilypond[verbatim,center]
398 #(define note '(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
399 #(define eight-note `(rows ,note ((kern . -0.1) (music ((raise . 3.5) "flags-u3")))))
400 #(define dotted-eight-note `(rows ,eight-note (music "dots-dot")))
403 \notes\relative c'' {
404 a1^#`(rows ,dotted-eight-note " = 64")
410 TextScript \override #'font-shape = #'upright
417 @node Output property
418 @section Output property
420 @lilypond[fragment,relative,verbatim,center]
421 \outputproperty #(make-type-checker 'note-head-interface)
422 #'extra-offset = #'(2 . 3)
426 Don't move the finger 2, only text "m.d." ...
427 @lilypond[verbatim,center]
428 #(define (make-text-checker text)
429 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
432 \notes\relative c''' {
433 \property Voice.Stem \set #'direction = #1
434 \outputproperty #(make-text-checker "m.d.")
435 #'extra-offset = #'(-3.5 . -4.5)
438 \paper { linewidth = -1.; }
447 @section Apply hacking
449 @lilypond[verbatim,center]
450 music = \notes { c'4 d'4( e'4 f'4 }
452 #(define (reverse-music music)
453 (let* ((elements (ly-get-mus-property music 'elements))
454 (reversed (reverse elements))
455 (span-dir (ly-get-mus-property music 'span-direction)))
457 (ly-set-mus-property music 'elements reversed)
460 (ly-set-mus-property music 'span-direction (- span-dir)))
462 (map reverse-music reversed)
469 \apply #reverse-music \music
471 \paper { linewidth = -1.; }
476 LilyPond is more flexible than some users realise. Han-Wen could be
479 Just too funny not to include.
483 I've just entered a request on cosource.com :
485 http://www.cosource.com/cgi-bin/cos.pl/wish/info/387
487 Here's a copy of my feature request :
489 Your task, if you accept it is to implement a \smarttranspose
490 command> that would translate such oddities into more natural
491 notations. Double accidentals should be removed, as well as #E
492 (-> F), bC (-> B), bF (-> E), #B (-> C).
495 You mean like this. (Sorry 'bout the nuked indentation.)
497 Add IMPLEMENT_TYPE_P(Music, "music?"); to music.cc, and presto, done.
499 That's an easy $ 100; if I'd make $ 200/hour for every hour I worked
500 on Lily, I'd be very rich :)
504 @lilypond[verbatim,center]
505 #(define (unhair-pitch p)
506 (let* ((o (pitch-octave p))
507 (a (pitch-alteration p))
508 (n (pitch-notename p)))
511 ((and (> a 0) (or (eq? n 6) (eq? n 2)))
512 (set! a (- a 1)) (set! n (+ n 1)))
513 ((and (< a 0) (or (eq? n 0) (eq? n 3)))
514 (set! a (+ a 1)) (set! n (- n 1))))
517 ((eq? a 2) (set! a 0) (set! n (+ n 1)))
518 ((eq? a -2) (set! a 0) (set! n (- n 1))))
520 (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
521 (if (> n 7) (begin (set! o (+ o 1)) (set! n (- n 7))))
525 #(define (smart-transpose music pitch)
526 (let* ((es (ly-get-mus-property music 'elements))
527 (e (ly-get-mus-property music 'element))
528 (p (ly-get-mus-property music 'pitch))
529 (body (ly-get-mus-property music 'body))
530 (alts (ly-get-mus-property music 'alternatives)))
535 (map (lambda (x) (smart-transpose x pitch)) es)))
540 (smart-transpose alts pitch)))
545 (smart-transpose body pitch)))
550 (smart-transpose e pitch)))
554 (set! p (unhair-pitch (Pitch::transpose p pitch)))
555 (ly-set-mus-property music 'pitch p)))
560 music = \notes \relative c' { c4 d e f g a b c }
563 \notes \context Staff {
564 \transpose ais' \music
565 \apply #(lambda (x) (smart-transpose x (make-pitch 0 5 1)))
568 \paper { linewidth = -1.; }
574 @section Embedded TeX
575 @lilypond[fragment,relative,verbatim,center]
576 a''^"3 $\\times$ \\`a deux"
579 @node Embedded PostScript
580 @section Embedded PostScript
582 Arbitrary lines and curves not supported...
584 [TODO:] Make a direct postscript command?
586 @lilypond[verbatim,center]
588 \notes \relative c'' {
589 a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
590 -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
591 b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
595 \paper { linewidth = 70 * \staffspace; }