]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
* Documentation/user/macros.itexi: @inputfileref macro.
[lilypond.git] / Documentation / user / refman.itely
1 @c Note: -*-texinfo-*-
2 @c
3 @c A menu is needed before every deeper *section nesting of @node's; run
4 @c     M-x texinfo-all-menus-update
5 @c to automagically fill in these menus before saving changes
6
7 @c FIXME: singular vs. plural:  Beams/Beam
8
9
10 @macro refbugs
11 @strong{BUGS}
12 @end macro
13
14
15
16
17 @c .{Reference Manual}
18
19 @node Reference Manual
20 @chapter Reference Manual
21
22 @html
23 <!--- @@WEB-TITLE@@=Reference Manual --->
24 @end html
25
26
27 This document describes GNU LilyPond and its input format. The last
28 revision of this document was made for LilyPond 1.7.10.  It assumes
29 that you already know a little bit about LilyPond input (how to
30 make an input file, how to create sheet music from that input file,
31 etc).  New users are encouraged to study the tutorial before reading
32 this manual.
33
34
35 @menu
36 * Note entry::                  
37 * Easier music entry::          
38 * Staff notation::              
39 * Polyphony::                   
40 * Beaming::                     
41 * Accidentals::                 
42 * Expressive marks::            
43 * Ornaments::                   
44 * Repeats::                     
45 * Rhythmic music::              
46 * Piano music::                 
47 * Vocal music::                 
48 * Tablatures::                  
49 * Chords::                      
50 * Writing parts::               
51 * Ancient notation::           
52 * Contemporary notation::      
53 * Tuning output::               
54 * Global layout::               
55 * Sound::                       
56 @end menu
57
58 @c FIXME: Note entry vs Music entry at top level menu is confusing.
59 @c . {Note entry}
60 @node Note entry
61 @section Note entry
62 @cindex Note entry
63
64 Notes constitute the most basic elements of LilyPond input, but they do
65 not form valid input on their own without a @code{\score} block.  However,
66 for the sake of brevity and simplicity we will generally omit
67 @code{\score} blocks and @code{\paper} declarations in this manual.
68
69
70 @menu
71 * Notes::                       
72 * Pitches::                     
73 * Chromatic alterations::       
74 * Rests::                       
75 * Skips::                       
76 * Durations::                   
77 * Ties::                        
78 * Automatic note splitting ::   
79 * Tuplets::                     
80 * Easy Notation note heads ::   
81 @end menu
82
83 @c . {Notes}
84 @node Notes
85 @subsection Notes
86
87
88 A note is printed by specifying its pitch and then its duration.
89 @lilypond[fragment,verbatim]
90   cis'4 d'8 e'16 c'16
91 @end lilypond
92
93 @c .  {Pitches}
94 @node Pitches
95 @subsection Pitches
96
97 @cindex Pitch names
98 @cindex Note specification
99 @cindex pitches
100 @cindex entering notes
101
102 The verbose syntax for pitch specification is
103
104 @cindex @code{\pitch}
105 @example
106   \pitch @var{scmpitch}
107 @end example
108
109 where @var{scmpitch} is a pitch scheme object.
110
111 In Note and Chord mode, pitches may be designated by names.  The default
112 names are the Dutch note names.  The notes are specified by the letters
113 @code{a} through @code{g}, while the octave is formed with notes ranging
114 from @code{c} to @code{b}.  The pitch @code{c} is an octave below
115 middle C and the letters span the octave above that C.  Here's an example
116 which should make things more clear:
117
118 @lilypond[fragment,verbatim]
119 \clef bass
120   a,4 b, c d e f g a b c' d' e' \clef treble f' g' a' b' c''
121 @end lilypond
122
123 @cindex note names, Dutch
124
125 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
126 name and a flat is formed by adding @code{-es}.  Double sharps and double
127 flats are obtained by adding @code{-isis} or @code{-eses}.  @code{aes}
128 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
129 both forms are accepted.
130
131 LilyPond has predefined sets of note names for various other languages.
132 To use them, simply include the language specific init file.  For
133 example: @code{\include "english.ly"}.  The available language files and
134 the note names they define are:
135
136 @anchor{note name}
137 @anchor{note names}
138 @example 
139                         Note Names               sharp       flat
140 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
141 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
142 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
143 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
144 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
145 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
146 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b 
147 espanol.ly     do  re  mi  fa  sol la  sib si  -s          -b 
148
149 @end example 
150
151 @cindex @code{'}
152 @cindex @code{,}
153
154
155
156 The optional octave specification takes the form of a series of
157 single quote (`@code{'}') characters or a series of comma
158 (`@code{,}') characters.  Each @code{'} raises the pitch by one
159 octave; each @code{,} lowers the pitch by an octave.
160
161 @lilypond[fragment,verbatim,center]
162   c' c'' es' g' as' gisis' ais'  
163 @end lilypond
164
165 @node Chromatic alterations
166 @subsection Chromatic alterations
167
168 Normally accidentals are printed automatically, but you may also
169 print them manually.  A reminder accidental
170 @cindex reminder accidental
171 @cindex @code{?}
172 can be forced by adding an exclamation mark @code{!}
173 after the pitch.  A cautionary accidental
174 @cindex cautionary accidental
175 @cindex parenthesized accidental
176 (an accidental within parentheses) can be obtained by adding the
177 question mark `@code{?}' after the pitch.
178
179 @lilypond[fragment,verbatim]
180   cis' cis' cis'! cis'?
181 @end lilypond
182
183
184 The automatic production of accidentals can be tuned in many
185 ways. For more information, refer to @ref{Accidentals}.
186
187 @c .  {Rests}
188 @node  Rests
189 @subsection Rests
190 @cindex Rests
191
192 Rests are entered like notes, with a ``note name'' of `@code{r}':
193
194 @lilypond[singleline,verbatim]
195 r1 r2 r4 r8
196 @end lilypond
197
198 Whole bar rests, centered in middle of the bar, are specified using
199 @code{R} (capital R); see @ref{Multi measure rests}.  See also
200 @seeinternals{Rest}.
201
202 For some music, you may wish to explicitly specify the rest's vertical
203 position.  This can be achieved by entering a note with the @code{\rest}
204 keyword appended. Rest collision testing will leave these rests alone.
205
206 @lilypond[singleline,verbatim]
207 a'4\rest d'4\rest
208 @end lilypond
209
210
211 @c .  {Skips}
212 @c FIXME: naming.
213 @node Skips
214 @subsection Skips
215 @cindex Skip
216 @cindex Invisible rest
217 @cindex Space note
218
219 An invisible rest (also called a `skip') can be entered like a note
220 with note name `@code{s}' or with @code{\skip @var{duration}}:
221
222 @lilypond[singleline,verbatim]
223 a2 s4 a4 \skip 1 a4 
224 @end lilypond
225
226 @c FIXME: in Lyrics mode, we have " " and _
227
228 In Lyrics mode, you can make invisible syllables by entering `@code{" "}' 
229 or `@code{_}':
230 @lilypond[singleline,verbatim,quote]
231 <
232   \context Lyrics \lyrics { lah2 di4 " " dah2 _4 di }
233   \notes\relative c'' { a2 a4 a a2 a4 a }
234 >
235 @end lilypond
236 In this case, syllables containing a space will be printed. In the
237 case that you really need an invisible space (i.e. something taking up
238 time, but not space), you should use @code{\skip}.
239
240 Note that the @code{s} syntax is only available in Note mode and Chord
241 mode.  In other situations, you should use the @code{\skip} command,
242 which will work outside of those two modes:
243
244 @lilypond[singleline,verbatim]
245 \score {
246   \context Staff <
247     { \time 4/8 \skip 2 \time 4/4 } 
248     \notes\relative c'' { a2 a1 }
249   >
250 }
251 @end lilypond
252
253 The skip command is merely an empty musical placeholder.  It doesn't
254 produce any output, not even transparent output.
255
256
257
258 @c .  {Durations}
259 @node Durations
260 @subsection Durations
261
262
263 @cindex duration
264 @cindex @code{\duration}
265
266
267 In Note, Chord, and Lyrics mode, durations are designated by numbers
268 and dots: durations are entered as their reciprocal values.  For example,
269 a quarter note is entered using a @code{4} (since it's a 1/4 note), while
270 a half note is entered using a @code{2} (since it's a 1/2 note).  For notes
271 longer than a whole you must use identifiers.
272 @c FIXME: what's an identifier?  I don't think it's been introduced yet.
273 @c and if it has, I obviously skipped that part.     - Graham
274
275 @example 
276 c'\breve  
277 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 
278 r\longa r\breve  
279 r1 r2 r4 r8 r16 r32 r64 r64 
280 @end example 
281
282 @lilypond[noindent]
283 \score {
284   \notes \relative c'' {
285     a\breve  \autoBeamOff
286     a1 a2 a4 a8 a16 a32 a64 a64 
287     r\longa r\breve  
288     r1 r2 r4 r8 r16 r32 r64 r64 
289   }
290   \paper {
291     \translator {
292       \StaffContext
293         \remove "Clef_engraver"
294         \remove "Staff_symbol_engraver"
295         \remove "Time_signature_engraver"
296         \consists "Pitch_squash_engraver"
297     }
298   }
299 }
300 @end lilypond
301
302
303 If the duration is omitted then it is set to the previously entered
304 duration.  At the start of parsing, a quarter note is assumed.  The
305 duration can be followed by dots (`@code{.}') in order to obtain dotted
306 note lengths:
307 @cindex @code{.}
308
309 @lilypond[fragment,verbatim,center]
310   a' b' c''8 b' a'4 a'4. b'4.. c'8.
311 @end lilypond
312 @cindex @code{r}
313 @cindex @code{s}
314
315 You can alter the length of duration by a fraction @var{N/M}
316 appending `@code{*}@var{N/M}' (or `@code{*}@var{N}' if @var{M=1}). This
317 won't affect the appearance of the notes or rests produced.
318
319 @lilypond[fragment,verbatim]
320   a'2*2 b'4*2 a'8*4 a'4*3/2 gis'4*3/2 a'4*3/2 a'4
321 @end lilypond
322
323 Durations can also be produced through GUILE extension mechanism. 
324 @lilypond[verbatim,fragment]
325  c'\duration #(ly:make-duration 2 1)
326 @end lilypond
327
328
329 @refbugs
330
331 Dot placement for chords is not perfect.  In some cases, dots overlap:
332 @lilypond[]
333  <<f, c'' d e f>>4.
334 @end lilypond
335
336
337 @node Ties
338 @subsection Ties
339
340 @cindex Tie
341 @cindex ties
342 @cindex @code{~}
343
344 A tie connects two adjacent note heads of the same pitch.  The tie in
345 effect extends the length of a note.  Ties should not be confused with
346 slurs, which indicate articulation, or phrasing slurs, which indicate
347 musical phrasing.  A tie is entered using the tilde symbol `@code{~}'.
348
349 @lilypond[fragment,verbatim,center]
350   e' ~ e' <<c' e' g'>> ~ <<c' e' g'>>
351 @end lilypond
352
353 When a tie is applied to a chord, all note heads (whose pitches match) are
354 connected.  If you try to tie together chords that have no common pitches,
355 no ties will be created.
356
357 If you want less ties created for a chord, you can set
358 @code{Voice.sparseTies} to true.  In this case, a single tie is used
359 for every tied chord.
360 @lilypond[fragment,verbatim,center]
361   \property Voice.sparseTies = ##t
362   <<c' e' g'>> ~ <<c' e' g'>>
363 @end lilypond
364
365 In its meaning a tie is just a way of extending a note duration, similar
366 to the augmentation dot: the following example are two ways of notating
367 exactly the same concept.
368 @c
369 @lilypond[fragment, singleline,quote]
370 \time 3/4 c'2. c'2 ~ c'4
371 @end lilypond
372 If you need to tie notes over bars, it may be easier to use
373 @ref{Automatic note splitting}.
374
375 See also @seeinternals{Tie}.
376
377
378 @refbugs
379
380 At present, the tie is represented as a separate event, temporally
381 located in between the notes.  Tying only a subset of the note heads
382 of a chord is not supported in a simple way.  It can be achieved by
383 moving the tie-engraver into the Thread context and turning on and off
384 ties per Thread.
385
386 Switching staves when a tie is active will not work.
387
388 @node Automatic note splitting 
389 @subsection Automatic note splitting
390 @c FIXME: This subsection doesn't belong in @ref{Note entry}.
391
392 LilyPond can automatically converting long notes to tied notes.  This
393 is done by replacing the @code{Note_heads_engraver} by the
394 @code{Completion_heads_engraver}. 
395
396 @lilypond[verbatim,noindent]
397 \score{
398   \notes\relative c'{ \time 2/4
399   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 
400   }
401   \paper{ \translator{
402       \ThreadContext
403       \remove "Note_heads_engraver"
404       \consists "Completion_heads_engraver"
405   } } }
406 @end lilypond
407
408 This engraver splits all running notes at the bar line, and inserts
409 ties.  One of its uses is to debug complex scores: if the measures are
410 not entirely filled, then the ties exactly show how much each measure
411 is off.
412
413 @refbugs
414
415 Not all durations (especially those containing tuplets) can be
416 represented exactly; the engraver will not insert tuplets. 
417
418 @node Tuplets
419 @subsection Tuplets
420
421 @cindex tuplets
422 @cindex triplets
423 @cindex @code{\times}
424
425 Tuplets are made out of a music expression by multiplying all durations
426 with a fraction.
427
428 @cindex @code{\times}
429 @example
430   \times @var{fraction} @var{musicexpr}
431 @end example
432
433 The duration of @var{musicexpr} will be multiplied by the fraction. 
434 In the sheet music, the fraction's denominator will be printed over
435 the notes, optionally with a bracket.  The most common tuplet is the
436 triplet in which 3 notes have the length of 2, so the notes are 2/3
437 of their written length:
438
439 @lilypond[fragment,verbatim,center]
440   g'4 \times 2/3 {c'4 c' c'} d'4 d'4
441 @end lilypond
442
443 The property @code{tupletSpannerDuration} specifies how long each bracket
444 should last.  With this, you can make lots of tuplets while typing
445 @code{\times} only once, saving you lots of typing.
446
447 @lilypond[fragment,  relative, singleline, verbatim]
448 \property Voice.tupletSpannerDuration = #(ly:make-moment 1 4)
449 \times 2/3 { c'8 c c c c c }
450 @end lilypond
451
452 The format of the number is determined by the property
453 @code{tupletNumberFormatFunction}.  The default prints only the
454 denominator, but if you set it to the Scheme function
455 @code{fraction-tuplet-formatter}, Lilypond will print @var{num}:@var{den}
456 instead.
457
458
459 @cindex @code{tupletNumberFormatFunction}
460 @cindex tuplet formatting 
461
462 See also @seeinternals{TupletBracket}.
463
464 @refbugs
465
466 Nested tuplets are not formatted automatically.  In this case, outer
467 tuplet brackets should be moved automatically.
468
469 @node Easy Notation note heads 
470 @subsection Easy Notation note heads
471
472 @cindex easy notation
473 @cindex Hal Leonard
474
475 An entirely different type of note head is the "easyplay" note head: a
476 note head that includes a note name.  It is used in some publications by
477 Hal-Leonard Inc. music publishers.
478
479 @lilypond[singleline,verbatim,26pt]
480 \score {
481   \notes { c'2 e'4 f' | g'1 }
482   \paper { \translator { \EasyNotation } } 
483 }
484 @end lilypond
485
486 Note that @code{EasyNotation} overrides a @internalsref{Score} context.  You
487 probably will want to print it with magnification or a large font size to
488 make it more readable.  To print with magnification, you must create a dvi
489 (with @file{ly2dvi}) and then enlarge it with something like @file{dvips -x
490 2000 file.dvi}.  See @file{man dvips} for details.  To print with a larger
491 font, see @ref{Font Size}.
492
493
494 @cindex Xdvi
495 @cindex ghostscript
496
497 If you view the result with Xdvi, then staff lines will show through
498 the letters.  Printing the PostScript file obtained with ly2dvi does
499 produce the correct result.
500
501
502 @node Easier music entry
503 @section Easier music entry
504 @cindex Music entry
505 @menu
506 * Graphical interfaces::        
507 * Relative octaves::            
508 * Bar check::                   
509 * Point and click::             
510 * Skipping corrected music::    
511 @end menu
512
513 When entering music with LilyPond, it is easy to introduce errors. This
514 section deals with tricks and features that help you enter music, and
515 find and correct mistakes.
516
517 @node Graphical interfaces
518 @subsection Graphical interfaces
519
520 @cindex GUI
521 @cindex graphical interface
522 @cindex sequencer
523 @cindex RoseGarden
524 @cindex Denemo
525 @cindex NoteEdit
526 @cindex MIDI
527
528 One way to avoid entering notes using the keyboard is to use a
529 graphical user interface.  The following programs are known to have
530 a lilypond export option:
531
532 @itemize @bullet
533 @item
534 Denemo was once intended as
535 a LilyPond graphical user interface.  It run on Gnome/GTK.
536
537 @quotation
538 @uref{http://denemo.sourceforge.net/}
539 @end  quotation
540
541 @item
542  Noteedit, a graphical score editor that runs under KDE/Qt.
543 @quotation
544 @uref{http://rnvs.informatik.tu-chemnitz.de/~jan/noteedit/noteedit.html,}
545 @end quotation
546
547 @item
548 RoseGarden was once the inspiration for naming LilyPond.  Nowadays it
549 has been rewritten from scratch and supports LilyPond export as of
550 version 0.1.6.
551
552 @quotation
553 @uref{http://rosegarden.sf.net/}
554 @end quotation
555 @end itemize
556
557 Another option is to enter the music using your favorite
558 sequencer/notation editor, and then export it as MIDI or MusicXML.
559 You can then import it in lilypond by using either midi2ly or
560 @cindex midi2ly
561 xml2ly. midi2ly is described in @ref{Invoking midi2ly}. @code{xml2ly}
562 @cindex xml2ly
563 is a tool to convert from the MusicXML music representation format
564 (@uref{http://www.musicxml.org}) to LilyPond format. @code{xml2ly} is
565 described at @uref{http://www.nongnu.org/xml2ly/}.
566
567
568 @c .  {Relative}
569 @node Relative octaves
570 @subsection Relative octaves
571 @cindex Relative
572 @cindex relative octave specification
573
574 Octaves are specified by adding @code{'} and @code{,} to pitch names.
575 When you copy existing music, it is easy to accidentally put a pitch in
576 the wrong octave and hard to find such an error.  To prevent these
577 errors, LilyPond features octave entry.
578
579 @cindex @code{\relative}
580 @example
581   \relative @var{startpitch} @var{musicexpr}
582 @end example
583
584 The octave of notes that appear in @var{musicexpr} are calculated as
585 follows: If no octave changing marks are used, the basic interval
586 between this and the last note is always taken to be a fourth or less
587 (This distance is determined without regarding alterations; a
588 @code{fisis} following a @code{ceses} will be put above the
589 @code{ceses})
590
591 The octave changing marks @code{'} and @code{,} can be added to raise or
592 lower the pitch by an extra octave.  Upon entering relative mode, an
593 absolute starting pitch must be specified that will act as the
594 predecessor of the first note of @var{musicexpr}.
595
596 Entering music that changes octave frequently  is easy in relative mode.
597 @lilypond[fragment,singleline,verbatim,center]
598   \relative c'' {
599     b c d c b c bes a 
600   }
601 @end lilypond
602
603 And octave changing marks are used for intervals greater than a fourth.
604 @lilypond[fragment,verbatim,center]
605   \relative c'' {
606     c g c f, c' a, e'' }
607 @end lilypond
608
609 If the preceding item is a chord, the first note of the chord is used
610 to determine the first note of the next chord. However, other notes
611 within the second chord are determined by looking at the immediately
612 preceding note.
613
614 @lilypond[fragment,verbatim,center]
615   \relative c' {
616     c <<c e g>> 
617     <<c' e g>>
618     <<c, e' g>>
619   }
620 @end lilypond 
621 @cindex @code{\notes}
622
623 The pitch after the @code{\relative} contains a note name.  To parse
624 the pitch as a note name, you have to be in note mode, so there must
625 be a surrounding @code{\notes} keyword (which is not
626 shown here).
627
628 The relative conversion will not affect @code{\transpose},
629 @code{\chords} or @code{\relative} sections in its argument.  If you
630 want to use relative within transposed music, you must place an
631 additional @code{\relative} inside the @code{\transpose}.
632
633
634 @c . {Bar check}
635 @node Bar check
636 @subsection Bar check
637 @cindex Bar check
638
639 @cindex bar check
640 @cindex @code{barCheckSynchronize}
641 @cindex @code{|}
642
643
644 Whenever a bar check is encountered during interpretation, a warning
645 message is issued if it doesn't fall at a measure boundary.  This can
646 help you find errors in the input.  Depending on the value of
647 @code{barCheckSynchronize}, the beginning of the measure will be
648 relocated, so this can also be used to shorten measures.
649
650 A bar check is entered using the bar symbol, @code{|}:
651 @example
652   \time 3/4 c2 e4 | g2.
653 @end example
654
655
656
657 @cindex skipTypesetting
658
659 Failed bar checks are most often caused by entering incorrect
660 durations. Incorrect durations often completely garble up the score,
661 especially if it is polyphonic, so you should start correcting the score
662 by scanning for failed bar checks and incorrect durations.  To speed up
663 this process, you can use @code{skipTypesetting} (See @ref{Skipping
664 corrected music})). 
665
666 @c .  {Point and click}
667 @node Point and click
668 @subsection Point and click
669 @cindex poind and click
670
671 Point and click lets you find notes in the input by clicking on them in
672 the Xdvi window. This makes it very easy to find input that causes some
673 error in the sheet music.
674
675 To use it, you need the following software
676 @itemize @bullet
677 @item A dvi viewer that supports src specials.
678 @itemize @bullet
679 @item Xdvi, version 22.36 or newer.  Available from
680 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
681
682   Note that most @TeX{} distributions ship with xdvik, which is always
683   a few versions behind the official Xdvi. To find out which xdvi you
684   are running, try @code{xdvi -version} or @code{xdvi.bin -version}.
685 @item KDVI.  A dvi viewer for KDE.  You need KDVI from KDE 3.0 or
686 newer.  Enable option @emph{Inverse search} in the menu @emph{Settings}.
687
688 @cindex Xdvi
689 @cindex KDVI
690 @cindex KDE
691
692
693
694 @end itemize
695 @item An editor with a client/server interface (or a lightweight GUI
696 editor).
697
698 @cindex editor
699
700 @itemize @bullet
701 @item Emacs. Emacs is an extensible text-editor.  It is available from
702 @uref{http://www.gnu.org/software/emacs/}.  You need version 21 to use
703 column location.
704
705 @c move this elsewhere?
706
707 LilyPond also comes with support files for emacs: lilypond-mode for
708 emacs provides indentation, autocompletion, syntax coloring, handy
709 compile short-cuts and reading Info documents of lilypond inside emacs.
710 If lilypond-mode is not installed on your platform,
711 then refer to the installation instructions for more information.
712
713 @cindex emacs
714 @cindex emacs mode
715 @cindex lilypond-mode for emacs
716 @cindex syntax coloring
717
718 @item XEmacs. Xemacs is very similar to emacs.
719
720 @cindex XEmacs
721
722 @item NEdit.  NEdit runs under Windows, and Unix.
723   It is available from @uref{http://www.nedit.org}.
724
725 @cindex NEdit
726
727 @item GVim.  GVim is a GUI variant of VIM, the popular VI
728 clone.  It is available from @uref{http://www.vim.org}.
729
730 @cindex GVim
731 @cindex Vim
732
733 @end itemize
734 @end itemize
735
736
737 Xdvi must be configured to find the @TeX{} fonts and music
738 fonts. Refer to the Xdvi documentation for more information.
739
740 To use point-and-click, add one of these lines to the top of your .ly
741 file.
742 @example
743 #(ly:set-point-and-click 'line)
744 @end example
745 @cindex line-location
746
747 When viewing, Control-Mousebutton 1 will take you to the originating
748 spot in the @file{.ly} file.  Control-Mousebutton 2 will show all
749 clickable boxes.
750
751 If you correct large files with point-and-click, be sure to start
752 correcting at the end of the file. When you start at the top, and
753 insert one line, all following locations will be off by a line.
754
755 @cindex Emacs
756 For using point-and-click with emacs,  add the following
757 In your emacs startup file (usually @file{~/.emacs}), 
758 @example
759 (server-start)
760 @end example
761
762 Make sure that the environment variable @var{XEDITOR} is set to
763 @example
764 emacsclient --no-wait +%l %f
765 @end example
766 @cindex @var{XEDITOR}
767 If you use xemacs instead of emacs, you use @code{(gnuserve-start)} in
768 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}
769
770 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or
771 use this argument with xdvi's @code{-editor} option.
772
773 @cindex NEdit
774 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
775 use this argument with xdvi's @code{-editor} option.
776
777 If can also make your editor jump to the exact location of the note
778 you clicked. This is only supported on Emacs and VIM. Users of Emacs version
779 20 must apply the patch @file{emacsclient.patch}. Users of version 21
780 must apply @file{server.el.patch} (version 21.2 and earlier).  At the
781 top of the @code{ly} file, replace the @code{set-point-and-click} line
782 with the following line,
783 @example
784 #(ly:set-point-and-click 'line-column)
785 @end example
786 @cindex line-colomn-location
787 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}.  Vim
788 users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}.
789
790
791
792 @refbugs
793
794 When you convert the @TeX{} file to PostScript using @code{dvips}, it
795 will complain about not finding @code{src:X:Y} files. These complaints
796 are harmless, and can be ignored.
797
798 @node Skipping corrected music
799 @subsection Skipping corrected music
800
801 The property @code{Score.skipTypesetting} can be used to switch on and
802 off typesetting completely during the interpretation phase. When
803 typesetting is switched off, the music is processed much more quickly.
804 You can use this to skip over the parts of a score that you have already
805 checked for errors. 
806
807 @lilypond[fragment,singleline,verbatim]
808 \relative c'' { c8 d
809 \property Score.skipTypesetting = ##t
810   e f g a g c, f e d
811 \property Score.skipTypesetting = ##f
812 c d b bes a g c2 } 
813 @end lilypond
814
815
816
817
818 @node Staff notation
819 @section Staff notation
820
821 This section deals with music notation that occurs on staff level,
822 such as keys, clefs and time signatures.
823
824 @cindex Staff notation
825
826 @menu
827 * Staff symbol::                
828 * Key signature::               
829 * Clef::                        
830 * Time signature::              
831 * Unmetered music::             
832 * Bar lines::                   
833 @end menu
834
835 @node Staff symbol
836 @subsection Staff symbol
837
838
839 @cindex adjusting staff symbol
840 @cindex StaffSymbol, using \property
841 @cindex staff lines, setting number of
842
843
844 The lines of the staff symbol are formed by the
845 @internalsref{StaffSymbol} object.  This object is created at the moment
846 that their context is created.  You can not change the appearance of
847 the staff symbol by using @code{\override} or @code{\set}.  At the
848 moment that @code{\property Staff} is interpreted, a Staff context is
849 made, and the StaffSymbol is created before any @code{\override} is
850 effective. You can deal with this either overriding properties in a
851 @code{\translator} definition, or by using @code{\outputproperty}.
852
853
854 @refbugs
855
856 If you end a staff half way a piece, the staff symbol may not end
857 exactly on the barline.
858
859
860 @c .  {Key}
861 @node Key signature
862 @subsection Key signature
863 @cindex Key
864
865 @cindex @code{\key}
866
867 Setting or changing the key signature is done with the @code{\key}
868 command.
869 @example
870   @code{\key} @var{pitch} @var{type}
871 @end example
872
873 @cindex @code{\minor}
874 @cindex @code{\major}
875 @cindex @code{\minor}
876 @cindex @code{\ionian}
877 @cindex @code{\locrian}
878 @cindex @code{\aeolian}
879 @cindex @code{\mixolydian}
880 @cindex @code{\lydian}
881 @cindex @code{\phrygian}
882 @cindex @code{\dorian}
883
884 Here, @var{type} should be @code{\major} or @code{\minor} to get
885 @var{pitch}-major or @var{pitch}-minor, respectively.
886 The standard mode names @code{\ionian},
887 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
888 @code{\phrygian}, and @code{\dorian} are also defined.
889
890 This command sets the context property @code{Staff.keySignature}. 
891 Non-standard key signatures can be specified by setting this property
892 directly.
893
894 The printed signature is a @internalsref{KeySignature} object, typically
895 created in @internalsref{Staff} context.
896
897 @cindex @code{keySignature}
898
899 @c .  {Clef}
900 @node Clef
901 @subsection Clef
902 @cindex @code{\clef}
903
904 The clef can be set or changed with the @code{\clef} command:
905 @lilypond[fragment,verbatim]
906   \key f\major  c''2 \clef alto g'2
907 @end lilypond
908
909 Supported clef-names include 
910 @c Moved standard clefs to the top /MB
911 @table @code
912 @item treble, violin, G, G2
913 G clef on 2nd line
914 @item alto, C
915  C clef on 3rd line
916 @item tenor
917  C clef on 4th line
918 @item bass, F
919  F clef on 4th line
920 @item french
921  G clef on 1st line, so-called French violin clef
922 @item soprano
923  C clef on 1st line
924 @item mezzosoprano
925  C clef on 2nd line
926 @item baritone
927  C clef on 5th line
928 @item varbaritone
929  F clef on 3rd line
930 @item subbass
931  F clef on 5th line
932 @item percussion
933  percussion clef
934 @end table
935
936 By adding @code{_8} or @code{^8} to the clef name, the clef is
937 transposed one octave down or up, respectively.  Note that you have to
938 enclose @var{clefname} in quotes if you use underscores or digits in the
939 name. For example,
940 @example
941         \clef "G_8"
942 @end example
943
944 The object for this symbol is @internalsref{Clef}. 
945
946
947 This command is equivalent to setting @code{clefGlyph},
948 @code{clefPosition} (which controls the Y position of the clef),
949 @code{centralCPosition} and @code{clefOctavation}. A clef is created
950 when any of these properties are changed.
951
952
953 @c .  {Time signature}
954 @node Time signature
955 @subsection Time signature
956 @cindex Time signature
957 @cindex meter
958 @cindex @code{\time}
959
960 The time signature is set or changed by the @code{\time}
961 command.
962 @lilypond[fragment,verbatim]
963  \time 2/4 c'2 \time 3/4 c'2. 
964 @end lilypond
965
966 The actual symbol that's printed can be customized with the @code{style}
967 property. Setting it to @code{#'()} uses fraction style for 4/4 and
968 2/2 time.
969
970
971 The object for this symbol is @internalsref{TimeSignature}.  There are
972 many more options for its layout. They are selected through the
973 @code{style} object property. See @inputfileref{input/test,time.ly} for more
974 examples.
975
976 This command sets the property @code{timeSignatureFraction},
977 @code{beatLength} and @code{measureLength} in the @code{Timing}
978 context, which is normally aliased to @internalsref{Score}.  The property
979 @code{timeSignatureFraction} determine where bar lines should be
980 inserted, and how automatic beams should be generated.  Changing the
981 value of @code{timeSignatureFraction} also causes a time signature
982 symbol to be printed.
983
984 More options are available through the Scheme function
985 @code{set-time-signature}. In combination with the
986 @internalsref{Measure_grouping_engraver}, it will create
987 @internalsref{MeasureGrouping} signs. Such signs ease reading
988 rhythmically complex modern music.  In the following example, the 9/8
989 measure is subdivided in 2, 2, 2 and 3. This is passed to
990 @code{set-time-signature} as the third argument @code{(2 2 2 3)}.
991
992 @lilypond[verbatim]
993 \score { \notes \relative c'' {
994    #(set-time-signature 9 8 '(2 2 2 3))
995    g8 g d d g g a8-[-( bes g-]-) | 
996    #(set-time-signature 5 8 '(3 2))
997    a4. g4
998    }
999    \paper {
1000        linewidth = -1.0
1001        \translator { \StaffContext
1002          \consists "Measure_grouping_engraver"
1003    }}}
1004 @end lilypond 
1005
1006 @c .   {Partial}
1007 @subsection Partial
1008 @cindex Partial
1009 @cindex anacrusis
1010 @cindex upbeat
1011 @cindex partial measure
1012 @cindex measure, partial
1013 @cindex shorten measures
1014 @cindex @code{\partial}
1015
1016 Partial measures, for example in upbeats, are entered using the
1017 @code{\partial} command:
1018 @lilypond[fragment,verbatim]
1019 \partial 4* 5/16  c'16 c4 f16 a'2. ~ a'8. a'16 | g'1
1020 @end lilypond
1021
1022 The syntax for this command is 
1023 @example
1024   \partial @var{duration} 
1025 @end example
1026 This is  internally translated into
1027 @example
1028   \property Timing.measurePosition = -@var{length of duration}
1029 @end example
1030 @cindex @code{|}
1031 The property @code{measurePosition} contains a rational number
1032 indicating how much of the measure has passed at this point.
1033
1034
1035 @node Unmetered music
1036 @subsection Unmetered music
1037
1038 Bar lines and bar numbers are calculated automatically. For unmetered
1039 music (e.g. cadenzas), this is not desirable.  The commands
1040 @code{\cadenzaOn} and @code{\cadenzaOff} can be used to switch off the
1041 timing information:
1042
1043 @lilypond[fragment,relative,singleline,verbatim]
1044 c'2.
1045 \cadenzaOn
1046 c2
1047 \cadenzaOff
1048 c4 c4 c4 
1049 @end lilypond
1050
1051 The property @code{Score.timing} can be used to switch off this
1052 automatic timing
1053
1054 @c .   {Bar lines}
1055 @node Bar lines
1056 @subsection Bar lines
1057 @cindex Bar lines
1058
1059 @cindex @code{\bar}
1060 @cindex measure lines
1061 @cindex repeat bars
1062
1063 Bar lines are inserted automatically, but if you need a special type
1064 of barline, you can force one using the @code{\bar} command:
1065 @lilypond[fragment,verbatim] c4 \bar "|:" c4
1066 @end lilypond
1067
1068 The following bar types are available
1069 @lilypond[fragment,  relative, singleline, verbatim]
1070 c4
1071 \bar "|" c
1072 \bar "" c
1073 \bar "|:" c
1074 \bar "||" c
1075 \bar ":|" c
1076 \bar ".|" c
1077 \bar ".|." c
1078 \bar "|." 
1079 @end lilypond
1080
1081 You are encouraged to use @code{\repeat} for repetitions.  See
1082 @ref{Repeats}.
1083
1084 In scores with many staves, the barlines are automatically placed at
1085 top level, and they are connected between different staves of a
1086 @internalsref{StaffGroup}:
1087 @lilypond[fragment, verbatim]
1088 < \context StaffGroup <
1089   \context Staff = up { e'4 d'
1090      \bar "||"
1091      f' e' }
1092   \context Staff = down { \clef bass c4 g e g } >
1093 \context Staff = pedal { \clef bass c2 c2 } >
1094 @end lilypond
1095
1096 The objects that are created at @internalsref{Staff} level. The name is
1097 @internalsref{BarLine}.
1098
1099 The command @code{\bar @var{bartype}} is a short cut for
1100 doing  @code{\property Score.whichBar = @var{bartype}}
1101 Whenever @code{whichBar} is set to a string, a bar line of that type is
1102 created.  @code{whichBar} is usually set automatically: at the start of
1103 a measure it is set to @code{defaultBarType}. The contents of
1104 @code{repeatCommands} is used to override default measure bars.
1105
1106 @code{whichBar} can also be set directly, using @code{\property} or
1107 @code{\bar  }.  These settings take precedence over the automatic
1108 @code{whichBar} settings. 
1109
1110
1111 @cindex Bar_line_engraver
1112 @cindex whichBar
1113 @cindex repeatCommands
1114 @cindex defaultBarType
1115
1116
1117
1118 @c .   {Polyphony}
1119 @node Polyphony
1120 @section Polyphony
1121 @cindex polyphony
1122
1123 The easiest way to enter such fragments with more than one voice on a
1124 staff is to split chords using the separator @code{\\}.  You can use
1125 it for small, short-lived voices (make a chord of voices) or for
1126 single chords:
1127
1128 @lilypond[verbatim,fragment]
1129 \context Voice = VA \relative c'' {
1130  c4 < { f d e  } \\ { b c2 } > c4 < g' \\ b, \\  f \\ d >
1131 }
1132 @end lilypond
1133
1134 The separator causes @internalsref{Voice} contexts to be instantiated,
1135 bearing the names @code{"1"}, @code{"2"}, etc.
1136
1137 Sometimes, it is necessary to instantiate these contexts by hand: For
1138 Instantiate a separate Voice context for each part, and use
1139 @code{\voiceOne}, up to @code{\voiceFour} to assign a stem directions
1140 and horizontal shift for each part.
1141 @c
1142
1143 @lilypond[singleline, verbatim]
1144 \relative c''
1145 \context Staff < \context Voice = VA { \voiceOne cis2 b  }
1146   \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 } 
1147   \context Voice = VC { \voiceTwo fis4~  fis4 f ~ f  } >
1148 @end lilypond
1149
1150 The identifiers @code{\voiceOne} to @code{\voiceFour} set directions
1151 ties, slurs and stems, and set shift directions.
1152
1153 If you want more than four voices, you can also manually set
1154 horizontal shifts and stem directions, as is shown  in the following example:
1155 @lilypond[fragment, verbatim]
1156   \context Staff \notes\relative c''<
1157        \context Voice=one {
1158        \shiftOff \stemUp e4
1159        }
1160        \context Voice=two {
1161           \shiftOn \stemUp cis
1162        }
1163        \context Voice=three {
1164          \shiftOnn \stemUp ais
1165        }
1166        \context Voice=four {
1167           \shiftOnnn \stemUp fis
1168        }
1169   >
1170 @end lilypond
1171
1172
1173 Normally, note heads with a different number of dots are not merged, but
1174 if you set the object property @code{merge-differently-dotted}, they are:
1175 @lilypond[verbatim,fragment,singleline]
1176 \context Voice < {
1177      g'8 g'8 
1178      \property Staff.NoteCollision \override
1179         #'merge-differently-dotted = ##t
1180      g'8 g'8
1181   } \\ { [g'8. f16] [g'8. f'16] } 
1182   >
1183 @end lilypond
1184
1185 Similarly, you can merge half note heads with eighth notes, by setting
1186 @code{merge-differently-headed}:
1187 @lilypond[fragment, relative=2,verbatim]
1188 \context Voice < {
1189     c8 c4.
1190     \property Staff.NoteCollision
1191       \override #'merge-differently-headed = ##t
1192     c8 c4. } \\ { c2 c2 } >
1193 @end lilypond
1194
1195 LilyPond also vertically shifts rests that are opposite of a stem. 
1196
1197 @lilypond[singleline,fragment,verbatim]
1198 \context Voice < c''4 \\  r4 >
1199 @end lilypond
1200
1201 See also @internalsref{NoteCollision} and @internalsref{RestCollision}
1202
1203 @refbugs
1204
1205 Resolving collisions is a very intricate subject, and LilyPond only
1206 handles a few situations. When it can not cope, you are advised to use
1207 @code{force-hshift} of the @internalsref{NoteColumn} object and pitched
1208 rests to override typesetting decisions.
1209
1210 @node Beaming
1211 @section Beaming
1212
1213 Beams are used to group short notes into chunks that are aligned with
1214 the metrum. They are inserted automatically in most cases.
1215
1216 @lilypond[fragment,verbatim, relative=2]
1217 \time 2/4 c8 c c c \time 6/8 c c c c8. c16  c8
1218 @end lilypond
1219
1220 If you're not satisfied with the automatic beaming, you can enter the
1221 beams explicitly. If you have beaming patterns that differ from the
1222 defaults, you can also set the patterns for automatic beamer.
1223
1224 See also @internalsref{Beam}.
1225
1226 @c .    {Manual beams}
1227 @cindex Automatic beams
1228 @subsection Manual beams
1229 @cindex beams, manual
1230 @cindex @code{]}
1231 @cindex @code{[}
1232
1233 In some cases it may be necessary to override LilyPond's automatic
1234 beaming algorithm.  For example, the auto beamer will not beam over
1235 rests or bar lines, If you want that, specify the begin and end point
1236 manually using a @code{[} before the first beamed note and a @code{]}
1237 after the last note:
1238
1239 @lilypond[fragment,relative,verbatim]
1240   \context Staff {
1241     r4 r8-[ g' a r8-] r8 g-[ | a-] r8
1242   }
1243 @end lilypond
1244
1245 @cindex @code{stemLeftBeamCount}
1246
1247 Normally, beaming patterns within a beam are determined automatically.
1248 When this mechanism fouls up, the properties
1249 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount} can
1250 be used to control the beam subdivision on a stem.  If you set either
1251 property, its value will be used only once, and then it is erased.
1252
1253 @lilypond[fragment,relative,verbatim]
1254   \context Staff {
1255     f8-[ r16 f g a-]
1256     f8-[ r16 \property Voice.stemLeftBeamCount = #1 f g a-]
1257   }
1258 @end lilypond
1259 @cindex @code{stemRightBeamCount}
1260
1261
1262 The property @code{subdivideBeams} can be set in order to subdivide
1263 all 16th or shorter beams at beat positions.  This accomplishes the
1264 same effect as twiddling with @code{stemLeftBeamCount} and
1265 @code{stemRightBeamCount}, but it take less typing.
1266
1267
1268 @example
1269 c16-[ c c c c c c c-]
1270 \property Voice.subdivideBeams = ##t
1271 c16-[ c c c c c c c-]
1272 c32-[ c c c c c c c c c c c c c c c-]
1273 \property Score.beatLength = #(ly:make-moment 1 8)
1274 c32-[ c c c c c c c c c c c c c c c-]
1275 @end example
1276 @lilypond[noindent]
1277 \score {
1278     \notes \relative c' {
1279         c16-[ c c c c c c c-]
1280         \property Voice.subdivideBeams = ##t
1281         c16-[ c c c c c c c-]
1282         c32-[ c c c c c c c c c c c c c c c-]
1283         \property Score.beatLength = #(ly:make-moment 1 8)
1284         c32-[ c c c c c c c c c c c c c c c-]
1285     }
1286 }
1287 @end lilypond
1288 @cindex subdivideBeams
1289
1290 Kneed beams are inserted automatically, when a large gap between two
1291 adjacent beamed notes is detected. This behavior can be tuned through
1292 the object property @code{auto-knee-gap}.
1293
1294 @cindex beams, kneed
1295 @cindex kneed beams
1296 @cindex auto-knee-gap
1297
1298
1299 @c TODO -> why this ref? Document? 
1300 @cindex @code{neutral-direction}
1301
1302 @refbugs
1303
1304 @cindex hara kiri
1305
1306 Auto knee beams can not be used together with hara kiri staves.
1307
1308 [TODO from bugs]
1309
1310 The Automatic beamer does not put @strong{unfinished} beams on the
1311 last notes of a score.
1312
1313 Formatting of ties is a difficult subject. LilyPond often does not
1314 give optimal results.
1315
1316 @menu
1317 * Setting automatic beam behavior ::  
1318 @end menu
1319
1320 @ignore
1321 @no de Beam typography
1322 @sub section Beam typography
1323
1324 One of the strong points of LilyPond is how beams are formatted. Beams
1325 are quantized, meaning that the left and right endpoints beams start
1326 exactly on staff lines. Without quantization, small wedges of white
1327 space appear between the beam and staff line, and this looks untidy.
1328
1329 Beams are also slope-damped: melodies that go up or down should also
1330 have beams that go up or down, but the slope of the beams should be
1331 less than the slope of the notes themselves.
1332
1333 Some beams should be horizontal. These are so-called concave beams. 
1334
1335 [TODO: some pictures.]
1336 @end ignore
1337
1338 @c .    {Automatic beams}
1339 @node Setting automatic beam behavior 
1340 @subsection Setting automatic beam behavior 
1341
1342 @cindex @code{autoBeamSettings}
1343 @cindex @code{(end * * * *)}
1344 @cindex @code{(begin * * * *)}
1345 @cindex automatic beams, tuning
1346 @cindex tuning automatic beaming
1347
1348 In normal time signatures, automatic beams can start on any note but can
1349 only end in a few positions within the measure: beams can end on a beat,
1350 or at durations specified by the properties in
1351 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
1352 are defined in @file{scm/auto-beam.scm}.
1353
1354 The value of @code{autoBeamSettings} is changed using
1355 @code{\override} and unset using @code{\revert}:
1356 @example
1357 \property Voice.autoBeamSettings \override #'(@var{BE} @var{P} @var{Q} @var{N} @var{M}) = @var{dur}
1358 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{P} @var{Q} @var{N} @var{M})
1359 @end example
1360 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
1361 whether the rule applies to begin or end-points.  The quantity
1362 @var{P}/@var{Q} refers to the length of the beamed notes (and `@code{*
1363 *}' designates notes of any length), @var{N}/@var{M} refers to a time
1364 signature (wildcards, `@code{* *}' may be entered to designate all time
1365 signatures).
1366
1367 For example, if you want automatic beams to end on every quarter note,
1368 you can use the following:
1369 @example
1370 \property Voice.autoBeamSettings \override
1371     #'(end * * * *) = #(ly:make-moment 1 4)
1372 @end example
1373 Since the duration of a quarter note is 1/4 of a whole note, it is
1374 entered as @code{(ly:make-moment 1 4)}.
1375
1376 The same syntax can be used to specify beam starting points. In this
1377 example, automatic beams can only end on a dotted quarter note. 
1378 @example
1379 \property Voice.autoBeamSettings \override
1380     #'(end * * * *) = #(ly:make-moment 3 8)
1381 @end example
1382 In 4/4 time signature, this means that automatic beams could end only on
1383 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1384 3/8 has passed within the measure).
1385
1386 You can also restrict rules to specific time signatures. A rule that
1387 should only be applied in @var{N}/@var{M} time signature is formed by
1388 replacing the second asterisks by @var{N} and @var{M}. For example, a
1389 rule for 6/8 time exclusively looks like
1390 @example
1391 \property Voice.autoBeamSettings \override
1392     #'(begin * * 6 8) =  ... 
1393 @end example
1394
1395 If you want a rule to apply to certain types of beams, you can use the
1396 first pair of asterisks. Beams are classified according to the shortest
1397 note they contain. For a beam ending rule that only applies to beams
1398 with 32nd notes (and no shorter notes), you would use @code{(end 1
1399 32 * *)}.
1400
1401 @c not true
1402 @c Automatic beams can not be put on the last note in a score.
1403
1404 If a score ends while an automatic beam has not been ended and is still
1405 accepting notes, this last beam will not be typeset at all.
1406
1407 @cindex automatic beam generation
1408 @cindex autobeam
1409 @cindex @code{Voice.autoBeaming}
1410 @cindex lyrics
1411
1412 For melodies that have lyrics, you may want to switch off 
1413 automatic beaming. This is done by setting @code{Voice.autoBeaming} to
1414 @code{#f}. 
1415
1416
1417 @refbugs
1418
1419 It is not possible to specify beaming parameters for beams with mixed
1420 durations, that differ from the beaming parameters of all separate
1421 durations, i.e., you'll have to specify manual beams to get:
1422
1423 @lilypond[singleline,fragment,relative,noverbatim,quote]
1424   \property Voice.autoBeamSettings
1425   \override #'(end * * * *) = #(ly:make-moment 3 8)
1426   \time 12/8 c'8 c c c16 c c c c c c-[ c c c-] c8 c c4
1427 @end lilypond
1428 It is not possible to specify beaming parameters that act differently in
1429 different parts of a measure. This means that it is not possible to use
1430 automatic beaming in irregular meters such as @code{5/8}.
1431
1432 @node Accidentals
1433 @section Accidentals
1434 @cindex Accidentals
1435 This section describes how to change the way that LilyPond automatically
1436 inserts accidentals before the running notes.
1437
1438 @menu
1439 * Using the predefined accidental macros::  
1440 * Defining your own accidental typesettings::  
1441 @end menu
1442
1443 @node Using the predefined accidental macros
1444 @subsection Using the predefined accidental macros
1445 The constructs for describing the accidental typesetting rules are
1446 quite hairy, so non-experts should stick to the macros defined in
1447 @file{ly/property-init.ly}.
1448 @cindex @file{property-init.ly}
1449
1450 The macros operate on the ``Current'' context (see @ref{Context properties}). This
1451 means that the macros shuold normally be invoked right after the
1452 creation of the context in which the accidental typesetting described
1453 by the macro is to take effect. I.e. if you want to use
1454 piano-accidentals in a pianostaff then you issue
1455 @code{\pianoAccidentals} first thing after the creation of the piano
1456 staff:
1457 @example
1458 \score @{
1459     \notes \relative c'' <
1460         \context Staff = sa @{ cis4 d e2 @}
1461         \context GrandStaff <
1462             \pianoAccidentals
1463             \context Staff = sb @{ cis4 d e2 @}
1464             \context Staff = sc @{ es2 c @}
1465         >
1466         \context Staff = sd @{ es2 c @}
1467     >
1468 @}
1469 @end example
1470 @lilypond[singleline]
1471 \score {
1472     \notes \relative c'' <
1473         \context Staff = sa { cis4 d e2 }
1474         \context GrandStaff <
1475             \pianoAccidentals
1476             \context Staff = sb { cis4 d e2 }
1477             \context Staff = sc { es2 c }
1478         >
1479         \context Staff = sd { es2 c }
1480     >
1481     \paper {
1482         \translator {
1483             \StaffContext
1484             minimumVerticalExtent = #'(-4.0 . 4.0)
1485         }
1486     }
1487 }
1488 @end lilypond
1489
1490 The macros are:
1491 @table @code
1492 @item \defaultAccidentals
1493       @cindex @code{\defaultAccidentals}
1494       This is the default typesetting behaviour. It should correspond
1495       to 18th century common practice: Accidentals are
1496       remembered to the end of the measure in which they occur and
1497       only on their own octave.
1498
1499 @item \voiceAccidentals
1500       @cindex @code{\voiceAccidentals}
1501       The normal behaviour is to remember the accidentals on
1502       Staff-level.
1503       This macro, however, typesets accidentals individually for each
1504       voice.
1505       Apart from that the rule is similar to
1506       @code{\defaultAccidentals}.
1507
1508       Warning: This leads to some weird and often unwanted results
1509       because accidentals from one voice DO NOT get cancelled in other
1510       voices:
1511 @lilypond[singleline,relative,fragment,verbatim,quote]
1512     \context Staff <
1513         \voiceAccidentals
1514         \context Voice=va { \voiceOne es g }
1515         \context Voice=vb { \voiceTwo c, e }
1516     >
1517 @end lilypond
1518       Hence you should only use @code{\voiceAccidentals}
1519       if the voices are to be read solely by
1520       individual musicians. if the staff should be readable also
1521       by one musician/conductor then you should use
1522       @code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
1523       instead.
1524
1525 @item \modernAccidentals
1526       @cindex @code{\modernAccidentals}
1527       This rule should correspond to the common practice in the 20th
1528       century.
1529       The rule is a bit more complex than @code{\defaultAccidentals}:
1530       You get all the same accidentals, but temporary
1531       accidentals also get cancelled in other octaves. Further more,
1532       in the same octave, they also get cancelled in the following measure:
1533 @lilypond[singleline,fragment,verbatim]
1534       \modernAccidentals
1535       cis' c'' cis'2 | c'' c'
1536 @end lilypond
1537
1538 @item \modernCautionaries
1539       @cindex @code{\modernCautionaries}
1540      This rule is similar to @code{\modernAccidentals}, but the
1541      ``extra'' accidentals (the ones not typeset by
1542      @code{\defaultAccidentals}) are typeset as cautionary accidentals
1543      (i.e. in reduced size):
1544 @lilypond[singleline,fragment,verbatim]
1545       \modernCautionaries
1546       cis' c'' cis'2 | c'' c'
1547 @end lilypond
1548
1549 @item \modernVoiceAccidentals
1550       @cindex @code{\modernVoiceAccidentals}
1551       Multivoice accidentals to be read both by musicians playing one voice
1552       and musicians playing all voices.
1553
1554       Accidentals are typeset for each voice, but they ARE cancelled
1555       across voices in the same @internalsref{Staff}.
1556
1557 @item \modernVoiceCautionaries
1558       @cindex @code{\modernVoiceCautionaries}
1559       The same as @code{\modernVoiceAccidentals}, but with the
1560       extra accidentals (the ones not typeset by
1561       @code{\voiceAccidentals}) typeset as cautionaries.
1562       Notice that even though all accidentals typeset by
1563       @code{\defaultAccidentals} ARE typeset by this macro then some
1564       of them are typeset as cautionaries.
1565
1566 @item \pianoAccidentals
1567       @cindex @code{\pianoAccidentals}
1568       20th century practice for piano notation. Very similar to
1569       @code{\modernAccidentals} but accidentals also get cancelled
1570       across the staves in the same @internalsref{GrandStaff} or
1571       @internalsref{PianoStaff}.
1572
1573 @item \pianoCautionaries
1574       @cindex @code{\pianoCautionaries}
1575       As @code{\pianoAccidentals} but with the extra accidentals
1576       typeset as cautionaries.
1577
1578 @item \noResetKey
1579       @cindex @code{\noResetKey}
1580       Same as @code{\defaultAccidentals} but with accidentals lasting
1581       ``forever'' and not only until the next measure:
1582 @lilypond[singleline,fragment,verbatim,relative]
1583       \noResetKey
1584       c1 cis cis c
1585 @end lilypond
1586
1587 @item \forgetAccidentals
1588       @cindex @code{\forgetAccidentals}
1589       This is sort of the opposite of @code{\noResetKey}: Accidentals
1590       are not remembered at all - and hence all accidentals are
1591       typeset relative to the key signature, regardless of what was
1592       before in the music:
1593 @lilypond[singleline,fragment,verbatim,relative]
1594       \forgetAccidentals
1595       \key d\major c4 c cis cis d d dis dis
1596 @end lilypond
1597 @end table
1598
1599 @node Defining your own accidental typesettings
1600 @subsection Defining your own accidental typesettings
1601
1602 This section must be considered gurus-only, and hence it must be
1603 sufficient with a short description of the system and a reference to
1604 the internal documentation.
1605
1606 The idea of the algorithm is to try several different rules and then
1607 use the rule that gives the highest number of accidentals.
1608 Each rule cosists of
1609 @table @asis
1610 @item Context:
1611       In which context is the rule applied. I.e. if context is
1612       @internalsref{Score} then all staves share accidentals, and if
1613       context is @internalsref{Staff} then all voices in the same
1614       staff share accidentals, but staves don't - like normally.
1615 @item Octavation:
1616       Whether the accidental changes all octaves or only the current
1617       octave.
1618 @item Lazyness:
1619       Over how many barlines the accidental lasts.
1620       If lazyness is @code{-1} then the accidental is forget
1621       immidiately, and if lazyness is @code{#t} then the accidental
1622       lasts forever.
1623 @end table
1624
1625 As described in the internal documentation of
1626 @internalsref{Accidental_engraver}, the properties @code{autoAccidentals} and
1627 @code{autoCautionaries} contain lists of rule descriptions. Notice
1628 that the contexts must be listed from in to out - that is
1629 @internalsref{Thread} before @internalsref{Voice},
1630 @internalsref{Voice} before @internalsref{Staff}, etc. 
1631 see the macros in @file{ly/property-init.ly} for examples of how the
1632 properties are set.
1633
1634 @refbugs
1635
1636 Currently the simultaneous notes are considered to be entered in
1637 sequential mode. This means that in a chord the accidentals are
1638 typeset as if the notes in the chord happened one at a time - in the
1639 order in which they appear in the input file.
1640
1641 Of course this is only a problem when you have simultainous notes
1642 which accidentals should depend on each other.
1643 Notice that the problem only occurs when using non-default accidentals
1644 - as the default accidentals only depend on other accidentals on the
1645 same staff and same pitch and hence cannot depend on other
1646 simultainous notes.
1647
1648 This example shows two examples of the same music giving different
1649 accidentals depending on the order in which the notes occur in the
1650 input file:
1651
1652 @lilypond[singleline,fragment,verbatim]
1653 \property Staff.autoAccidentals = #'( Staff (any-octave . 0) )
1654 cis'4 <<c'' c'>> r2 | cis'4 <<c' c''>> r2 | <<cis' c''>> r | <<c'' cis'>> r | 
1655 @end lilypond
1656
1657 The only solution is to manually insert the problematic
1658 accidentals using @code{!} and @code{?}.
1659
1660 @node Expressive marks
1661 @section Expressive marks
1662
1663 @c .   {Slurs}
1664 @menu
1665 * Slurs ::                      
1666 * Phrasing slurs::              
1667 * Breath marks::                
1668 * Tempo::                       
1669 * Text spanners::               
1670 * Analysis brackets::           
1671 @end menu
1672
1673 @node Slurs 
1674 @subsection Slurs
1675 @cindex Slurs
1676
1677 A slur indicates that notes are to be played bound or @emph{legato}.
1678 They are entered using parentheses:
1679 @lilypond[fragment,verbatim,center]
1680   f'-( g'-)-( a'-) [a'8 b'-(-] a'4 g'2 f'4-)
1681   <<c' e'>>2-( <<b d'>>2-)
1682 @end lilypond
1683
1684 See also @seeinternals{Slur}.
1685
1686 Slurs avoid crossing stems, and are generally attached to note heads.
1687 However, in some situations with beams, slurs may be attached to stem
1688 ends.  If you want to override this layout you can do this through the
1689 object property @code{attachment} of @internalsref{Slur} in
1690 @internalsref{Voice} context It's value is a pair of symbols, specifying
1691 the attachment type of the left and right end points.
1692
1693 @lilypond[fragment,relative,verbatim]
1694   \slurUp
1695   \property Voice.Stem \set #'length = #5.5
1696   g'8-(g g4-)
1697   \property Voice.Slur \set #'attachment = #'(stem . stem)
1698   g8-( g g4-)
1699 @end lilypond
1700
1701 If a slur would strike through a stem or beam, the slur will be moved
1702 away upward or downward. If this happens, attaching the slur to the
1703 stems might look better:
1704
1705 @lilypond[fragment,relative,verbatim]
1706   \stemUp \slurUp
1707   d32-( d'4 d8..-)
1708   \property Voice.Slur \set #'attachment = #'(stem . stem)
1709   d,32-( d'4 d8..-)
1710 @end lilypond
1711
1712 @ignore
1713 Similarly, the curvature of a slur is adjusted to stay clear of note
1714 heads and stems.  When that would increase the curvature too much, the
1715 slur is reverted to its default shape.  The threshold for this
1716 decision is in @internalsref{Slur}'s object property @code{beautiful}.
1717 It is loosely related to the enclosed area between the slur and the
1718 notes.  Usually, the default setting works well, but in some cases you
1719 may prefer a curved slur when LilyPond decides for a vertically moved
1720 one.  You can indicate this preference by increasing the
1721 @code{beautiful} value:
1722
1723 @lilyp ond[verbatim,singleline,relative]
1724   \stemDown \slurUp
1725   c16-( a' f' a a f a, c,-)
1726   c-( a' f' a a f d, c-)
1727   \property Voice.Slur \override #'beautiful = #5.0
1728   c-( a' f' a a f d, c-)
1729 @end lilypond
1730 @end ignore
1731
1732 @refbugs
1733
1734 Producing nice slurs is a difficult problem, and LilyPond currently
1735 uses a simple, empiric method to produce slurs. In some cases, the
1736 results of this method are ugly.
1737
1738 @ignore
1739 This is reflected by the
1740 @code{beautiful} property, which it is an arbitrary parameter in the
1741 slur formatter.  Useful values can only be determined by trial and
1742 error.
1743 @end ignore
1744
1745 @cindex Adjusting slurs
1746
1747 @node Phrasing slurs
1748 @subsection Phrasing slurs
1749
1750 @cindex phrasing slurs
1751 @cindex phrasing marks
1752
1753 A phrasing slur (or phrasing mark) connects chords and is used to
1754 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1755 respectively.
1756
1757 @lilypond[fragment,verbatim,center,relative]
1758   \time 6/4 c' \(  d ( e-) f ( e-)  d-\) 
1759 @end lilypond
1760
1761 Typographically, the phrasing slur behaves almost exactly like a normal
1762 slur.  See also @seeinternals{PhrasingSlur}.  But although they behave
1763 similarily to normal slurs, phrasing slurs count as different objects.
1764 A @code{\slurUp} will have no effect on a phrasing slur; instead, you
1765 should use @code{\phrasingSlurUp}, @code{\phrasingSlurDown}, and
1766 @code{\phrasingSlurBoth}.
1767
1768 Note that the commands
1769 @code{\slurUp}, @code{\slurDown}, and @code{\slurBoth} will only affect
1770 normal slurs and not phrasing slurs.
1771
1772 @node Breath marks
1773 @subsection Breath marks
1774
1775 Breath marks are entered using @code{\breathe}.  See also
1776 @seeinternals{BreathingSign}.
1777
1778 @lilypond[fragment,relative]
1779 c'4 \breathe d4
1780 @end lilypond
1781
1782
1783 @c .  {Tempo}
1784 @node Tempo
1785 @subsection Tempo
1786 @cindex Tempo
1787 @cindex beats per minute
1788 @cindex metronome marking
1789
1790 Metronome settings can be entered as follows:
1791
1792 @cindex @code{\tempo}
1793 @example
1794   \tempo @var{duration} = @var{perminute} 
1795 @end example
1796
1797 For example, @code{\tempo 4 = 76} requests output with 76 quarter notes
1798 per minute.
1799   
1800 @refbugs
1801   
1802 The tempo setting is not printed, but is only used in the MIDI
1803 output. You can trick lily into producing a metronome mark,
1804 though. Details are in @ref{Text markup}.
1805   
1806
1807
1808 @node Text spanners
1809 @subsection Text spanners
1810 @cindex Text spanners
1811
1812 Some textual indications, e.g. rallentando or accelerando, often extend
1813 over many measures. This is indicated by following the text with a
1814 dotted line.  You can create such texts using text spanners. The syntax
1815 is as follows:
1816 @example
1817  \startTextSpan
1818  \stopTextSpan
1819 @end example
1820 LilyPond will respond by creating a @internalsref{TextSpanner} object (typically
1821 in @internalsref{Voice} context).  The string to be printed, as well as the
1822 style is set through object properties.
1823
1824 An application---or rather, a hack---is to fake octavation indications.
1825 @lilypond[fragment,relative,verbatim]
1826  \relative c' {  a''' b c a
1827   \property Voice.TextSpanner \set #'type = #'dotted-line
1828   \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1829   \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1830   \property Staff.centralCPosition = #-13
1831   a\startTextSpan b c a \stopTextSpan }
1832 @end lilypond
1833
1834
1835 @node Analysis brackets
1836 @subsection Analysis brackets
1837 @cindex brackets
1838 @cindex phrasing brackets
1839 @cindex musicological analysis
1840 @cindex note grouping bracket
1841
1842 Brackets are used in musical analysis to indicate structure in musical
1843 pieces. LilyPond supports a simple form of nested horizontal brackets.
1844 To use this, add the @internalsref{Horizontal_bracket_engraver} to
1845 @internalsref{Staff} context.  A bracket is started with
1846 @code{\groupOpen} and closed with @code{\groupClose}. This produces
1847 @internalsref{HorizontalBracket} objects.
1848
1849 @lilypond[singleline,verbatim]
1850 \score { \notes \relative c'' {  
1851         c4-\groupOpen-\groupOpen
1852         c4-\groupClose
1853         c4-\groupOpen
1854         c4-\groupClose-\groupClose
1855   }
1856   \paper { \translator {
1857             \StaffContext \consists "Horizontal_bracket_engraver"
1858         }}}
1859 @end lilypond
1860
1861 @c .  {Ornaments}
1862 @node Ornaments
1863 @section Ornaments
1864 @cindex Ornaments
1865 @menu
1866 * Articulations::               
1867 * Text scripts::                
1868 * Grace notes::                 
1869 * Glissando ::                  
1870 * Dynamics::                    
1871 @end menu
1872
1873 @c .   {Articulation}
1874 @node Articulations
1875 @subsection Articulations
1876 @cindex Articulations
1877
1878 @cindex articulations
1879 @cindex scripts
1880 @cindex ornaments
1881
1882 A variety of symbols can appear above and below notes to indicate
1883 different characteristics of the performance. They are added to a note
1884 by adding a dash and the the character signifying the
1885 articulation. They are demonstrated here.
1886 @lilypond[singleline]
1887   \score {
1888     \notes \context Voice {
1889       \property Voice.TextScript \set #'font-family = #'typewriter
1890       \property Voice.TextScript \set #'font-shape = #'upright
1891       c''4-._"c-."      s4
1892       c''4--_"c-{}-"    s4
1893       c''4-+_"c-+"      s4
1894       c''4-|_"c-|"      s4
1895       c''4->_"c->"      s4
1896       c''4-^_"c-\\^{ }" s4
1897       c''4-__"c-\_" s4      
1898     }
1899   }
1900 @end lilypond
1901
1902 The script is automatically placed, but if you need to force
1903 directions, you can use @code{_} to force them down, or @code{^} to
1904 put them up:
1905 @lilypond[fragment, verbatim]
1906   c''4^^ c''4_^
1907 @end lilypond
1908
1909
1910 Other symbols can be added using the syntax
1911 @var{note}@code{-\}@var{name}. Again, they can be forced up or down
1912 using @code{^} and @code{_}.
1913
1914 @cindex accent
1915 @cindex marcato
1916 @cindex staccatissimo
1917 @cindex fermata
1918 @cindex stopped
1919 @cindex staccato
1920 @cindex portato
1921 @cindex tenuto
1922 @cindex upbow
1923 @cindex downbow
1924 @cindex foot marks
1925 @cindex organ pedal marks
1926 @cindex turn
1927 @cindex open
1928 @cindex flageolet
1929 @cindex reverseturn
1930 @cindex trill
1931 @cindex prall
1932 @cindex mordent
1933 @cindex prallprall
1934 @cindex prallmordent
1935 @cindex prall, up
1936 @cindex prall, down
1937 @cindex mordent
1938 @cindex thumb marking
1939 @cindex segno
1940 @cindex coda
1941 @cindex varcoda
1942
1943 @lilypond[]
1944   \score {
1945     <
1946       \property Score.LyricText \override #'font-family = #'typewriter
1947       \property Score.LyricText \override #'font-shape = #'upright
1948       \context Staff \notes {
1949         \property Score.timing = ##f
1950         \property Score.barAlways = ##t
1951         \property Staff.BarLine \override #'transparent = ##t
1952         c''-\accent             c''-\marcato            c''-\staccatissimo
1953         c''-\staccato           c''-\tenuto             c''-\portato
1954         c''-\upbow              c''-\downbow            c''-\flageolet
1955         c''-\thumb              c''^\lheel              c''-\rheel
1956         c''^\ltoe               c''-\rtoe               c''-\open
1957         c''-\stopped            c''-\turn               c''-\reverseturn
1958         c''-\trill              c''-\prall              c''-\mordent
1959         c''-\prallprall         c''-\prallmordent       c''-\upprall
1960         c''-\downprall          c''-\upmordent          c''-\downmordent
1961         c''-\pralldown          c''-\prallup            c''-\lineprall
1962         c''-\shortfermata       c''-\fermata            c''-\longfermata
1963         c''-\verylongfermata    c''-\segno              c''-\coda
1964         c''-\varcoda
1965       }
1966       \context Lyrics \lyrics {
1967         accent__                marcato__               staccatissimo__
1968         staccato__              tenuto__                portato__
1969         upbow__                 downbow__               flageolet__
1970         thumb__                 lheel__                 rheel__
1971         ltoe__                  rtoe__                  open__
1972         stopped__               turn__                  reverseturn__
1973         trill__                 prall__                 mordent__
1974         prallprall__            prallmordent__          uprall__
1975         downprall__             upmordent__             downmordent__
1976         pralldown__             prallup__               lineprall__            
1977         shortfermata__          fermata__               longfermata__
1978         verylongfermata__       segno__                 coda__
1979         varcoda__
1980       }
1981     >
1982     \paper {
1983       linewidth = 5.1\in
1984       indent    = 0.0\mm
1985     }
1986   }
1987 @end lilypond
1988
1989
1990 @cindex fingering
1991
1992 Fingering instructions can also be entered in this shorthand. For
1993 finger changes, use markup texts:
1994 @c
1995 @lilypond[verbatim, singleline, fragment]
1996       c'4-1 c'4-2 c'4-3 c'4-4
1997       c'^\markup { \fontsize #-3 \number "2-3" }
1998 @end lilypond
1999
2000 @cindex finger change
2001 @cindex scripts
2002 @cindex superscript
2003 @cindex subscript
2004
2005 See also @seeinternals{Script} and @seeinternals{Fingering}.
2006
2007 @refbugs
2008
2009 All of these note ornaments appear in the printed output but have no
2010 effect on the MIDI rendering of the music.
2011
2012 Unfortunately, there is no support for adding fingering instructions or 
2013 ornaments to individual note heads. Some hacks exist, though. See
2014 @inputfileref{input/test,script-horizontal.ly}.
2015
2016
2017 @c .  {Text scripts}
2018 @node Text scripts
2019 @subsection Text scripts
2020 @cindex Text scripts
2021
2022 In addition, it is possible to place arbitrary strings of text or markup
2023 text (see @ref{Text markup}) above or below notes by using a string:
2024 @code{c^"text"}. 
2025
2026 By default, these indications do not influence the note spacing, but
2027 by using the command @code{\fatText}, the widths will be taken into
2028 account.
2029 @c
2030 @lilypond[fragment,singleline,verbatim] \relative c' {
2031 c4^"longtext" \fatText c4_"longlongtext" c4 }
2032 @end lilypond
2033
2034 It is possible to use @TeX{} commands in the strings, but this should be
2035 avoided because it makes it impossible for LilyPond to compute the
2036 exact length of the string, which may lead to collisions.  Also, @TeX{}
2037 commands won't work with direct PostScript output.
2038 @c (see @ref{PostScript output}).
2039
2040 Text scripts are created in form of @internalsref{TextScript} objects, in
2041 @internalsref{Voice} context. 
2042
2043 @ref{Text markup} describes how to change the font or access
2044 special symbols in text scripts.
2045
2046
2047 @c .   {Grace notes}
2048 @node Grace notes
2049 @subsection Grace notes
2050
2051
2052
2053 @cindex @code{\grace}
2054 @cindex ornaments
2055 @cindex grace notes
2056
2057 Grace notes are ornaments that are written out
2058 @lilypond[relative=2,verbatim,ifragment] c4 \grace c16 c4 \grace {
2059 [c16 d16] } c4
2060 @end lilypond
2061
2062 In normal notation, grace notes are supposed to take up no logical
2063 time in a measure. Such an idea is practical for normal notation, but
2064 is not strict enough to put it into a program. The model that LilyPond
2065 uses for grace notes internally is that all timing is done in two
2066 steps:
2067
2068 Every point in musical time consists of two rational numbers: one
2069 denotes the logical time, one denotes the grace timing. The above
2070 example is shown here with timing tuples.
2071
2072 @lilypond[]
2073 \score { \notes \relative c''{ 
2074   c4^"(0,0)"  \grace c16_" "_"(1/4,-1/16)"  c4^"(1/4,0)"  \grace {
2075   [c16_"(2/4,-1/8)"  d16^"(2/4,-1/16)" ] } c4_" "_"(2/4,0)"
2076   }
2077 \paper {  linewidth = 8.\cm }
2078 }
2079 @end lilypond
2080
2081 The advantage of this approach is that you can use almost any lilypond
2082 construction together with grace notes, for example slurs and clef
2083 changes may appear halfway in between grace notes:
2084
2085 @lilypond[relative=2,verbatim,fragment] 
2086   c4  \grace { [ c16 c, \clef bass c, b(] }  )c4 
2087 @end lilypond
2088
2089 The placement of these grace notes is synchronized between different
2090 staves, using this grace timing.
2091
2092 @lilypond[relative=2,verbatim,fragment] 
2093 < \context Staff = SA { e4 \grace { c16 d e f } e4 }
2094   \context Staff = SB { c4 \grace { g8 b } c4 } >
2095 @end lilypond
2096
2097
2098 Unbeamed eighth notes and shorter by default have a slash through the
2099 stem. This can be controlled with object property @code{stroke-style} of
2100 @internalsref{Stem}. The change in formatting is accomplished by
2101 inserting @code{\startGraceMusic} before handling the grace notes, and
2102 @code{\stopGraceMusic} after finishing the grace notes.
2103 You can add to these definitions to globally change grace note
2104 formatting. The standard definitions are in @file{ly/grace-init.ly}.
2105
2106 [TODO discuss Scheme functionality.]
2107
2108
2109 Notice how the @code{\override} is carefully matched with a @code{\revert}.
2110
2111 @cindex slash
2112 @cindex grace slash
2113
2114 @lilypond[fragment,verbatim]
2115 \relative c'' \context Voice {
2116   \grace c8 c4 \grace { [c16 c16] } c4
2117   \grace { 
2118     \property Voice.Stem \override #'stroke-style = #'() 
2119     c16 
2120     \property Voice.Stem \revert #'stroke-style
2121   } c4
2122 }
2123 @end lilypond
2124
2125
2126
2127 If you want to end a note with a grace note, then the standard trick
2128 is to put the grace notes before a phantom ``space note'', e.g.
2129 @lilypond[fragment,verbatim, relative=2]
2130 \context Voice {
2131     < { d1^\trill ( }
2132      { s2 \grace { [c16 d] } } >
2133    )c4
2134 }
2135 @end lilypond
2136
2137 A @code{\grace} section has some default values, and LilyPond will
2138 use those default values unless you specify otherwise inside the
2139 @code{\grace} section.  For example, if you specify \slurUp
2140 @emph{before} your @code{\grace} section, a slur which starts inside
2141 the @code{\grace} won't be forced up, even if the slur ends outside
2142 of the @code{\grace}.  Note the difference between the first and
2143 second bars in this example:
2144
2145 @lilypond[fragment,verbatim]
2146 \relative c'' \context Voice {
2147     \slurUp
2148     \grace {
2149         a4 ( }
2150     ) a4 a4 () a2
2151     \slurBoth
2152
2153     \grace {
2154         \slurUp
2155         a4 ( }
2156     ) a4 a4 () a2
2157     \slurBoth
2158
2159 }
2160 @end lilypond
2161
2162
2163 @refbugs
2164
2165 Grace notes can not be used in the smallest size (@file{paper11.ly}).
2166
2167 Grace note synchronization can also lead to surprises. Staff notation,
2168 such as key signatures, barlines, etc. are also synchronized. Take
2169 care when you mix staves with grace notes and staves without.
2170
2171 @lilypond[relative=2,verbatim,fragment]
2172 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
2173   \context Staff = SB { c4 \bar "|:"  d4 } >
2174 @end lilypond
2175
2176 Grace sections should only be used within sequential music
2177 expressions.  Nesting, juxtaposing, or ending sequential music with a
2178 grace section is not supported, and might produce crashes or other
2179 errors.
2180
2181
2182 @node Glissando 
2183 @subsection Glissando
2184 @cindex Glissando 
2185
2186 @cindex @code{\glissando}
2187
2188 A glissando line can be requested by attaching a @code{\glissando} to
2189 a note:
2190
2191 @lilypond[fragment,relative,verbatim]
2192   c'-\glissando c'
2193 @end lilypond
2194
2195 @refbugs
2196
2197 Printing of an additional text (such as @emph{gliss.}) must be done
2198 manually. See also @seeinternals{Glissando}.
2199
2200
2201
2202 @c .   {Dynamics}
2203 @node Dynamics
2204 @subsection Dynamics
2205 @cindex Dynamics
2206
2207
2208
2209 @cindex @code{\ppp}
2210 @cindex @code{\pp}
2211 @cindex @code{\p}
2212 @cindex @code{\mp}
2213 @cindex @code{\mf}
2214 @cindex @code{\f}
2215 @cindex @code{\ff}
2216 @cindex @code{\fff}
2217 @cindex @code{\ffff}
2218 @cindex @code{\fp}
2219 @cindex @code{\sf}
2220 @cindex @code{\sff}
2221 @cindex @code{\sp}
2222 @cindex @code{\spp}
2223 @cindex @code{\sfz}
2224 @cindex @code{\rfz}
2225
2226
2227 Absolute dynamic marks are specified using an identifier after a
2228 note: @code{c4-\ff}.  The available dynamic marks are: @code{\ppp},
2229 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
2230 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
2231 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
2232
2233 @lilypond[verbatim,singleline,fragment,relative]
2234   c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
2235   c2\sf c\rfz
2236 @end lilypond
2237
2238 @cindex @code{\cr}
2239 @cindex @code{\rc}
2240 @cindex @code{\decr}
2241 @cindex @code{\rced}
2242 @cindex @code{\<}
2243 @cindex @code{\>}
2244 @cindex @code{\"!}
2245
2246
2247 A crescendo mark is started with @code{\cr} and terminated with
2248 @code{\rc} (the textual reverse of @code{cr}).  A decrescendo mark is
2249 started with @code{\decr} and terminated with @code{\rced}.  There are
2250 also shorthands for these marks.  A crescendo can be started with
2251 @code{\<} and a decrescendo can be started with @code{\>}.  Either one
2252 can be terminated with @code{\!}.  Note that @code{\!}  must go before
2253 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
2254 after the last note.  Because these marks are bound to notes, if you
2255 want several marks during one note, you have to use spacer notes.
2256
2257 @lilypond[fragment,verbatim,center,quote]
2258   c'' \< \! c''   d'' \decr e'' \rced 
2259   < f''1 { s4 s4 \< \! s4 \> \! s4 } >
2260 @end lilypond
2261 This may give rise to very short hairpins. Use @code{minimum-length}
2262 in Voice.HairPin to lengthen these, e.g.
2263
2264 @example
2265  \property Staff.Hairpin \override #'minimum-length = #5
2266 @end example
2267
2268 You can also use a text saying @emph{cresc.} instead of hairpins. Here
2269 is an example how to do it:
2270
2271 @lilypond[fragment,relative=2,verbatim]
2272   c4 \cresc c4 \endcresc c4
2273 @end lilypond
2274
2275
2276 @cindex crescendo
2277 @cindex decrescendo
2278
2279 You can also supply your own texts:
2280 @lilypond[fragment,relative,verbatim]
2281   \context Voice {
2282     \property Voice.crescendoText = "cresc. poco"
2283     \property Voice.crescendoSpanner = #'dashed-line
2284     a'2\mf\< a a \!a 
2285   }
2286 @end lilypond
2287
2288 @cindex diminuendo
2289
2290 Dynamics are objects of @internalsref{DynamicText} and
2291 @internalsref{Hairpin}. Vertical positioning of these symbols is
2292 handled by the @internalsref{DynamicLineSpanner} object.  If you want to
2293 adjust padding or vertical direction of the dynamics, you must set
2294 properties for the @internalsref{DynamicLineSpanner} object. Predefined
2295 identifiers to set the vertical direction are \dynamicUp and
2296 \dynamicDown.
2297
2298 @cindex direction, of dynamics
2299 @cindex @code{\dynamicDown}
2300 @cindex @code{\dynamicUp}
2301
2302 @c .  {Repeats}
2303 @node Repeats
2304 @section Repeats
2305
2306
2307 @cindex repeats
2308 @cindex @code{\repeat}
2309
2310 To specify repeats, use the @code{\repeat} keyword.  Since repeats
2311 should work differently when played or printed, there are a few
2312 different variants of repeats.
2313
2314 @table @code
2315 @item unfold
2316 Repeated music is fully written (played) out.  Useful for MIDI
2317 output, and entering repetitive music.
2318
2319 @item volta
2320 This is the normal notation: Repeats are not written out, but
2321 alternative endings (voltas) are printed, left to right.
2322
2323 @item fold
2324 Alternative endings are written stacked. This has limited use but may be
2325 used to typeset two lines of lyrics in songs with repeats, see
2326 @inputfileref{input,star-spangled-banner.ly}.
2327
2328 @item tremolo
2329 Make tremolo beams.
2330
2331 @item percent
2332 Make beat or measure repeats. These look like percent signs.
2333
2334 @end table  
2335
2336 @menu
2337 * Repeat syntax::               
2338 * Repeats and MIDI::            
2339 * Manual repeat commands::      
2340 * Tremolo repeats::             
2341 * Tremolo subdivisions::        
2342 * Measure repeats::             
2343 @end menu
2344
2345 @node Repeat syntax
2346 @subsection Repeat syntax
2347
2348 The syntax for repeats is
2349
2350 @example
2351   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2352 @end example
2353
2354 If you have alternative endings, you may add
2355 @cindex @code{\alternative}
2356 @example
2357  \alternative @code{@{} @var{alternative1}
2358             @var{alternative2}
2359             @var{alternative3} @dots{} @code{@}}
2360 @end example
2361 where each @var{alternative} is a music expression.
2362
2363 Normal notation repeats are used like this:
2364 @lilypond[fragment,verbatim]
2365   c'1
2366   \repeat volta 2 { c'4 d' e' f' }
2367   \repeat volta 2 { f' e' d' c' }
2368 @end lilypond
2369
2370 With alternative endings:
2371 @lilypond[fragment,verbatim]
2372   c'1
2373   \repeat volta 2 {c'4 d' e' f'} 
2374   \alternative { {d'2 d'} {f' f} }
2375 @end lilypond
2376
2377 Folded repeats look like this:
2378
2379
2380 @lilypond[fragment,verbatim]
2381   c'1
2382   \repeat fold 2 {c'4 d' e' f'} 
2383   \alternative { {d'2 d'} {f' f} }
2384
2385 @end lilypond
2386
2387 If you don't give enough alternatives for all of the repeats, then
2388 the first alternative is assumed to be repeated often enough to equal
2389 the specified number of repeats.
2390
2391 @lilypond[fragment,verbatim]
2392 \context Staff {
2393   \relative c' {
2394     \partial 4
2395     \repeat volta 4 { e | c2 d2 | e2 f2 | }
2396     \alternative { { g4 g g } { a | a a a a | b2. } }
2397   }
2398 }
2399 @end lilypond
2400
2401 @node Repeats and MIDI
2402 @subsection Repeats and MIDI
2403
2404 @cindex expanding repeats
2405
2406 For instructions on how to unfoldi repeats for MIDI output, see
2407 the example file @inputfileref{input/test,unfold-all-repeats.ly}.
2408
2409
2410 @refbugs
2411
2412 Notice that timing information is not remembered at the start of an
2413 alternative, so you have to reset timing information after a repeat,
2414 e.g. using a bar-check (See @ref{Bar check}), setting
2415 @code{Score.measurePosition} or entering @code{\partial}.  Slurs or ties
2416 are also not repeated.
2417
2418 It is possible to nest @code{\repeat}s, although this probably is only
2419 meaningful for unfolded repeats.
2420
2421 Folded repeats offer little more over simultaneous music.
2422
2423 @node Manual repeat commands
2424 @subsection Manual repeat commands
2425
2426 @cindex @code{repeatCommands}
2427
2428 The property @code{repeatCommands} can be used to control the layout of
2429 repeats. Its value is a Scheme list of repeat commands, where each repeat
2430 command can be
2431
2432 @table @code
2433 @item 'start-repeat
2434  Print a |: bar line
2435 @item 'end-repeat
2436  Print a :| bar line
2437 @item (volta . @var{text})
2438  Print a volta bracket saying @var{text}. The text can be specified as
2439 a text string or as a markup text, see @ref{Text markup}. Do not
2440 forget to change the font, as the default number font does not contain
2441 alphabetic characters.
2442 @item (volta . #f) 
2443  Stop a running volta bracket
2444 @end table
2445
2446 @lilypond[verbatim, fragment]
2447  c''4
2448     \property Score.repeatCommands = #'((volta "93") end-repeat)
2449  c''4 c''4
2450     \property Score.repeatCommands = #'((volta #f))
2451  c''4 c''4
2452 @end lilypond
2453
2454
2455 Repeats brackets are @internalsref{VoltaBracket} objects.
2456
2457 @node Tremolo repeats
2458 @subsection Tremolo repeats
2459 @cindex tremolo beams
2460
2461 To place tremolo marks between notes, use @code{\repeat} with tremolo
2462 style.  
2463 @lilypond[verbatim,center,singleline]
2464 \score { 
2465   \context Voice \notes\relative c' {
2466     \repeat "tremolo" 8 { c16 d16 }
2467     \repeat "tremolo" 4 { c16 d16 }    
2468     \repeat "tremolo" 2 { c16 d16 }
2469     \repeat "tremolo" 4 c16
2470   }
2471 }
2472 @end lilypond
2473
2474 Tremolo beams are @internalsref{Beam} objects. Single stem tremolos are
2475 @internalsref{StemTremolo}. The single stem tremolo @emph{must} be
2476 entered without @code{@{} and @code{@}}.  
2477
2478 @refbugs
2479
2480 Only powers of two and undotted notes are supported repeat counts.
2481
2482 @node Tremolo subdivisions
2483 @subsection Tremolo subdivisions
2484 @cindex tremolo marks
2485 @cindex @code{tremoloFlags}
2486
2487 Tremolo marks can be printed on a single note by adding
2488 `@code{:}[@var{length}]' after the note.  The length must be at least 8.
2489 A @var{length} value of 8 gives one line across the note stem.  If the
2490 length is omitted, then then the last value (stored in
2491 @code{Voice.tremoloFlags}) is used.
2492
2493 @lilypond[verbatim,fragment,center]
2494   c'2:8 c':32 | c': c': |
2495 @end lilypond
2496
2497 @refbugs
2498
2499
2500 Tremolos in this style do not carry over into the MIDI output.
2501
2502
2503 @node Measure repeats
2504 @subsection Measure repeats
2505
2506 @cindex percent repeats
2507 @cindex measure repeats
2508
2509 In the @code{percent} style, a note pattern can be repeated. It is
2510 printed once, and then the pattern is replaced with a special sign.
2511 Patterns of a one and two measures are replaced by percent-like signs,
2512 patterns that divide the measure length are replaced by slashes.
2513
2514 @lilypond[verbatim,singleline]
2515  \context Voice { \repeat  "percent" 4  { c'4 }
2516     \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2517 }
2518 @end lilypond   
2519
2520 The signs are represented by these objects: @internalsref{RepeatSlash} and
2521 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2522
2523 @refbugs
2524
2525 You can not nest percent repeats, e.g. by filling in the first measure
2526 with slashes, and repeating that measure with percents.
2527
2528 @node Rhythmic music
2529 @section Rhythmic music
2530
2531 Sometimes you might want to show only the rhythm of a melody.  This can
2532 be done with the rhythmic staff. All pitches of notes on such a staff
2533 are squashed, and the  staff itself  looks has  a single staff line:
2534
2535 @lilypond[fragment,relative,verbatim]
2536   \context RhythmicStaff {
2537       \time 4/4
2538       c4 e8 f  g2 | r4 g r2 | g1:32 | r1 |
2539   }
2540 @end lilypond
2541
2542 @menu
2543 * Percussion staves::           
2544 @end menu
2545
2546 @node Percussion staves
2547 @subsection Percussion staves
2548 @cindex percussion
2549 @cindex drums
2550 To typeset more than one piece of percussion to be played by the same
2551 musician one typically uses a multiline staff where each staff
2552 position refers to a specific piece of percussion.
2553
2554 LilyPond is shipped with a bunch of scheme functions which allows you
2555 to do this fairly easily.
2556
2557 The system is based on the general midi drum-pitches.
2558 In order to use the drum pitches you include
2559 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2560 variable @code{drum-pitch-names} - which definition can be read in
2561 @file{scm/drums.scm}. You see that each piece of percussion has a full
2562 name and an abbreviated name - and you may freely select whether to
2563 refer to the full name or the abbreviation in your music definition.
2564
2565 To typeset the music on a staff you apply the scheme function
2566 @code{drums->paper} to the percussion music. This function takes a
2567 list of percussion instrument names, notehead scripts and staff
2568 positions (that is: pitches relative to the C-clef) and uses this to
2569 transform the input music by moving the pitch, changing the notehead
2570 and (optionally) adding a script:
2571 @lilypond[singleline,verbatim,quote]
2572 \include "drumpitch-init.ly"
2573 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2574 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2575 \score {
2576     \apply #(drums->paper 'drums) \context Staff <
2577         \clef percussion
2578         \context Voice = up { \voiceOne \up }
2579         \context Voice = down { \voiceTwo \down }
2580     >
2581 }
2582
2583 @end lilypond
2584 In the above example the music was transformed using the list @code{'drums}.
2585 Currently the following lists are defined in @file{scm/drums.scm}:
2586 @table @code
2587 @item 'drums
2588 To typeset a typical drum kit on a five-line staff.
2589
2590 @lilypond[noindent]
2591 \include "drumpitch-init.ly"
2592 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2593     bd sn ss tomh tommh tomml toml tomfh tomfl }
2594 mus = \notes  { cymc cyms cymr hh hhc hho hhho hhp cb hc
2595     bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2596 \score {
2597     <
2598         \apply #(drums->paper 'drums) \context Staff <
2599             \clef percussion
2600             \mus
2601         >
2602         \context Lyrics \nam 
2603     >
2604     \paper {
2605         linewidth = 100.0\mm
2606         \translator {
2607             \StaffContext
2608             \remove Bar_engraver
2609             \remove Time_signature_engraver
2610             minimumVerticalExtent = #'(-4.0 . 5.0)
2611         }
2612         \translator {
2613             \VoiceContext
2614             \remove Stem_engraver
2615         }
2616    }   
2617 }
2618 @end lilypond
2619
2620 Notice that the scheme supports six different toms.
2621 If you are using fewer toms then you simply select the toms that produce
2622 the desired result - i.e. to get toms on the three middle lines you
2623 use @code{tommh}, @code{tomml} and @code{tomfh}.
2624
2625 Because the general midi contain no rimshots we use the sidestick for
2626 this purpose instead.
2627 @item 'timbales
2628 To typeset timbales on a two line staff.
2629 @lilypond[singleline]
2630 \include "drumpitch-init.ly"
2631 nam = \lyrics { timh ssh timl ssl cb }
2632 mus = \notes  { timh ssh timl ssl cb s16 }
2633 \score {
2634     <
2635         \apply #(drums->paper 'timbales) \context Staff <
2636             \clef percussion
2637             \mus
2638         >
2639         \context Lyrics \nam 
2640     >
2641     \paper {
2642         \translator {
2643             \StaffContext
2644             \remove Bar_engraver
2645             \remove Time_signature_engraver
2646             StaffSymbol \override #'line-count = #2
2647             StaffSymbol \override #'staff-space = #2
2648             minimumVerticalExtent = #'(-3.0 . 4.0)
2649         }
2650         \translator {
2651             \VoiceContext
2652             \remove Stem_engraver
2653         }
2654
2655     }   
2656 }
2657 @end lilypond
2658 @item 'congas
2659 To typeset congas on a two line staff.
2660 @lilypond[singleline]
2661 \include "drumpitch-init.ly"
2662 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2663 mus = \notes  { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2664 \score {
2665     <
2666         \apply #(drums->paper 'congas) \context Staff <
2667             \clef percussion
2668             \mus
2669         >
2670         \context Lyrics \nam 
2671     >
2672     \paper {
2673         \translator {
2674             \StaffContext
2675             \remove Bar_engraver
2676             \remove Time_signature_engraver
2677             StaffSymbol \override #'line-count = #2
2678             StaffSymbol \override #'staff-space = #2
2679             minimumVerticalExtent = #'(-3.0 . 4.0)
2680         }
2681         \translator {
2682             \VoiceContext
2683             \remove Stem_engraver
2684         }
2685     }   
2686 }
2687 @end lilypond
2688 @item 'bongos
2689 To typeset bongos on a two line staff.
2690 @lilypond[singleline]
2691 \include "drumpitch-init.ly"
2692 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2693 mus = \notes  { boh boho bohm ssh bol bolo bolm ssl s16 }
2694 \score {
2695     <
2696         \apply #(drums->paper 'bongos) \context Staff <
2697             \clef percussion
2698             \mus
2699         >
2700         \context Lyrics \nam 
2701     >
2702     \paper {
2703         \translator {
2704             \StaffContext
2705             \remove Bar_engraver
2706             \remove Time_signature_engraver
2707             StaffSymbol \override #'line-count = #2
2708             StaffSymbol \override #'staff-space = #2
2709             minimumVerticalExtent = #'(-3.0 . 4.0)
2710         }
2711         \translator {
2712             \VoiceContext
2713             \remove Stem_engraver
2714         }
2715     }   
2716 }
2717 @end lilypond
2718 @item 'percussion
2719 To typeset all kinds of simple percussion on one line staves.
2720 @lilypond[singleline]
2721 \include "drumpitch-init.ly"
2722 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2723 mus = \notes  { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2724 \score {
2725     <
2726         \apply #(drums->paper 'percussion) \context Staff <
2727             \clef percussion
2728             \mus
2729         >
2730         \context Lyrics \nam 
2731     >
2732     \paper {
2733         \translator {
2734             \StaffContext
2735             \remove Bar_engraver
2736             \remove Time_signature_engraver
2737             StaffSymbol \override #'line-count = #1
2738             minimumVerticalExtent = #'(-2.0 . 3.0)
2739         }
2740         \translator {
2741             \VoiceContext
2742             \remove Stem_engraver
2743         }
2744     }   
2745 }
2746 @end lilypond
2747 @end table
2748
2749 If you don't like any of the predefined lists you can define your own
2750 list at the top of your file:
2751
2752 @lilypond[singleline, verbatim]
2753 #(define mydrums `(
2754         (bassdrum     default   #f        ,(ly:make-pitch -1 2 0))
2755         (snare        default   #f        ,(ly:make-pitch 0 1 0))
2756         (hihat        cross     #f        ,(ly:make-pitch 0 5 0))
2757         (pedalhihat   xcircle   "stopped" ,(ly:make-pitch 0 5 0))
2758         (lowtom       diamond   #f        ,(ly:make-pitch -1 6 0))
2759 ))
2760 \include "drumpitch-init.ly"
2761 up = \notes { hh8 hh hh hh hhp4 hhp }
2762 down = \notes { bd4 sn bd toml8 toml }
2763 \score {    
2764     \apply #(drums->paper 'mydrums) \context Staff <
2765         \clef percussion
2766         \context Voice = up { \voiceOne \up }
2767         \context Voice = down { \voiceTwo \down }
2768     >
2769 }
2770 @end lilypond
2771
2772 To use a modified existing list instead of building your own from
2773 scratch you can append your modifications to the start of the existing
2774 list:
2775
2776 @example
2777 #(define mydrums (append `(
2778    (bassdrum default #f ,(ly:make-pitch -1 2 0))
2779    (lowtom   diamond #f ,(ly:make-pitch -1 6 0))
2780 ) drums ))
2781 @end example
2782
2783 @c FIXME: Too many levels of headers when using subsubsections.
2784 @c Perhaps junk subsection ``Percussion staves''
2785 @subsubsection Percussion staves with normal staves
2786 When you include @file{drumpitch-init.ly} then the default pitches
2787 are overridden so that you after the inclusion cannot use the common
2788 dutch pitch names anymore. Hence you might wan't to reinclude
2789 @file{nederlands.ly} after the drum-pattern-definitions:
2790 @lilypond[singleline,verbatim]
2791 \include "drumpitch-init.ly"
2792 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2793 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2794 \include "nederlands.ly"
2795 bass = \notes \transpose c c,, { a4. e8 r e g e }
2796 \score {
2797     <
2798         \apply #(drums->paper 'drums) \context Staff = drums <
2799             \clef percussion
2800             \context Voice = up { \voiceOne \up }
2801             \context Voice = down { \voiceTwo \down }
2802         >
2803         \context Staff = bass { \clef "F_8" \bass }
2804     >
2805 }
2806 @end lilypond
2807
2808 @subsubsection Percussion midi output
2809 In order to produce correct midi output you need to produce two score
2810 blocks - one for the paper and one for the midi.
2811 To use the percussion channel you set the property @code{instrument}
2812 to @code{'drums}. Because the drum-pitches themself are similar to the
2813 general midi pitches all you have to do is to insert the voices with
2814 none of the scheme functions to get the correct midi output:
2815
2816 @example
2817 \score @{    
2818     \apply #(drums->paper 'mydrums) \context Staff <
2819         \clef percussion
2820         \context Voice = up @{ \voiceOne \up @}
2821         \context Voice = down @{ \voiceTwo \down @}
2822     >
2823     \paper@{@}
2824 @}
2825 \score @{    
2826     \context Staff <
2827         \property Staff.instrument = #'drums
2828         \up \down
2829     >
2830     \midi@{@}
2831 @}
2832 @end example
2833
2834 @refbugs
2835
2836 This scheme is to be considered a temporary implementation. Even
2837 though the scheme will probably keep on working then the future might
2838 bring some other way of typesetting drums, and probably
2839 there will be made no great efforts in keeping things downwards
2840 compatible.
2841
2842 @c . {Piano music}
2843 @node Piano music
2844 @section Piano music
2845
2846 Piano music is an odd type of notation. Piano staves are two normal
2847 staves coupled with a brace.  The staves are largely independent, but
2848 sometimes voices can cross between the two staves.  The
2849 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2850 behavior.  In this section we discuss the @internalsref{PianoStaff} and some
2851 other pianistic peculiarities.
2852
2853
2854 @menu
2855 * Automatic staff changes::     
2856 * Manual staff switches::       
2857 * Pedals::                      
2858 * Arpeggio::                    
2859 * Voice follower lines::        
2860 @end menu 
2861
2862 @refbugs
2863
2864 There is no support for putting chords across staves.  You can get
2865 this result by increasing the length of the stem in the lower stave so
2866 it reaches the stem in the upper stave, or vice versa. An example is
2867 included with the distribution as @inputfileref{input/test,stem-cross-staff.ly}.
2868
2869 @cindex cross staff stem
2870 @cindex stem, cross staff
2871
2872
2873 @c fixme: should have hyperlinks as well.
2874
2875
2876
2877
2878 @c .   {Automatic staff changes}
2879 @node Automatic staff changes
2880 @subsection Automatic staff changes
2881 @cindex Automatic staff changes
2882
2883 Voices can switch automatically between the top and the bottom
2884 staff. The syntax for this is
2885 @example
2886         \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2887 @end example        
2888 The autochanger switches on basis of pitch (central C is the turning
2889 point), and it looks ahead skipping over rests to switch rests in
2890 advance. Here is a practical example:
2891         
2892 @lilypond[verbatim,singleline,quote]
2893 \score { \notes \context PianoStaff <
2894   \context Staff = "up" {
2895     \autochange Staff \context Voice = VA < \relative c' {
2896        g4 a  b c d r4 a g } > }
2897   \context Staff = "down" {
2898        \clef bass
2899        s1*2
2900 } > }
2901 @end lilypond
2902 Spacer rests are used to prevent the bottom staff from
2903 terminating too soon.
2904
2905
2906 @node Manual staff switches
2907 @subsection Manual staff switches
2908
2909 @cindex manual staff switches
2910 @cindex staff switch, manual
2911
2912 Voices can be switched between staves manually, using the following command:
2913 @example
2914   \translator Staff = @var{staffname} @var{music}
2915 @end example
2916 The string @var{staffname} is the name of the staff. It switches the
2917 current voice from its current staff to the Staff called
2918 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2919 @code{"down"}.
2920
2921 @c .   {Pedals}
2922 @node Pedals
2923 @subsection Pedals
2924 @cindex Pedals
2925
2926 Piano pedal instruction can be expressed using 
2927 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2928 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2929
2930 The symbols that are printed can be modified by setting
2931 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2932 Sustain, Sostenuto or UnaCorda.  Refer to the generated documentation of
2933 @internalsref{SustainPedal}, for example, for more information.
2934
2935 Pedals can also be indicated by a sequence of brackets, by setting the 
2936 @code{pedal-type} property of SustainPedal objects: 
2937
2938 @lilypond[fragment,verbatim]
2939 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2940 c''4 \sustainDown d''4 e''4 a'4
2941 \sustainUp \sustainDown
2942  f'4 g'4 a'4 \sustainUp
2943 @end lilypond
2944
2945 A third style of pedal notation is a mixture of text and brackets,
2946 obtained by setting @code{pedal-type} to @code{mixed}:
2947
2948 @lilypond[fragment,verbatim]
2949 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2950 c''4 \sustainDown d''4 e''4 c'4
2951 \sustainUp \sustainDown
2952  f'4 g'4 a'4 \sustainUp
2953 @end lilypond
2954
2955 The default '*Ped' style for sustain and damper pedals corresponds to
2956 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2957 for a sostenuto pedal:
2958
2959 @lilypond[fragment,verbatim]
2960 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2961 @end lilypond
2962
2963 For fine-tuning of the appearance of a pedal bracket, the properties
2964 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2965 @code{PianoPedalBracket} objects (see the detailed documentation of
2966 @internalsref{PianoPedalBracket}) can be modified.  For example, the bracket
2967 may be extended to the end of the note head.
2968
2969 @lilypond[fragment,verbatim]
2970 \property Staff.PianoPedalBracket \override
2971    #'shorten-pair = #'(0 . -1.0)
2972 c''4 \sostenutoDown d''4 e''4 c'4
2973 f'4 g'4 a'4 \sostenutoUp
2974 @end lilypond
2975
2976 @node Arpeggio
2977 @subsection Arpeggio
2978 @cindex Arpeggio
2979
2980 @cindex broken arpeggio
2981 @cindex @code{\arpeggio}
2982
2983 You can specify an arpeggio sign on a chord by attaching an
2984 @code{\arpeggio} to a chord.
2985
2986
2987 @lilypond[fragment,relative,verbatim]
2988   <<c e g c>>-\arpeggio
2989 @end lilypond
2990
2991 When an arpeggio crosses staves in piano music, you attach an arpeggio
2992 to the chords in both staves, and set
2993 @code{PianoStaff.connectArpeggios}.
2994
2995 @lilypond[fragment,relative,verbatim]
2996   \context PianoStaff <
2997     \property PianoStaff.connectArpeggios = ##t
2998     \context Voice = one  { <<c' e g c>>-\arpeggio }
2999     \context Voice = other { \clef bass  <<c,, e g>>-\arpeggio}
3000   >  
3001 @end lilypond
3002
3003 This command creates @internalsref{Arpeggio} objects.  Cross staff arpeggios
3004 are @code{PianoStaff.Arpeggio}.
3005
3006 To add an arrow head to explicitly specify the direction of the
3007 arpeggio, you should set the arpeggio object property
3008 @code{arpeggio-direction}.
3009
3010 @lilypond[fragment,relative,verbatim]
3011   \context Voice {
3012      \property Voice.Arpeggio \set #'arpeggio-direction = #1
3013      <<c e g c>>-\arpeggio
3014      \property Voice.Arpeggio \set #'arpeggio-direction = #-1
3015      <<c e g c>>-\arpeggio
3016   }
3017 @end lilypond
3018
3019 A square bracket on the left indicates that the player should not
3020 arpeggiate the chord. To draw these brackets, set the
3021 @code{molecule-callback} property of @code{Arpeggio} or
3022 @code{PianoStaff.Arpeggio} objects to @code{\arpeggioBracket}, and use
3023 @code{\arpeggio} statements within the chords as before.
3024
3025 @lilypond[fragment,relative,verbatim]
3026   \context PianoStaff <
3027     \property PianoStaff.connectArpeggios = ##t
3028     \property PianoStaff.Arpeggio \override
3029         #'molecule-callback = \arpeggioBracket
3030     \context Voice = one  { <<c' e g c>>-\arpeggio }
3031     \context Voice = other { \clef bass  <<c,, e g>>-\arpeggio }
3032   >  
3033 @end lilypond
3034
3035
3036 @refbugs
3037
3038 It is not possible to mix connected arpeggios and unconnected
3039 arpeggios in one PianoStaff at the same time.
3040
3041
3042
3043 @node  Voice follower lines
3044 @subsection Voice follower lines
3045
3046 @cindex follow voice
3047 @cindex staff switching
3048 @cindex cross staff
3049
3050 @cindex @code{followVoice}
3051
3052 Whenever a voice switches to another staff a line connecting the notes
3053 can be printed automatically. This is enabled if the property
3054 @code{PianoStaff.followVoice} is set to true:
3055
3056 @lilypond[fragment,relative,verbatim]
3057   \context PianoStaff <
3058     \property PianoStaff.followVoice = ##t
3059     \context Staff \context Voice {
3060       c1
3061       \translator Staff=two
3062       b2 a
3063     }
3064     \context Staff=two {\clef bass \skip 1*2 }
3065   >  
3066 @end lilypond
3067
3068 The associated object is @internalsref{VoiceFollower}.
3069
3070
3071 @node Vocal music
3072 @section Vocal music
3073
3074 For a discussion of how to put lyrics into a score, see section
3075 @code{Printing lyrics} in the tutorial.
3076
3077 [TODO: Move lyrics section from tutorial to here?]
3078
3079 See also the sections on @ref{Slurs} and @ref{Breath marks}.
3080
3081 [TODO: Move slurs / breath marks section to here?]
3082
3083 [TODO: Write subsection upon usage of ChoirStaff.]
3084
3085 For entering quotes in Lyrics mode, use the following
3086 @example
3087 "\"God\"" is "`King'"
3088 @end example
3089
3090 You can use empty syllables, e.g. @code{_4} or @code{" "4} to enter
3091 lyrics. This can confuse the LilyPond -- for example, this might put
3092 (empty) lyrics under rests. To remedy this, use @code{\skip}.
3093
3094
3095 @menu
3096 * Ambitus::
3097 @end menu
3098
3099 @node Ambitus
3100 @subsection Ambitus
3101 @cindex ambitus
3102
3103 The term @emph{ambitus} denotes a range of pitches for a given voice in
3104 a part of music.  It also may denote the pitch range that a musical
3105 instrument is capable of playing.  Most musical instruments have their
3106 ambitus standardized (or at least there is agreement upon the minimal
3107 ambitus of a particular type of instrument), such that a composer or
3108 arranger of a piece of music can easily meet the ambitus constraints of
3109 the targeted instrument.  However, the ambitus of the human voice
3110 depends on individual physiological state, including education and
3111 training of the voice.  Therefore, a singer potentially has to check for
3112 each piece of music if the ambitus of that piece meets his individual
3113 capabilities.  This is why the ambitus of a piece may be of particular
3114 value to vocal performers.
3115
3116 The ambitus is typically notated on a per-voice basis at the very
3117 beginning of a piece, e.g. nearby the initial clef or time signature of
3118 each staff.  The range is graphically specified by two noteheads, that
3119 represent the minimum and maximum pitch.  Some publishers use a textual
3120 notation: they put the range in words in front of the corresponding
3121 staff.  Lilypond currently only supports the graphical ambitus notation.
3122
3123 To apply, simply add the @internalsref{Ambitus_engraver} to the
3124 @internalsref{Voice} context, as shown in the below example:
3125
3126 @lilypond[singleline,verbatim]
3127 upper = \notes \relative c {
3128   \clef "treble"
3129   \key c \minor
3130   as'' c e2 bes f cis d4 e f2 g
3131 }
3132 lower = \notes \relative c {
3133   \clef "treble"
3134   \key e \major
3135   e'4 b g a c es fis a cis b a g f e d2
3136 }
3137 \score {
3138   \context ChoirStaff {
3139     <
3140       \context Staff = one { \upper }
3141       \context Staff = three { \lower }
3142     >
3143   }
3144   \paper {
3145     \translator {
3146       \VoiceContext
3147       \consists Ambitus_engraver
3148     }
3149   }
3150 }
3151 @end lilypond
3152
3153 The shape of the note heads to use can be changed via the
3154 @code{note-head-style} property, which holds the glyph name of the note
3155 head (see also @ref{Ancient note heads}).  The vertical line between the
3156 upper and lower head can be switched on or off via the @code{join-heads}
3157 property.  Example:
3158
3159 @example
3160 \translator @{
3161   \VoiceContext
3162   \consists Ambitus_engraver
3163   Ambitus \set #'note-head-style = #'noteheads-2mensural
3164   Ambitus \set #'join-heads = ##f
3165 @}
3166 @end example
3167
3168 By default, the ambitus grob is put before the clef.  You can control
3169 this behaviour through the @code{breakAlignOrder} property of the score
3170 context by redefining the order, e.g. with the following addition to the
3171 paper block:
3172
3173 @example
3174 \translator @{
3175   \ScoreContext
3176   breakAlignOrder = #'(
3177     instrument-name
3178     left-edge
3179     span-bar
3180     breathing-sign
3181     clef
3182     ambitus
3183     key-signature
3184     staff-bar
3185     time-signature
3186     custos
3187   )
3188 @}
3189 @end example
3190
3191 @node Tablatures
3192 @section Tablatures
3193
3194 Tablature notation is used for notating music for plucked string
3195 instruments.  It notates pitches not by using note heads, but by
3196 indicating on which string and fret a note must be played.  LilyPond
3197 offers limited support for tablature.
3198
3199 @menu
3200 * Tablatures basic::            
3201 * Non-guitar tablatures::       
3202 * Tablature in addition to normal staff::  
3203 @end menu
3204
3205 @node Tablatures basic
3206 @subsection Tablatures basic
3207 @cindex Tablatures basic
3208
3209 Tablature can be typeset with Lilypond by using the
3210 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
3211 tablature is a recent feature in Lilypond, most of the guitar special
3212 effects such as bend are not yet supported.
3213
3214 With the @internalsref{TabStaff}, the string number associated to a note
3215 is given as a backslash followed by the string number, e.g. @code{c4\3} for a C
3216 quarter on the third string. By default, string 1 is the highest one, and the
3217 tuning defaults to the standard guitar tuning (with 6 strings).
3218
3219 @lilypond[fragment,verbatim]
3220   \context TabStaff <
3221     \notes {
3222       a,4\5 c'\2 a\3 e'\1
3223       e\4 c'\2 a\3 e'\1
3224     }
3225   >  
3226 @end lilypond
3227
3228 If you do not specify a string number then lilypond automatically selects one.
3229 The selection is controlled by the translator property @code{minimumFret}. -- LilyPond
3230 simply selects the first string that does not give a fret number less than
3231 @code{minimumFret}. Default is 0.
3232
3233 Notice that LilyPond does not handle chords in any special way, and hence
3234 the automatic string selector may easily select the same string to two notes in a chord.
3235
3236 @example
3237 e8 fis gis a b cis' dis' e'
3238 \property TabStaff.minimumFret = #8
3239 e8 fis gis a b cis' dis' e'
3240 @end example
3241 @lilypond[noindent]
3242 frag = \notes {
3243     \key e \major
3244     e8 fis gis a b cis' dis' e'
3245     \property TabStaff.minimumFret = #8
3246     e8 fis gis a b cis' dis' e'
3247 }
3248 \score {
3249   \context StaffGroup <
3250     \context Staff { \clef "G_8" \frag }
3251     \context TabStaff { \frag }
3252   >
3253 }
3254 @end lilypond
3255
3256 @node Non-guitar tablatures
3257 @subsection Non-guitar tablatures
3258 @cindex Non-guitar tablatures
3259
3260 There are many ways to customize Lilypond tablatures.
3261
3262 First you can change the number of strings, by setting the number of
3263 lines in the @internalsref{TabStaff} (the @code{line-count} property
3264 of TabStaff can only be changed using @code{\outputproperty}, for more
3265 information, see @ref{Tuning per object}.  You can change the strings
3266 tuning. A string tuning is given as a Scheme list with one integer
3267 number for each string, the number being the pitch of an open string.
3268
3269 (The numbers specified for stringTuning are the numbers of semitons
3270 to subtract --- or add --- starting the specified pitch by default
3271 middle C, in string order: thus the notes are e, a, d & g)
3272
3273 @lilypond[fragment,verbatim]
3274   \context TabStaff <
3275
3276     \outputproperty #(make-type-checker 'staff-symbol-interface)
3277                     #'line-count = #4
3278     \property TabStaff.stringTunings =  #'(-5 -10 -15 -20)
3279     
3280     \notes {
3281       a,4 c' a e' e c' a e'
3282     }
3283   > 
3284 @end lilypond
3285
3286 Finally, it is possible to change the Scheme function to format the
3287 tablature note text. The default is @var{fret-number-tablature-format},
3288 which uses the fret number, but for some instruments that may not use
3289 this notation, just create your own tablature-format function. This
3290 function takes three argument: the string number, the string tuning and
3291 the note pitch.
3292
3293
3294 @node Tablature in addition to normal staff
3295 @subsection Tablature in addition to normal staff
3296 @cindex Tablature in addition to normal staff
3297
3298 It is possible to typeset both tablature and a "normal" staff, as
3299 commonly done in many parts.
3300
3301 A common trick for that is to put the notes in a variables, and to hide
3302 the fingering information (which correspond to the string number) for
3303 the standard staff.
3304
3305 @c FIXME
3306 @c @lily pond[verbatim]
3307 @example
3308   part = \notes @{
3309     a,4-2 c'-5 a-4 e'-6
3310     e-3 c'-5 a-4 e'-6
3311   @}
3312   \score @{
3313     \context StaffGroup <
3314       \context Staff <
3315         % Hide fingering number
3316         \property Staff.Fingering \override #'transparent = ##t
3317
3318         \part
3319       >
3320       \context TabStaff <
3321         \property Staff.Stem \override #'direction = #1
3322
3323         \part
3324       >
3325     >
3326   @}
3327 @end example
3328 @c @end lilypond
3329
3330 @c . {Chords}
3331 @node Chords
3332 @section Chords
3333 @cindex Chords
3334
3335 LilyPond has support for both entering and printing chords. 
3336 @lilypond[verbatim,singleline]
3337 twoWays = \notes \transpose c c' {
3338   \chords {
3339     c1 f:sus4 bes/f
3340   }
3341   <<c e g>>
3342   <<f bes c'>>
3343   <<f bes d'>>
3344   }
3345
3346 \score {
3347    < \context ChordNames \twoWays
3348      \context Voice \twoWays > }
3349 @end lilypond
3350
3351 This example also shows that the chord printing routines do not try to
3352 be intelligent. If you enter @code{f bes d}, it does not interpret
3353 this as an inversion.
3354
3355 As you can see chords really are a set of pitches. They are internally
3356 stored as simultaneous music expressions. This means you can enter
3357 chords by name and print them as notes, enter them as notes and print
3358 them as chord names, or (the most common case) enter them by name, and
3359 print them as name.
3360
3361 @menu
3362 * Chords mode::                 
3363 * Printing named chords::       
3364 @end menu
3365
3366 @c .  {Chords mode}
3367 @node Chords mode
3368 @subsection Chords mode
3369 @cindex Chords mode
3370
3371 Chord mode is a mode where you can input sets of pitches using common
3372 names.  It is introduced by the keyword @code{\chords}.
3373 In chords mode,  a  chord is entered by the root, which is entered
3374 like a common pitch, for example,
3375 @lilypond[fragment,verbatim,quote]
3376   es4.  d8 c2
3377 @end lilypond
3378 is the notation for an E-flat major chord.
3379
3380 @cindex chord entry
3381 @cindex chord mode
3382
3383 Other chords may be entered
3384 by suffixing a colon, and introducing a modifier, and optionally, a
3385 number, for example
3386 @lilypond[fragment,verbatim,quote]
3387 \chords { e1:m e1:7 e1:m7  }
3388 @end lilypond
3389 The first number following the root is taken to be the `type' of the
3390 chord, thirds are added to the root until it reaches the specified
3391 number, for example.
3392 @lilypond[fragment,verbatim]
3393  \chords { c:3 c:5 c:6 c:7 c:8 c:9 c:10 c:11 }
3394 @end lilypond
3395
3396 @cindex root of chord
3397 @cindex additions, in chords
3398 @cindex removals, in  chords
3399
3400 More complex chords may also be constructed  adding separate steps
3401 to a chord. Additions are added after the  number following
3402 the colon, and are separated by dots. For example
3403 @c
3404 @lilypond[verbatim,fragment,quote]
3405   \chords { c:5.6 c:3.7.8 c:3.6.13 }
3406 @end lilypond
3407 Chord steps can be  altered by suffixing a @code{-} or @code{+} sign
3408 to the number, for example:
3409 @lilypond[verbatim,fragment,quote]
3410   \chords { c:7+ c:5+.3-  c:3-.5-.7- }
3411 @end lilypond
3412 Removals are specified similarly, and are introduced by a caret.  They
3413 must come after the additions.
3414 @lilypond[verbatim,fragment]
3415   \chords { c^3 c:7^5 c:9^3.5 }
3416 @end lilypond
3417
3418 Modifiers can be used to change pitches. The following modifiers are
3419 supported
3420 @table @code
3421 @item m
3422   Minor chord. Lowers the 3rd and (if present) the 7th step.
3423 @item dim
3424   Diminished chord. Lowers the 3rd, 5th and (if present) the 7th step
3425 @item aug
3426   Augmented chord. Raises the 5th step.
3427 @item maj
3428   Major 7th chord. Raises the 7th step, if present.  
3429 @item sus
3430   Suspended 4th or 2nd. This modifier removes the 3rd step. Append
3431   either @code{2} or @code{4} to add the 2nd or 4th step to the chord.
3432 @end table
3433 Modifiers can be mixed with additions. 
3434 @lilypond[verbatim,fragment]
3435   \chords { c:sus4 c:7sus4 c:dim7 c:m6 } 
3436 @end lilypond
3437
3438 @cindex modifiers, in chords. 
3439 @cindex @code{aug}
3440 @cindex @code{dim}
3441 @cindex @code{maj}
3442 @cindex @code{sus}
3443 @cindex @code{m}
3444
3445 Since the unaltered 11 does sound well when combined with the
3446 unaltered 3, the 11 is removed in this case, unless it is added
3447 explicitly). For example,
3448 @lilypond[fragment,verbatim]
3449   \chords { c:13 c:13.11 c:m13 }
3450 @end lilypond 
3451
3452 @cindex @code{/}
3453
3454 An inversion (putting one pitch of the chord on the bottom), as well
3455 as bass notes, can be specified by appending
3456 @code{/}@var{pitch} to the chord. 
3457 @lilypond[fragment,verbatim,center]
3458    \chords { c1 c/g c/f }
3459 @end lilypond 
3460 @cindex @code{/+}
3461 If you do not want to remove the bass note from the chord, but rather
3462 add the note, then you can use @code{/+}@var{pitch}.
3463
3464 @lilypond[fragment,verbatim,center]
3465    \chords { c1 c/+g c/+f }
3466 @end lilypond 
3467
3468 The chords mode is a mode similar to @code{\lyrics}, @code{\notes}
3469 etc.  Most of the commands continue to work, for example, @code{r} and
3470 @code{\skip} can be used to insert spaces, and @code{\property}  to
3471 change various settings.
3472
3473
3474
3475 @refbugs
3476
3477 Each step can only be present in a chord once.  The following
3478 simply produces the augmented chord, since @code{5+} is interpreted
3479 last.
3480 @cindex clusters
3481 @lilypond[verbatim,fragment]
3482   \chords { c:5.5-.5+ }
3483 @end lilypond
3484
3485 In chord mode, dashes and carets are used to indicate chord additions
3486 and subtractions, so articulation scripts can not be entered.
3487
3488
3489
3490
3491
3492 @c .  {Printing named chords}
3493 @node Printing named chords
3494 @subsection Printing named chords
3495
3496 @cindex printing chord names
3497 @cindex chord names
3498 @cindex chords
3499
3500 For displaying printed chord names, use the @internalsref{ChordNames} context.
3501 The chords may be entered either using the notation described above, or
3502 directly using simultaneous music.
3503
3504 @lilypond[verbatim,singleline]
3505 scheme = \notes {
3506   \chords {a1 b c} <<d f g>>  <<e g b>>
3507 }
3508 \score {
3509   \notes<
3510     \context ChordNames \scheme
3511     \context Staff \transpose c c' \scheme
3512   >
3513 }
3514 @end lilypond
3515
3516 You can make the chord changes stand out by setting
3517 @code{ChordNames.chordChanges} to true.  This will only display chord
3518 names when there's a change in the chords scheme and at the start of a
3519 new line.
3520
3521 @lilypond[verbatim]
3522 scheme = \chords {
3523   c1:m c:m \break c:m c:m d
3524 }
3525 \score {
3526   \notes <
3527     \context ChordNames {
3528         \property ChordNames.chordChanges = ##t
3529         \scheme }
3530     \context Staff \transpose c c' \scheme
3531   >
3532 \paper{linewidth= 9.\cm}
3533 }
3534 @end lilypond
3535
3536 LilyPond examines chords specified as lists of notes to determine a name
3537 to give the chord. LilyPond will not try to identify chord inversions or
3538 an added bass note, which may result in strange chord names when chords
3539 are entered as a list of pitches:
3540
3541 @lilypond[verbatim,center,singleline]
3542 scheme = \notes {
3543   <<c' e' g'>>1
3544   <<e' g' c''>>
3545   <<e e' g' c''>>
3546 }
3547
3548 \score {
3549   <
3550     \context ChordNames \scheme
3551     \context Staff \scheme
3552   >
3553 }
3554 @end lilypond
3555
3556 The default chord name layout is a system for Jazz music, proposed by
3557 Klaus Ignatzek (See @ref{Literature}).
3558
3559 [TODO: add description for banter other jazz.]
3560
3561 The Ignatzek chord name formatting can be tuned in a number of ways
3562 through the following properties:
3563 @table @code
3564 @item chordNameExceptions
3565 This is a list that contains the chords that have special formatting.
3566 For example.
3567 @lilypond[verbatim,singleline]
3568 chExceptionMusic = \notes { <<c f g bes>>1-\markup { \super "7" "wahh" }}
3569 chExceptions = #(append
3570   (sequential-music-to-chord-exceptions chExceptionMusic)
3571   ignatzekExceptions)
3572
3573 \score {   \context ChordNames
3574     \chords {
3575       c:7sus4 c:dim7
3576       \property ChordNames.chordNameExceptions = #chExceptions
3577       c:7sus4 c:dim7 } }
3578 @end lilypond
3579
3580 Putting the exceptions list encoded as
3581 @example
3582  \notes @{ <<c f g bes>>1-\markup @{ \super "7" "wahh" @} @}
3583 @end example
3584 into the property takes a little manoeuvring. The following code
3585 transforms  @code{chExceptionMusic} (which is a sequential music)
3586 into a list of exceptions.
3587 @example
3588   (sequential-music-to-chord-exceptions chExceptionMusic)
3589 @end example
3590 Then,
3591 @example
3592 #(append
3593   ... ignatzekExceptions)
3594 @end example
3595 adds the new exceptions to the default ones, which are defined in
3596 @file{ly/chord-modifier-init.ly}.
3597
3598 @item majorSevenSymbol
3599 This property contains the markup object used for the 7th step, when
3600 it is major. Predefined options are @code{whiteTriangleMarkup},
3601 @code{blackTriangleMarkup}. The following uses another popular shorthand. 
3602 @lilypond[fragment,verbatim]
3603 \context ChordNames \chords {
3604       c:7
3605       \property ChordNames.majorSevenSymbol = \markup { "j7" }
3606       c:7 } 
3607 @end lilypond
3608 @item chordNameSeparator
3609 Different parts of a chord name are normally separated by a
3610 slash. By setting @code{chordNameSeparator}, you can specify other
3611 separators, e.g.
3612 @lilypond[fragment,verbatim]
3613 \context ChordNames \chords {
3614       c:7sus4
3615       \property ChordNames.chordNameSeparator = \markup { "|" }
3616       c:7sus4 }
3617 @end lilypond
3618 @end table
3619
3620
3621
3622
3623
3624 @node Writing parts
3625 @section Writing parts
3626
3627 Orchestral music involves some special notation, both in the full score,
3628 as in the individual parts. This section explains how to tackle common
3629 problems in orchestral music.
3630
3631
3632 @c .  {Transpose}
3633 @menu
3634 * Rehearsal marks::             
3635 * Bar numbers::                 
3636 * Instrument names::            
3637 * Transpose::                   
3638 * Multi measure rests::         
3639 * Automatic part combining::    
3640 * Hara kiri staves::            
3641 * Sound output for transposing instruments::  
3642 @end menu
3643
3644 @c .   {Rehearsal marks}
3645 @node Rehearsal marks
3646 @subsection Rehearsal marks
3647 @cindex Rehearsal marks
3648 @cindex mark
3649 @cindex @code{\mark}
3650
3651 To print a  rehearsal mark, use the @code{\mark} command. 
3652 @lilypond[fragment,verbatim]
3653 \relative c'' {
3654   c1 \mark "A"
3655   c1 \mark \default
3656   c1 \mark \default 
3657   c1 \mark "12"
3658   c1 \mark \default
3659   c1
3660 }
3661 @end lilypond
3662
3663 As you can see, the mark is incremented automatically if you use
3664 @code{\mark \default}. The value to use is stored in the property
3665 @code{rehearsalMark} is used and automatically incremented.  The object
3666 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3667 @inputfileref{input/test,boxed-molecule.ly} if you need boxes around the
3668 marks.
3669
3670 The @code{\mark} command can also be used to put signs like coda,
3671 segno and fermatas on a barline.  The trick is to use the text markup
3672 mechanism to access the fermata symbol.
3673 @lilypond[fragment,verbatim,relative=1]
3674   c1 \mark \markup { \musicglyph #"scripts-ufermata" }
3675   c1
3676 @end lilypond
3677
3678
3679 The problem is that marks that occur at a line break are typeset only
3680 at the beginning of the next line, opposite to what you want for the
3681 fermata. This can be corrected by the following property setting
3682 @example
3683 \property Score.RehearsalMark \override
3684   #'break-visibility = #begin-of-line-invisible
3685 @end example
3686
3687 @cindex fermatas
3688 @cindex coda
3689 @cindex segno
3690 @cindex barlines, putting symbols on 
3691
3692
3693 @node Bar numbers
3694 @subsection Bar numbers
3695
3696
3697 @cindex bar numbers
3698 @cindex measure numbers
3699 @cindex currentBarNumber
3700
3701 Bar numbers are printed by default at the start of the line.  The
3702 number itself is a property that can be set by modifying the
3703 @code{currentBarNumber} property, although that is usually not
3704 necessary, i.e.
3705 @example
3706   \property Score.currentBarNumber = #217
3707 @end example
3708
3709 To typeset Bar Numbers at regular intervals instead of at the beginning of each line,
3710 you need to change the grob property @code{break-visibility} as well as the translator
3711 property @code{barNumberVisibility}, as illustrated in the following example which also
3712 adds a box around the bar numbers:
3713 @example
3714 \property Score.BarNumber \override #'break-visibility =
3715   #end-of-line-invisible
3716 \property Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
3717 \property Score.BarNumber \override #'molecule-callback =
3718   #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule)
3719 \property Score.BarNumber \override #'font-relative-size = #0
3720 @end example
3721 @lilypond[noindent]
3722 \score {
3723     \context Staff \notes \transpose c c'' {
3724         \property Score.BarNumber \override #'break-visibility = #end-of-line-invisible
3725         \property Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
3726         \property Score.BarNumber \override #'molecule-callback =
3727         #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule)
3728         \property Score.BarNumber \override #'font-relative-size = #0
3729         
3730         \repeat unfold 16 c1 \bar "|."
3731     }
3732 }
3733 @end lilypond
3734
3735 If you would like the bar numbers to appear at regular intervals, but
3736 not starting from measure zero, you can use the context function,
3737 @code{set-bar-number-visibility}, to automatically set
3738 @code{barNumberVisibility} so that the bar numbers appear at regular
3739 intervals, starting from the @code{\applycontext}:
3740
3741 @example
3742 resetBarnum = \context Score \applycontext
3743   #(set-bar-number-visibility 4)
3744 ...
3745 \property Score.BarNumber \override #'break-visibility =
3746   #end-of-line-invisible
3747 \mark "A" \resetBarnum
3748 \repeat unfold 10 c1
3749 \mark \default \resetBarnum
3750 \repeat unfold 8 c
3751 @end example
3752 @lilypond[noindent]
3753 resetBarnum = \context Score \applycontext
3754   #(set-bar-number-visibility 4)
3755 \score {
3756     <
3757         \notes \transpose c c'' {
3758             \property Score.BarNumber \override #'break-visibility =#end-of-line-invisible
3759             \property Score.RehearsalMark \override #'padding = #2.5
3760             \mark "A" \resetBarnum
3761             \repeat unfold 10 c1
3762             \mark \default \resetBarnum
3763             \repeat unfold 8 c
3764             \bar "|."
3765         }
3766     >
3767 }
3768 @end lilypond
3769
3770 See also @seeinternals{BarNumber}.
3771
3772 @refbugs
3773
3774 Barnumbers can collide with the StaffGroup, if there is one at the
3775 top. To solve this, You have to twiddle with the
3776 @internalsref{padding} property of @internalsref{BarNumber} if your
3777 score starts with a @internalsref{StaffGroup}.
3778
3779 @node Instrument names
3780 @subsection Instrument names
3781
3782 In scores, the instrument name is printed before the staff. This can
3783 be done by setting @code{Staff.instrument} and
3784 @code{Staff.instr}. This will print a string before the start of the
3785 staff. For the first start, @code{instrument} is used, for the next
3786 ones @code{instr} is used.
3787
3788 @lilypond[verbatim,singleline]
3789   \property Staff.instrument = "ploink " { c''4 }  
3790 @end lilypond
3791
3792 You can also use markup texts to construct more complicated instrument
3793 names:
3794
3795
3796 @lilypond[verbatim,singleline]
3797 \score {
3798   \notes \context Staff = treble {
3799     \property Staff.instrument
3800         = \markup { \column << "Clarinetti" { "in B" \smaller \musicglyph #"accidentals--1" } >> }
3801     { c''1 }
3802   }
3803   \paper { linewidth= 8.0\cm }
3804 }
3805 @end lilypond
3806
3807
3808 @refbugs
3809
3810 When you put a name on a grand staff or piano staff the width of the
3811 brace is not taken into account. You must add extra spaces to the end of
3812 the name to avoid a collision.
3813
3814 @node Transpose
3815 @subsection Transpose
3816 @cindex Transpose
3817 @cindex transposition of pitches
3818 @cindex @code{\transpose}
3819
3820 A music expression can be transposed with @code{\transpose}.  The syntax
3821 is
3822 @example
3823   \transpose @var{from} @var{to} @var{musicexpr}
3824 @end example
3825
3826 This means that @var{musicexpr} is transposed to by the interval
3827 between @var{from} is @var{to}.
3828
3829 @code{\transpose} distinguishes between enharmonic pitches: both
3830 @code{\transpose c cis} or @code{\transpose c des} will transpose up
3831 half a tone.  The first version will print sharps and the second
3832 version will print flats.
3833
3834 @lilypond[singleline, verbatim]
3835 mus =\notes { \key d \major cis d fis g }
3836 \score { \notes \context Staff {
3837   \clef "F" \mus
3838   \clef "G"
3839   \transpose c g' \mus
3840   \transpose c f' \mus
3841 }}
3842 @end lilypond
3843
3844 If you want to use both @code{\transpose} and @code{\relative}, then
3845 you must use @code{\transpose} first.  @code{\relative} will have no
3846 effect music that appears inside a @code{\transpose}.
3847
3848 @c .  {Multi measure rests}
3849 @node  Multi measure rests
3850 @subsection Multi measure rests
3851 @cindex Multi measure rests
3852
3853 @cindex @code{R}
3854
3855 Multi measure rests are entered using `@code{R}'. It is specifically
3856 meant for full bar rests and for entering parts: the rest can expand to
3857 fill a score with rests, or it can be printed as a single multimeasure
3858 rest This expansion is controlled by the property
3859 @code{Score.skipBars}. If this is set to true, Lily will not expand
3860 empty measures, and the appropriate number is added automatically.
3861
3862 @lilypond[fragment,verbatim]
3863  \time 4/4 r1 | R1 | R1*2
3864  \property Score.skipBars = ##t R1*17  R1*4
3865 @end lilypond
3866
3867 The @code{1} in @code{R1} is similar to the duration notation used for
3868 notes. Hence, for time signatures other than 4/4, you must enter other
3869 durations.  This can be done with augmentation dots, or with
3870 fractions:
3871
3872 @lilypond[fragment,verbatim]
3873  \property Score.skipBars = ##t
3874  \time 3/4
3875   R2. | R2.*2
3876  \time 13/8
3877  R1*13/8
3878  R1*13/8*12
3879 @end lilypond
3880
3881 Notice that a @code{R} spanning a single measure is printed as a whole
3882 rest centered in the measure, regardless of the time signature.
3883
3884 [ add note about breves.]
3885  
3886
3887 @cindex text on multi-measure rest
3888 @cindex script on multi-measure rest
3889 @cindex fermata on multi-measure rest
3890
3891 Texts can be added to multi-measure rests by using the
3892 @var{note}-@code{markup} syntax.  An identifier
3893 is provided for a fermata. 
3894
3895 @lilypond[verbatim,fragment]
3896   \time 3/4
3897   R2._\markup { \roman "Ad lib" }
3898   R2.^\fermataMarkup
3899 @end lilypond
3900
3901 By default, the multi-measure rest uses the number font, which does
3902 not contain any letters. This is the reason for the explicit
3903 @code{\roman} in the above example.
3904
3905 @cindex whole rests for a full measure 
3906
3907 The object for this object is @internalsref{MultiMeasureRest}, and
3908 @internalsref{MultiMeasureRestNumber}.
3909
3910 @refbugs
3911
3912 Only one text can be put on a multi-measure rest with
3913 @var{note}-@var{text} syntax, since this is internally converted to
3914 setting @code{#'text} in @internalsref{MultiMeasureRestNumber}. It is
3915 not possible to use fingerings (e.g. @code{R1-4}) to put numbers over
3916 multi-measure rests.
3917
3918
3919 @cindex condensing rests
3920
3921 Currently, there is no way to automatically condense multiple rests
3922 into a single multimeasure rest. Multi measure rests do not take part
3923 in rest collisions.
3924
3925
3926 @node Automatic part combining
3927 @subsection Automatic part combining
3928 @cindex automatic part combining
3929 @cindex part combiner
3930
3931
3932 Automatic part combining is used to merge two parts of music onto a
3933 staff in an intelligent way.  It is aimed primarily at typesetting
3934 orchestral scores.  When the two parts are identical for a period of
3935 time, only one is shown.  In places where the two parts differ, they
3936 are typeset as separate voices, and stem directions are set
3937 automatically.  Also, solo and @emph{a due} parts can be identified
3938 and marked.
3939
3940 The syntax for part combining is
3941
3942 @example
3943   \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3944 @end example
3945 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3946 combined into one context of type @var{context}.  The music expressions
3947 must be interpreted by contexts whose names should start with @code{one}
3948 and @code{two}.
3949
3950 The most useful function of the part combiner is to combine parts into
3951 one voice, as common for wind parts in orchestral scores:
3952
3953 @lilypond[verbatim,singleline,fragment]
3954   \context Staff <
3955     \context Voice=one \partcombine Voice
3956       \context Thread=one \relative c'' {
3957         g a () b r
3958       }
3959       \context Thread=two \relative c'' {
3960         g r4 r f
3961       }
3962   >
3963 @end lilypond
3964
3965 Notice that the first @code{g} appears only once, although it was
3966 specified twice (once in each part).  Stem, slur and tie directions are
3967 set automatically, depending whether there is a solo or unisono. The
3968 first part (with context called @code{one}) always gets up stems, and
3969 `solo', while the second (called @code{two}) always gets down stems and
3970 `Solo II'.
3971
3972 If you just want the merging parts, and not the textual markings, you
3973 may set the property @var{soloADue} to false.
3974
3975 @lilypond[verbatim,singleline,fragment]
3976   \context Staff <
3977     \property Staff.soloADue = ##f
3978     \context Voice=one \partcombine Voice
3979       \context Thread=one \relative c'' {
3980         b4 a c g
3981       }
3982       \context Thread=two \relative c'' {
3983         d,2 a4 g'
3984       }
3985   >
3986 @end lilypond
3987
3988 There are a number of other properties that you can use to tweak the
3989 behavior of part combining, refer to the automatically generated
3990 documentation of @internalsref{Thread_devnull_engraver} and
3991 @internalsref{Voice_devnull_engraver}. Look at the documentation of the
3992 responsible engravers, @code{Thread_devnull_engraver},
3993 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3994
3995 @refbugs
3996
3997 In @code{soloADue} mode, when the two voices play the same notes on and
3998 off, the part combiner may typeset @code{a2} more than once in a
3999 measure.
4000
4001 @lilypond[fragment,singleline]
4002   \context Staff <
4003     \context Voice=one \partcombine Voice
4004       \context Thread=one \relative c'' {
4005         c b c b c a c a
4006       }
4007       \context Thread=two \relative c'' {
4008         b b b b f a f a
4009       }
4010   >
4011 @end lilypond
4012
4013 @cindex @code{Thread_devnull_engraver}
4014 @cindex @code{Voice_engraver}
4015 @cindex @code{A2_engraver}
4016
4017 @node Hara kiri staves
4018 @subsection Hara kiri staves
4019
4020 In orchestral scores, staff lines that only have rests are usually removed.
4021 This saves some space.  LilyPond also supports this through the hara
4022 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
4023 the Japanese Samourai warriors.} staff. This staff commits suicide when
4024 it finds itself to be empty after the line-breaking process.  It will
4025 not disappear when it contains normal rests, you must use multi measure
4026 rests.
4027
4028 The hara kiri staff is specialized version of the @internalsref{Staff}
4029 context. It is available as the context identifier
4030 @code{\HaraKiriStaffContext}.  Observe how the second staff in this
4031 example disappears in the second line.
4032
4033 @lilypond[verbatim]
4034 \score  {
4035   \notes \relative c' <
4036     \context Staff = SA { e4 f g a \break c1 }
4037     \context Staff = SB { c4 d e f \break R1 }
4038   >
4039   \paper {
4040     linewidth = 6.\cm 
4041     \translator { \HaraKiriStaffContext }
4042   }
4043 }
4044 @end lilypond
4045
4046 For @internalsref{Lyrics}, @internalsref{LyricsVoice},
4047 @internalsref{ChordNames} and @internalsref{FiguredBass}, hara-kiri is
4048 switched on by default.
4049
4050
4051 @node Sound output for transposing instruments
4052 @subsection Sound output for transposing instruments
4053
4054 When you want to make a MIDI file from a score containing transposed
4055 and untransposed instruments, you have to instruct LilyPond the pitch
4056 offset (in semitones) for the transposed instruments. This is done
4057 using the @code{transposing} property. It does not affect printed
4058 output.
4059
4060 @cindex @code{transposing}
4061
4062 @example
4063         \property Staff.instrument = #"Cl. in B-flat"
4064         \property Staff.transposing = #-2
4065 @end example
4066
4067
4068 @node Ancient notation 
4069 @section Ancient notation
4070
4071 @cindex Vaticana, Editio
4072 @cindex Medicaea, Editio
4073 @cindex hufnagel
4074 @cindex Petrucci
4075 @cindex mensural
4076
4077 @menu
4078 * Ancient note heads::
4079 * Ancient clefs::
4080 * Custodes::
4081 * Divisiones::
4082 * Ligatures::
4083 * Figured bass::
4084 @end menu
4085
4086
4087 @node Ancient note heads
4088 @subsection Ancient note heads
4089
4090 To get a longa note head, you have to use mensural note heads. This
4091 is accomplished by setting the @code{style} property of the
4092 NoteHead object to @code{mensural}. There is also a note head style
4093 @code{baroque} which gives mensural note heads for @code{\longa} and
4094 @code{\breve} but standard note heads for shorter notes.
4095
4096 @lilypond[fragment,singleline,verbatim]
4097  \property Voice.NoteHead \set #'style = #'mensural
4098  a'\longa
4099 @end lilypond
4100
4101 @node Ancient clefs 
4102 @subsection Ancient clefs
4103
4104 LilyPond supports a variety of clefs, many of them ancient.
4105
4106 For modern clefs, see section @ref{Clef}.  For the percussion clef, see
4107 section @ref{Percussion staves}.  For the @code{TAB} clef, see section
4108 @ref{Tablatures}.
4109
4110 The following table shows all ancient clefs that are supported via the
4111 @code{\clef} command.  Some of the clefs use the same glyph, but differ
4112 only with respect to the line they are printed on.  In such cases, a
4113 trailing number in the name is used to enumerate these clefs.  Still,
4114 you can manually force a clef glyph to be typeset on an arbitrary line,
4115 as described in section @ref{Clef}.  The note printed to the right side
4116 of each clef denotes the @code{c'} with respect to the clef.
4117
4118 @table @code
4119
4120 @c --- This should go somewhere else: ---
4121 @c @item modern style G clef (glyph: @code{clefs-G})
4122 @c
4123 @c Supported clefs:
4124 @c @code{treble}, @code{violin}, @code{G}, @code{G2}, @code{french}
4125 @c
4126 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "G" c'}
4127 @c
4128 @c @item modern style F clef (glyph: @code{clefs-F})
4129 @c
4130 @c Supported clefs:
4131 @c @code{varbaritone}, @code{bass}, @code{F}, @code{subbass}
4132 @c
4133 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "F" c'}
4134 @c
4135 @c @item modern style C clef (glyph: @code{clefs-C})
4136 @c
4137 @c Supported clefs:
4138 @c @code{soprano}, @code{mezzosoprano}, @code{alto}, @code{C},
4139 @c @code{tenor}, @code{baritone}
4140 @c
4141 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "C" c'}
4142
4143 @item modern style mensural C clef (glyph: @code{clefs-neo_mensural_c'})
4144
4145 Supported clefs:
4146 @code{neo_mensural_c1}, @code{neo_mensural_c2},
4147 @code{neo_mensural_c3}, @code{neo_mensural_c4}
4148
4149 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "neo_mensural_c2" c'}
4150
4151 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c1})
4152
4153 Supported clefs:
4154 @code{petrucci_c1}
4155 for 1st staffline
4156
4157 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c1" c'}
4158
4159 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c2})
4160
4161 Supported clefs:
4162 @code{petrucci_c2}
4163 for 2nd staffline
4164
4165 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c2" c'}
4166
4167 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c3})
4168
4169 Supported clefs:
4170 @code{petrucci_c3}
4171 for 3rd staffline
4172
4173 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c3" c'}
4174
4175 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c4})
4176
4177 Supported clefs:
4178 @code{petrucci_c4}
4179 for 4th staffline
4180
4181 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c4" c'}
4182
4183 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c5})
4184
4185 Supported clefs:
4186 @code{petrucci_c5}
4187 for 5th staffline
4188
4189 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c5" c'}
4190
4191 @item petrucci style mensural F clef (glyph: @code{clefs-petrucci_f})
4192
4193 Supported clefs:
4194 @code{petrucci_f}
4195
4196 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_f" c'}
4197
4198 @item petrucci style mensural G clef (glyph: @code{clefs-petrucci_g})
4199
4200 Supported clefs:
4201 @code{petrucci_g}
4202
4203 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_g" c'}
4204
4205 @item historic style mensural C clef (glyph: @code{clefs-mensural_c'})
4206
4207 Supported clefs:
4208 @code{mensural_c1}, @code{mensural_c2}, @code{mensural_c3},
4209 @code{mensural_c4}
4210
4211 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_c2" c'}
4212
4213 @item historic style mensural F clef (glyph: @code{clefs-mensural_f})
4214
4215 Supported clefs:
4216 @code{mensural_f}
4217
4218 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_f" c'}
4219
4220 @item historic style mensural G clef (glyph: @code{clefs-mensural_g})
4221
4222 Supported clefs:
4223 @code{mensural_g}
4224
4225 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_g" c'}
4226
4227 @item Editio Vaticana style do clef (glyph: @code{clefs-vaticana_do})
4228
4229 Supported clefs:
4230 @code{vaticana_do1}, @code{vaticana_do2}, @code{vaticana_do3}
4231
4232 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_do2" c'}
4233
4234 @item Editio Vaticana style fa clef (glyph: @code{clefs-vaticana_fa})
4235
4236 Supported clefs:
4237 @code{vaticana_fa1}, @code{vaticana_fa2}
4238
4239 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_fa2" c'}
4240
4241 @item Editio Medicaea style do clef (glyph: @code{clefs-medicaea_do})
4242
4243 Supported clefs:
4244 @code{medicaea_do1}, @code{medicaea_do2}, @code{medicaea_do3}
4245
4246 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_do2" c'}
4247
4248 @item Editio Medicaea style fa clef (glyph: @code{clefs-medicaea_fa})
4249
4250 Supported clefs:
4251 @code{medicaea_fa1}, @code{medicaea_fa2}
4252
4253 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_fa2" c'}
4254
4255 @item historic style hufnagel do clef (glyph: @code{clefs-hufnagel_do})
4256
4257 Supported clefs:
4258 @code{hufnagel_do1}, @code{hufnagel_do2}, @code{hufnagel_do3}
4259
4260 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do2" c'}
4261
4262 @item historic style hufnagel fa clef (glyph: @code{clefs-hufnagel_fa})
4263
4264 Supported clefs:
4265 @code{hufnagel_fa1}, @code{hufnagel_fa2}
4266
4267 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_fa2" c'}
4268
4269 @item historic style hufnagel combined do/fa clef (glyph: @code{clefs-hufnagel_do_fa})
4270
4271 Supported clefs:
4272 @code{hufnagel_do_fa}
4273
4274 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do_fa" c'}
4275
4276 @c --- This should go somewhere else: ---
4277 @c @item modern style percussion clef (glyph: @code{clefs-percussion})
4278 @c
4279 @c Supported clefs:
4280 @c @code{percussion}
4281 @c
4282 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "percussion" c'}
4283 @c
4284 @c @item modern style tab clef (glyph: @code{clefs-tab})
4285 @c
4286 @c Supported clefs:
4287 @c @code{tab}
4288 @c
4289 @c @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #6 \property Staff.TimeSignature \set #'transparent = ##t \clef "tab" c'}
4290
4291 @end table
4292
4293 @emph{Modern style} means ``as is typeset in current editions of
4294 transcribed mensural music''.
4295
4296 @emph{Petrucci style} means ``inspired by printings published by the
4297 famous engraver Petrucci (1466-1539)''.
4298
4299 @emph{Historic style} means ``as was typeset or written in contemporary
4300 historic editions (other than those of Petrucci)''.
4301
4302 @emph{Editio XXX style} means ``as is/was printed in Editio XXX''.
4303
4304 Petrucci used C clefs with differently balanced left-side vertical
4305 beams, depending on which staffline it was printed.
4306
4307 @c . {Custodes}
4308 @node Custodes
4309 @subsection Custodes
4310
4311 @cindex custos
4312 @cindex custodes
4313
4314 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
4315 staff context symbol that appears at the end of a staff line.  It
4316 anticipates the pitch of the first note(s) of the following line and
4317 thus helps the player or singer to manage line breaks during
4318 performance, thus enhancing readability of a score.
4319
4320 @lilypond[verbatim]
4321 \score {
4322   \notes { c'1 \break
4323         \property Staff.Custos \set #'style = #'mensural
4324         d' }
4325   \paper {
4326     \translator {
4327       \StaffContext
4328       \consists Custos_engraver
4329     }
4330   }
4331 }
4332 @end lilypond
4333
4334 Custodes were frequently used in music notation until the 17th century.
4335 There were different appearances for different notation styles.
4336 Nowadays, they have survived only in special forms of musical notation
4337 such as via the @emph{editio vaticana} dating back to the beginning of
4338 the 20th century.
4339
4340 For typesetting custodes, just put a @code{Custos_engraver} into the
4341 Staff context when declaring the @code{\paper} block, as shown in the
4342 following example.  In the @code{\paper} block, you can also globally
4343 control the appearance of the custos symbol by setting the custos
4344 @code{style} property.
4345
4346 @example
4347 \paper @{
4348   \translator @{
4349       \StaffContext
4350       \consists Custos_engraver
4351       Custos \override #'style = #'mensural
4352   @}
4353 @}
4354 @end example
4355
4356 The property can also be set locally, for example in a @code{\notes}
4357 block:
4358
4359 @example
4360 \notes @{
4361   \property Staff.Custos \override #'style = #'vaticana
4362   c'1 d' e' d' \break c' d' e' d'
4363 @}
4364 @end example
4365
4366 Currently, the following styles are supported:
4367
4368 @lilypond[26pt]
4369 \score {
4370     \notes {
4371         \fatText
4372         s
4373         ^\markup { "vaticana" }
4374         ^\markup { \musicglyph #"custodes-vaticana-u0" }
4375         s
4376         ^\markup { "medicaea" }
4377         ^\markup { \musicglyph #"custodes-medicaea-u0" }
4378         s
4379         ^\markup { "hufnagel" }
4380         ^\markup { \musicglyph #"custodes-hufnagel-u0" }
4381         s
4382         ^\markup { "mensural" }
4383         ^\markup { \musicglyph #"custodes-mensural-u0" }
4384     }
4385     \paper {
4386         linewidth = -1.0
4387         interscoreline = 1
4388         \translator {
4389             \ScoreContext
4390             \remove "Bar_number_engraver"
4391             TextScript \override #'extra-X-extent = #'(-1 . 1)
4392         }
4393         \translator{
4394             \StaffContext
4395             \remove "Clef_engraver"
4396             \remove "Key_engraver"
4397             \remove "Time_signature_engraver"
4398             \remove "Staff_symbol_engraver"
4399             minimumVerticalExtent = ##f
4400         }
4401     }
4402 }
4403 @end lilypond
4404
4405 If the boolean property @code{adjust-if-on-staffline} is set to
4406 @code{#t} (which it is by default), lily typesets slightly different
4407 variants of the custos glyph, depending on the pitch of the custos,
4408 i.e. depending on the glyph being typeset either on a staffline or
4409 between two stafflines.  The idea is that the glyph will optically fit
4410 well into the staff, with the appendage on the right of the custos
4411 always ending at the same vertical position between two stafflines
4412 regardless of the pitch.  If you set @code{adjust-if-on-staffline} to
4413 @code{#f}, then lily takes regardless of the pitch always a glyph that
4414 is a compromise of the former two variants.
4415
4416 Just like stems can be attached to noteheads in two directions
4417 @emph{up} and @emph{down}, each custos glyph is available with its
4418 appendage pointing either up or down.  If the pitch of a custos is
4419 above a selectable position, the appendage will point downwards; if
4420 the pitch is below this position, the appendage will point upwards.
4421 Use property @code{neutral-position} to select this position.  By
4422 default, it is set to @code{0}, such that the neutral position is the
4423 center of the staff.  Use property @code{neutral-direction} to control
4424 what happens if a custos is typeset on the neutral position itself.
4425 By default, this property is set to @code{-1}, such that the appendage
4426 will point downwards.  If set to @code{1}, the appendage will point
4427 upwards.  Other values such as @code{0} are reserved for future
4428 extensions and should not be used.
4429
4430 @node Divisiones
4431 @subsection Divisiones
4432
4433 @cindex divisio
4434 @cindex divisiones
4435 @cindex finalis
4436
4437 A @emph{divisio} (plural: @emph{divisiones}; latin word for
4438 `division') is a staff context symbol that is used to structure
4439 Gregorian music into phrases and sections.  The musical meaning of
4440 @emph{divisio minima}, @emph{divisio maior} and @emph{divisio maxima}
4441 can be characterized as short, medium and long pause, somewhat like
4442 @ref{Breath marks}.  The @emph{finalis} sign not only marks the end of
4443 a chant, but is also frequently used within a single
4444 antiphonal/responsorial chant to mark the end of each section.
4445
4446 To use divisiones, just include the file @code{gregorian-init.ly}.  It
4447 contains definitions that you can apply by just inserting
4448 @code{\divisiominima}, @code{\divisiomaior}, @code{\divisiomaxima},
4449 and @code{\finalis} at proper places into your lilypond files.
4450
4451 @lilypond[verbatim]
4452 \include "gregorian-init.ly"
4453 \score {
4454     \notes {
4455         \context Staff = staff \addlyrics \notes \transpose c c' {
4456             \property Score.timing = ##f
4457             \property Score.barAlways = ##t
4458             \property Staff.BarLine \override #'transparent = ##t
4459             \property Voice.Stem \override #'transparent = ##t
4460             g4( )a g e( )f e
4461             ^\markup { "divisio minima" }
4462             \divisiominima
4463             g4( )a g e( )f e
4464             ^\markup { "divisio maior" }
4465             \divisiomaior
4466             g4( )a g e( )f e
4467             ^\markup { "divisio maxima" }
4468             \divisiomaxima
4469             g4( )a g e( )f e
4470             ^\markup { "finalis" }
4471             \finalis
4472             g4( )a g e( )f e
4473         }
4474         \context Lyrics = lyrics \lyrics {
4475             Blah blub, blah blam.
4476             Blah blub, blah blam.
4477             Blah blub, blah blam.
4478             Blah blub, blah blam.
4479             Blah blub, blah blam.
4480         }
4481     }
4482 }
4483 @end lilypond
4484
4485 Some editions use @emph{virgula} or @emph{caesura} instead of divisio
4486 minima.  Therefore, @code{gregorian-init.ly} also defines
4487 @code{\virgula} and @code{\caesura}.
4488
4489 @lilypond[verbatim]
4490 \include "gregorian-init.ly"
4491 \score {
4492     \notes {
4493         \context Staff = staff \addlyrics \notes \transpose c c' {
4494             \property Score.timing = ##f
4495             \property Score.barAlways = ##t
4496             \property Staff.BarLine \override #'transparent = ##t
4497             \property Voice.Stem \override #'transparent = ##t
4498             g4( )a g e( )f e
4499             ^\markup { "virgula" }
4500             \virgula
4501             g4( )a g e( )f e
4502             ^\markup { "caesura" }
4503             \caesura
4504             g4( )a g e( )f e
4505         }
4506         \context Lyrics = lyrics \lyrics {
4507             Blah blub, blah blam.
4508             Blah blub, blah blam.
4509             Blah blub, blah blam.
4510         }
4511     }
4512 }
4513 @end lilypond
4514
4515 @node Ligatures
4516 @subsection Ligatures
4517
4518 @cindex Ligatures
4519
4520 @c TODO: Should double check if I recalled things correctly when I wrote
4521 @c down the following paragraph by heart.
4522 In musical terminology, a ligature is a coherent graphical symbol that
4523 represents at least two different notes.  Ligatures originally appeared
4524 in the manuscripts of Gregorian chant notation roughly since the 9th
4525 century as an allusion to the accent symbols of greek lyric poetry to
4526 denote ascending or descending sequences of notes.  Both, the shape and
4527 the exact meaning of ligatures changed tremendously during the following
4528 centuries: In early notation, ligatures where used for monophonic tunes
4529 (Gregorian chant) and very soon denoted also the way of performance in
4530 the sense of articulation.  With upcoming multiphony, the need for a
4531 metric system arised, since multiple voices of a piece have to be
4532 synchronized some way.  New notation systems were invented, that used
4533 the manifold shapes of ligatures to now denote rhythmical patterns
4534 (e.g. black mensural notation, mannered notation, ars nova).  With the
4535 invention of the metric system of the white mensural notation, the need
4536 for ligatures to denote such patterns disappeared.  Nevertheless,
4537 ligatures were still in use in the mensural system for a couple of
4538 decades until they finally disappeared during the late 16th / early 17th
4539 century.  Still, ligatures have survived in contemporary editions of
4540 Gregorian chant such as the Editio Vaticana from 1905/08.
4541
4542 Syntactically, ligatures are simply enclosed by @code{\[} and @code{\]}.
4543 Some ligature styles (such as Editio Vaticana) may need additional input
4544 syntax specific for this particular type of ligature.  By default, the
4545 @internalsref{LigatureBracket} engraver just marks the start and end of
4546 a ligature by small square angles:
4547
4548 @lilypond[singleline,verbatim]
4549 \score {
4550     \notes \transpose c c' {
4551         \[ g c a f d' \]
4552         a g f
4553         \[ e f a g \]
4554     }
4555 }
4556 @end lilypond
4557
4558 To select a specific style of ligatures, a proper ligature engraver has
4559 to be added to the @internalsref{Voice} context, as explained in the
4560 following subsections.  Currently, Lilypond only supports white mensural
4561 ligatures with certain limitations.  Support for Editio Vaticana will be
4562 added in the future.
4563
4564 @menu
4565 * White mensural ligatures::    
4566 @end menu
4567
4568 @node White mensural ligatures
4569 @subsubsection White mensural ligatures
4570
4571 @cindex Mensural ligatures
4572 @cindex White mensural ligatures
4573
4574 Lilypond has limited support for white mensural ligatures.  The
4575 implementation is still experimental; it currently may output strange
4576 warnings or even crash in some cases or produce weird results on more
4577 complex ligatures.  To engrave white mensural ligatures, in the paper
4578 block the @internalsref{MensuralLigature} engraver has to be put into
4579 the @internalsref{Voice} context (and you probably want to remove the
4580 @internalsref{LigatureBracket} engraver).  There is no additional input
4581 language to describe the shape of a white mensural ligature.  The shape
4582 is rather determined solely from the pitch and duration of the enclosed
4583 notes.  While this approach may take a new user quite a while to get
4584 accustomed, it has a great advantage: this way, lily has full musical
4585 information about the ligature.  This is not only required for correct
4586 MIDI output, but also allows for automatic transcription of the
4587 ligatures.
4588
4589 Example:
4590
4591 @lilypond[singleline,verbatim]
4592 \score {
4593     \notes \transpose c c' {
4594         \property Score.timing = ##f
4595         \property Score.defaultBarType = "empty"
4596         \property Voice.NoteHead \set #'style = #'neo_mensural
4597         \property Staff.TimeSignature \set #'style = #'neo_mensural
4598         \clef "petrucci_g"
4599         \[ g\longa c\breve a\breve f\breve d'\longa \]
4600         s4
4601         \[ e1 f1 a\breve g\longa \]
4602     }
4603     \paper {
4604         \translator {
4605             \VoiceContext
4606             \remove Ligature_bracket_engraver
4607             \consists Mensural_ligature_engraver
4608         }
4609     }
4610 }
4611 @end lilypond
4612
4613 Without replacing @code{Ligature_bracket_engraver} with
4614 @code{Mensural_ligature_engraver}, the same music transcribes to the
4615 following:
4616
4617 @lilypond[singleline,verbatim]
4618 \score {
4619     \notes \transpose c c' {
4620         \property Score.timing = ##f
4621         \property Score.defaultBarType = "empty"
4622         \property Voice.NoteHead \set #'style = #'neo_mensural
4623         \property Staff.TimeSignature \set #'style = #'neo_mensural
4624         \clef "petrucci_g"
4625         \[ g\longa c\breve a\breve f\breve d'\longa \]
4626         s4
4627         \[ e1 f1 a\breve g\longa \]
4628     }
4629 }
4630 @end lilypond
4631
4632 @node Figured bass
4633 @subsection Figured bass
4634
4635 @cindex Basso continuo
4636
4637 LilyPond has limited support for figured bass:
4638
4639 @lilypond[verbatim,fragment]
4640 <
4641  \context Voice \notes { \clef bass dis4  c d ais}
4642  \context FiguredBass
4643    \figures {
4644     < 6 >4 < 7 >8 < 6+ [_!] >
4645     < 6 >4 <6 5 [3+] >
4646    }
4647  >
4648 @end lilypond
4649
4650 The support for figured bass consists of two parts: there is an input
4651 mode, introduced by @code{\figures}, where you can enter bass figures
4652 as numbers, and there is a context called @internalsref{FiguredBass}
4653 that takes care of making @internalsref{BassFigure} objects.
4654
4655 In figures input mode, a group of bass figures is delimited by
4656 @code{<} and @code{>}. The duration is entered after the @code{>}.
4657 @example
4658         <4 6>
4659 @end example
4660 @lilypond[fragment]
4661 \context FiguredBass
4662 \figures { <4 6> }
4663 @end lilypond
4664
4665 Accidentals are added to the numbers if you alterate them by
4666 appending @code{-}, @code{!}  and @code{+}.
4667
4668 @example
4669   <4- 6+ 7!>
4670 @end example
4671 @lilypond[fragment]
4672   \context FiguredBass
4673 \figures { <4- 6+ 7!> }
4674 @end lilypond
4675
4676 Spaces or dashes may be inserted by using @code{_}. Brackets are
4677 introduced with @code{[} and @code{]}.
4678
4679 @example
4680         < [4 6] 8 [_ 12]>
4681 @end example
4682 @lilypond[fragment]
4683  \context FiguredBass
4684 \figures { < [4 6] 8 [_ 12]> }
4685 @end lilypond
4686
4687 Although the support for figured bass may superficially resemble chord
4688 support, it works much simpler: in figured bass simply stores the
4689 numbers, and then prints the numbers you entered. There is no
4690 conversion to pitches, and no realizations of the bass are played in
4691 the MIDI file.
4692
4693 Internally, the code produces markup texts internally. You can use any
4694 of the markup text properties to override formatting. For example, the
4695 vertical spacing of the figures may be set with @code{baseline-skip}.
4696
4697 @c . {Contemporary notation}
4698 @node Contemporary notation
4699 @section Contemporary notation
4700
4701 @menu
4702 * Clusters::
4703 * Fermatas::
4704 @end menu
4705
4706 @node Clusters
4707 @subsection Clusters
4708
4709 @cindex cluster
4710
4711 In musical terminology, a @emph{cluster} denotes a range of
4712 simultaneously sounding pitches that may change over time.  The set of
4713 available pitches to apply usually depends on the accoustic source.
4714 Thus, in piano music, a cluster typically consists of a continous range
4715 of the semitones as provided by the piano's fixed set of a chromatic
4716 scale.  In choral music, each singer of the choir typically may sing an
4717 arbitrary pitch within the cluster's range that is not bound to any
4718 diatonic, chromatic or other scale.  In electronic music, a cluster
4719 (theoretically) may even cover a continuous range of pitches, thus
4720 resulting in coloured noise, such as pink noise.
4721
4722 Clusters can be notated in the context of ordinary staff notation by
4723 engraving simple geometrical shapes that replace ordinary notation of
4724 notes.  Ordinary notes as musical events specify starting time and
4725 duration of pitches; however, the duration of a note is expressed by the
4726 shape of the note head rather than by the horizontal graphical extent of
4727 the note symbol.  In contrast, the shape of a cluster geometrically
4728 describes the development of a range of pitches (vertical extent) over
4729 time (horizontal extent).  Still, the geometrical shape of a cluster
4730 covers the area in wich any single pitch contained in the cluster would
4731 be notated as an ordinary note.  From this point of view, it is
4732 reasonable to specify a cluster as the envelope of a set of notes.  This
4733 is exactly how to construct a cluster with lilypond.
4734
4735 @lilypond[singleline,verbatim]
4736 \score {
4737     \context PianoStaff <
4738         \context Voice = voiceI { % same as voiceII, but with ordinary notes
4739             \notes \relative c' {
4740                 c4 f4
4741                 a4 <e4 d'4> | \break
4742                 < g8 a8 > < e8 a8 > a4 c1 < d4 b4 > e4 |
4743                 c4 a4 f4 g4 a4
4744             }
4745         }
4746         \context Voice = voiceII { % same as voiceI, but with cluster notation
4747             \notes \relative c' {
4748
4749                 % hide notes, accidentals, etc.
4750                 \property Thread.NoteHead \set #'transparent = ##t
4751                 \property Voice.Stem \set #'transparent = ##t
4752                 \property Voice.Beam \set #'transparent = ##t
4753                 \property Staff.Accidental \set #'transparent = ##t
4754
4755                 \property Voice.Cluster \set #'padding = #0.01
4756                 \property Voice.Cluster \set #'shape = #'ramp
4757
4758                 c4 f4
4759                 \startCluster
4760                 a4 <e4 d'4> | \break
4761                 < g8 a8 > < e8 a8 > a4 c1 < d4 b4 > e4 |
4762                 c4 \stopCluster a4 f4 g4 a4
4763             }
4764         }
4765     >
4766 }
4767 @end lilypond
4768
4769 Note that the second voice differs from the first one only by the
4770 additional keywords @code{\startCluster} and @code{\stopCluster} and the
4771 fact that notes, accidentals, etc. are hidden.  A future version of
4772 lilypond may automatically hide notes, accidentals, etc. within the
4773 scope of clusters.
4774
4775 Also note that a music expression like @code{< @{ g8 e8 @} a4 >} is
4776 illegal; in such a case, you can instead use the expression @code{< g8
4777 a8 > < e8 a8 >}.
4778
4779 By default, cluster engraver is in the voice context.  This allows
4780 putting ordinary notes and clusters together in the same staff, even
4781 simultaneously.  However, in such a case no attempt is made to
4782 automatically avoid collisions between ordinary notes and clusters.
4783
4784 The geometrical shape can be further controlled with grob properties
4785 @code{padding} and @code{shape}.  @code{padding} adds to the vertical
4786 extent of the shape (top and bottom) and is expressed in units of
4787 staffspace.  Since the pitch range of a single pitch is infinitely
4788 small, if padding is set to @code{0.0}, this possibly results in an
4789 invisible shape, if you,for example, say @code{ \startCluster c d e
4790 \endCluster}.  The default value for @code{padding} therefore is
4791 @code{0.25}, such that a single pitch roughly shows the same height as a
4792 note head.  Property @code{shape} controls how the overall shape of the
4793 cluster is constructed from the set of notes.  Currently supported
4794 values are @code{leftsided-stairs}, @code{rightsided-stairs},
4795 @code{centered-stairs}, and @code{ramp}.
4796
4797 @node Fermatas
4798 @subsection Fermatas
4799
4800 @cindex fermatas
4801
4802 Currently, lilypond supports the following fermata symbols that are
4803 frequently used in contemporary music notation:
4804
4805 @lilypond[singleline,verbatim]
4806 \score {
4807     \notes {
4808         \fatText
4809         b'
4810         ^\shortfermata
4811         _\shortfermata
4812         ^\markup { short fermata }
4813         r
4814         b'
4815         ^\fermata
4816         _\fermata
4817         ^\markup { fermata }
4818         r
4819         b'
4820         ^\longfermata
4821         _\longfermata
4822         ^\markup { long fermata }
4823         r
4824         b'
4825         ^\verylongfermata
4826         _\verylongfermata
4827         ^\markup { very long fermata }
4828         r
4829     }
4830 }
4831 @end lilypond
4832
4833 See @ref{Articulations} for general instructions how to apply scripts
4834 such as fermatas to a @code{\notes@{@}} block.
4835
4836 @c . {Tuning output}
4837 @node Tuning output
4838 @section Tuning output
4839
4840 LilyPond tries to take as much formatting as possible out of your
4841 hands. Nevertheless, there are situations where it needs some help, or
4842 where you want to override its decisions. In this section we discuss
4843 ways to do just that.
4844
4845 Formatting is internally done by manipulating so called objects (graphic
4846 objects). Each object carries with it a set of properties (object
4847 properties) specific to that object.  For example, a stem object has
4848 properties that specify its direction, length and thickness.
4849
4850 The most direct way of tuning the output is by altering the values of
4851 these properties. There are two ways of doing that: first, you can
4852 temporarily change the definition of a certain type of object, thus
4853 affecting a whole set of objects.  Second, you can select one specific
4854 object, and set a object property in that object.
4855
4856 @menu
4857 * Tuning groups of objects ::   
4858 * Tuning per object ::          
4859 * Font selection::              
4860 * Text markup::                 
4861 @end menu
4862
4863 @node Tuning groups of objects 
4864 @subsection Tuning groups of objects 
4865
4866 @cindex object description
4867
4868 A object definition is a Scheme association list, that is stored in a
4869 context property.  By assigning to that property (using plain
4870 @code{\property}), you can change the resulting objects.
4871
4872 @lilypond[verbatim, fragment,quote]
4873 c'4 \property Voice.NoteHead  = #'() c'4
4874 @end lilypond
4875 This mechanism is fairly crude, since you can only set, but not modify,
4876 the definition of an object. Also, it will thoroughly confuse LilyPond.
4877
4878 The definition of an object is actually a list of default object
4879 properties. For example, the definition of the Stem object (available
4880 in @file{scm/grob-description.scm}), includes the following definitions for
4881 @internalsref{Stem}
4882
4883 @example
4884         (thickness . 0.8)
4885         (beamed-lengths . (0.0 2.5 2.0 1.5))
4886         (Y-extent-callback . ,Stem::height)
4887         @var{...}
4888 @end example
4889
4890 You can add a property on top of the existing definition, or remove a
4891 property, thus overriding the system defaults:
4892 @lilypond[verbatim,quote]
4893 c'4 \property Voice.Stem \override #'thickness = #4.0
4894 c'4 \property Voice.Stem \revert #'thickness
4895 c'4
4896 @end lilypond
4897 You should balance @code{\override} and @code{\revert}. If that's too
4898 much work, you can use the @code{\set} shorthand. It performs a revert
4899 followed by an override. The following example gives exactly the same
4900 result as the previous one. 
4901 @lilypond[verbatim,quote]
4902 c'4 \property Voice.Stem \set #'thickness = #4.0
4903 c'4 \property Voice.Stem \set #'thickness = #0.8
4904 c'4
4905 @end lilypond
4906 If you use @code{\set}, you must explicitly restore the default.
4907
4908
4909 Formally the syntax for these constructions is
4910 @example
4911 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
4912 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
4913 \property @var{context}.@var{grobname} \revert @var{symbol}
4914 @end example
4915 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
4916 and @var{grobname} are strings and @var{value} is a Scheme expression.
4917
4918
4919 If you revert a setting which was not set in the first place, then it
4920 has no effect. However, if the setting was set as a system default, it
4921 may remove the default value, and this may give surprising results,
4922 including crashes.  In other words, @code{\override} and @code{\revert},
4923 must be carefully balanced.
4924
4925 These are examples of correct nesting of @code{\override}, @code{\set},
4926 @code{\revert}. 
4927
4928 A clumsy but correct form:
4929 @example
4930   \override \revert \override \revert \override \revert
4931 @end example
4932
4933 Shorter version of the same:
4934 @example 
4935   \override \set \set  \revert
4936 @end example
4937
4938 A short form, using only @code{\set}. This requires you to know the
4939 default value:
4940 @example
4941   \set \set \set \set @var{to default value}
4942 @end example
4943
4944 If there is no default (i.e. by default, the object property is unset),
4945 then you can use
4946 @example
4947   \set \set \set \revert
4948 @end example
4949
4950 For the digirati, the object description is an Scheme association
4951 list. Since a Scheme list is a singly linked list, we can treat it as a
4952 stack, and @code{\override} and @code{\revert} are just push and pop
4953 operations. This pushing and popping is also used for overriding
4954 automatic beaming settings.
4955
4956 @refbugs
4957
4958 LilyPond will hang or crash if @var{value} contains cyclic references.
4959 The backend is not very strict in type-checking object properties. If you
4960 @code{\revert} properties that are expected to be set by default,
4961 LilyPond may crash.
4962
4963
4964
4965
4966 @node Tuning per object 
4967 @subsection Tuning per object 
4968
4969 @cindex \once
4970 Tuning a single object is most often done with @code{\property}. The
4971 form,
4972 @example
4973         \once \property @dots{}
4974 @end example
4975 @c
4976 applies a setting only during one moment in the score: notice how the
4977 original setting for stem thickness is restored automatically in the
4978 following example
4979 @c
4980 @lilypond[verbatim, fragment, relative=1]
4981   c4 
4982   \once \property Voice.Stem \set #'thickness = #4
4983   c4
4984   c4
4985 @end lilypond
4986
4987 @cindex \once
4988 @cindex \outputproperty
4989
4990 A second way of tuning objects is the more arcane @code{\outputproperty}
4991 feature.  The syntax is as follows:
4992 @example
4993 \outputproperty @var{predicate} @var{symbol} = @var{value}
4994 @end example
4995 Here @code{predicate} is a Scheme function taking a object argument, and
4996 returning a boolean.  This statement is processed by the
4997 @code{Output_property_engraver}.  It instructs the engraver to feed all
4998 objects that it sees to @var{predicate}. Whenever the predicate returns
4999 true, the object property @var{symbol} will be set to @var{value}.
5000
5001 This command is only single shot, in contrast to @code{\override} and
5002 @code{\set}.
5003
5004 You will need to combine this statement with @code{\context} to select
5005 the appropriate context to apply this to.
5006
5007 In the following example, all note heads occurring at current staff
5008 level, are shifted up and right by setting their @code{extra-offset}
5009 property.
5010
5011 @lilypond[fragment,verbatim,singleline]
5012 \relative c'' { c4
5013   \context Staff \outputproperty
5014   #(make-type-checker 'note-head-interface)
5015   #'extra-offset = #'(0.5 . 0.75)
5016   <<c e g>>8 }
5017 @end lilypond
5018
5019 @cindex @code{extra-offset}
5020
5021 In this example, the predicate checks the @code{text} object property, to
5022 shift only the `m.d.' text,  but not the fingering instruction "2".
5023 @lilypond[verbatim,singleline]
5024 #(define (make-text-checker text)
5025    (lambda (grob) (equal? text (ly:get-grob-property grob 'text))))
5026
5027 \score {    
5028   \notes\relative c''' {
5029     \property Voice.Stem \set #'direction = #1
5030     \outputproperty #(make-text-checker "m.d.")
5031       #'extra-offset = #'(-3.5 . -4.5)
5032     a^2^"m.d."    
5033   }
5034 }
5035 @end lilypond
5036
5037 @refbugs
5038
5039 If possible, avoid this feature: the semantics are not very clean, and
5040 the syntax and semantics are up for rewrite.
5041
5042
5043
5044
5045 @node Font selection
5046 @subsection Font selection
5047
5048 The most common thing to change about the appearance of fonts is
5049 their size. The font size of a @internalsref{Voice},
5050 @internalsref{Staff} or @internalsref{Thread} context, can be easily
5051 changed by setting the @code{fontSize} property for that context:
5052 @lilypond[fragment,relative=1,verbatim,quote]
5053   c4 c4 \property Voice.fontSize = #-1
5054   f4 g4
5055 @end lilypond
5056  This command will not change the size of variable symbols, such as
5057 beams or slurs.  You can use this command to get smaller symbol for
5058 cue notes, but that involves some more subtleties. An elaborate
5059 example of those is in @inputfileref{input/test,cue-notes.ly}.
5060
5061 @cindex cue notes
5062 @cindex font size
5063 @cindex size
5064 @cindex symbol size
5065 @cindex glyph size
5066
5067 The font used for printing a object can be selected by setting
5068 @code{font-name}, e.g.
5069 @example
5070   \property Staff.TimeSignature
5071     \set #'font-name = #"cmr17"
5072 @end example
5073 You may use any font which is available to @TeX{}, such as foreign
5074 fonts or fonts that do not belong to the Computer Modern font family.
5075 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
5076 can also be adjusted with a more fine-grained mechanism.  By setting
5077 the object properties described below, you can select a different font.
5078 All three mechanisms work for every object that supports
5079 @code{font-interface}.
5080
5081 @table @code
5082 @item font-family
5083  A symbol indicating the general class of the typeface.  Supported are
5084 @code{roman} (Computer Modern), @code{braces} (for piano staff
5085 braces), @code{music} (the standard music font), @code{ancient} (the
5086 ancient notation font) @code{dynamic} (font for dynamic signs) and
5087 @code{typewriter}. 
5088   
5089 @item font-shape
5090   A symbol indicating the shape of the font, there are typically several
5091   font shapes available for each font family. Choices are @code{italic},
5092   @code{caps} and @code{upright} 
5093
5094 @item font-series
5095 A  symbol indicating the series of the font. There are typically several
5096 font series for each font family and shape. Choices are @code{medium}
5097 and @code{bold}. 
5098
5099 @item font-relative-size
5100   A number indicating the size relative the standard size.  For example,
5101   with 20pt staff height, relative size -1  corresponds to 16pt staff
5102   height, and relative size +1 corresponds to 23 pt staff height.
5103
5104 @item font-design-size
5105 A number indicating  the design size of the font. 
5106
5107 This is a feature of the Computer Modern Font: each point size has a
5108 slightly different design. Smaller design sizes are relatively wider,
5109 which enhances readability.
5110 @end table
5111
5112 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
5113 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
5114 to override default setting, which are always present. For example:
5115 @example
5116   \property Lyrics.LyricText \override #'font-series = #'bold
5117   \property Lyrics.LyricText \override #'font-family = #'typewriter
5118   \property Lyrics.LyricText \override #'font-shape  = #'*
5119 @end example
5120
5121 @cindex @code{font-style}
5122
5123 There are also pre-cooked font selection qualifiers. These are
5124 selected through the object property @code{font-style}.  For example,
5125 the style @code{finger} selects family @code{number} and relative size
5126 @code{-3}.  Styles available include @code{volta}, @code{finger},
5127 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
5128 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
5129 tables for selecting fonts are located in @file{scm/font.scm}. Refer
5130 to this file for more information.
5131
5132 @cindex magnification
5133
5134 The size of the font may be scaled with the object property
5135 @code{font-magnification}.  For example, @code{2.0} blows up all
5136 letters by a factor 2 in both directions.
5137
5138 @refbugs
5139
5140 Relative size is not linked to any real size.
5141
5142 There is no style sheet provided for other fonts besides the @TeX{}
5143 family, and the style sheet can not be modified easily.
5144
5145 @cindex font selection
5146 @cindex font magnification
5147 @cindex @code{font-interface}
5148
5149
5150 @node Text markup
5151 @subsection Text markup
5152 @cindex text markup
5153 @cindex markup text
5154
5155
5156 @cindex typeset text
5157
5158 LilyPond has an internal mechanism to typeset texts. You can access it
5159 with the keyword @code{\markup}. Within markup mode, you can enter texts
5160 similar to lyrics: simply enter them, surrounded by spaces. 
5161 @cindex markup
5162
5163 @lilypond[verbatim,fragment,relative=1]
5164  c1^\markup { hello }
5165  c1_\markup { hi there }
5166  c1^\markup { hi \bold there, is \italic anyone home? }
5167 @end lilypond
5168
5169 @cindex font switching
5170
5171 The line of the example demonstrates font switching commands. Notice
5172 that the command only apply to the first following word; enclose a set
5173 of texts with braces to apply a command to more words.
5174 @example
5175   \markup @{ \bold @{ hi there @} @}
5176 @end example
5177 For clarity, you can also do this for single arguments, e.g.
5178 @example
5179   \markup @{ is \italic @{ anyone @} home @}
5180 @end example
5181
5182 @cindex font size, texts
5183
5184
5185 The following size commands set abolute sizes
5186
5187 @cindex \teeny
5188 @cindex \tiny
5189 @cindex \small
5190 @cindex \large
5191 @cindex \huge
5192
5193 @table @code
5194 @item \teeny
5195 @item \tiny
5196 @item \small
5197 @item \large
5198 @item \huge
5199 @end table
5200
5201 You can also make letter larger or smaller relative to their neighbors,
5202 with the commands @code{\larger} and @code{\smaller}.
5203 @cindex smaller
5204 @cindex larger
5205
5206 @cindex font style, for texts
5207 @cindex \bold
5208 @cindex \dynamic
5209 @cindex \number
5210 @cindex \italic
5211
5212 The following font change commands are defined:
5213 @table @code
5214 @item \dynamic
5215 This changes to the font used for dynamic signs. Note that this font
5216 doesn't contain all characters of the alphabet.
5217 @item \number
5218 This changes to the font used for time signatures. It only contains
5219 numbers and a few punctuation marks.
5220 @item \italic
5221 @item \bold
5222 @end table
5223
5224 @cindex raising text
5225 @cindex lowering text
5226 @cindex moving text
5227 @cindex translating text
5228
5229 @cindex \sub
5230 @cindex \super
5231
5232 Raising and lowering texts can be done with @code{\super} and
5233 @code{\sub}.
5234
5235 @lilypond[verbatim,fragment,relative=1]
5236  c1^\markup { E "=" mc \super "2" }
5237 @end lilypond
5238
5239 @cindex \raise
5240
5241 If you want to give an explicit amount for lowering or raising, use
5242 @code{\raise}.  This command takes a Scheme valued argument,
5243 @lilypond[verbatim,fragment,relative=1,quote]
5244  c1^\markup { C \small \raise #1.0 { "9/7+" }}
5245 @end lilypond
5246 The argument to @code{\raise} is the vertical displacement amount,
5247 measured in (global) staff spaces.
5248
5249 Other commands taking  single arguments include
5250 @table @code
5251
5252 @item \bracket, \hbracket
5253  Bracket the argument markup.
5254
5255 @item \musicglyph
5256 @cindex \musicglyph
5257   This is converted to a musical symbol, e.g. @code{\musicglyph
5258 #"accidentals-0"} will select the natural sign from the music font.
5259 See @ref{The Feta font} for  a complete listing of the possible glyphs.
5260 @item \char
5261 This produces a single character, e.g. @code{\char #65} produces the 
5262 letter 'A'.
5263
5264 @item \hspace #@var{amount}
5265 @cindex \hspace
5266 This produces a invisible object taking horizontal space.
5267 @example 
5268 \markup @{ A \hspace #2.0 B @} 
5269 @end example
5270 will put extra space between A and B. Note that lilypond 
5271 inserts space before and after @code{\hspace}. 
5272
5273 @item \fontsize #@var{size}
5274 @cindex \fontsize
5275 This sets the relative font size, eg.
5276 @example
5277 A \fontsize #2 @{ B C @} D
5278 @end example
5279
5280
5281 This will enlarge the B and the C by two steps.
5282 @item  \translate #(cons @var{x} @var{y})
5283 @cindex  \translate
5284 This translates an object. It's first argument is a cons of numbers
5285 @example
5286 A \translate #(cons 2 -3) @{ B C @} D
5287 @end example
5288 This moves `B C' 2 spaces to the right, and 3 down.
5289
5290 @item \magnify  #@var{mag}
5291 @cindex \magnify
5292 This sets the font magnification for the its argument. In the following
5293 example, the middle A will be 10% larger.
5294 @example
5295 A \magnify #1.1 @{ A @} A
5296 @end example
5297
5298
5299 @item \override #(@var{key} . @var{value})
5300 @cindex \override
5301 This overrides a  formatting property for its argument. The argument
5302 should be a key/value pair, e.g.
5303 @example
5304 m \override #'(font-family . math) m m
5305 @end example
5306 @end table
5307
5308 In markup mode you can compose expressions, similar to mathematical
5309 expressions, XML documents and music expressions.  The braces group
5310 notes into horizontal lines. Other types of lists also exist: you can
5311 stack expressions grouped with @code{<<}, and @code{>>} vertically with
5312 the command @code{\column}. Similarly, @code{\center} aligns texts by
5313 their center lines. 
5314
5315 @lilypond[verbatim,fragment,relative=1]
5316  c1^\markup { \column << a bbbb c >> }
5317  c1^\markup { \center << a bbbb c >> }
5318  c1^\markup { \line << a b c >> }
5319 @end lilypond
5320
5321
5322
5323 The markup mechanism is very flexible and extensible.  Refer to
5324 @file{scm/new-markup.scm} for more information on extending the markup
5325 mode.
5326
5327
5328 @cindex metronome mark
5329
5330 One practical application of complicated markup is to fake a metronome
5331 marking:
5332
5333 @lilypond[verbatim]
5334 eighthStem = \markup \combine
5335         \musicglyph #"flags-stem"
5336         \translate #'(0.0 . 3.5) \musicglyph #"flags-u3"
5337 eighthNote = \markup
5338         \override #'(word-space . 0.0)
5339         { \musicglyph #"noteheads-2"
5340           \translate #'(-0.05 . 0.1) \eighthStem }
5341
5342 \score {
5343   \notes\relative c'' {
5344     a1^\markup { \magnify #0.9 \eighthNote " = 64" }
5345   }
5346 }
5347 @end lilypond
5348
5349 @refbugs
5350
5351 @cindex kerning
5352
5353 LilyPond does not account for kerning in its text formatting, so it
5354 spaces texts slightly too wide.
5355
5356 Syntax errors for markup mode are confusing.
5357
5358
5359 @node Global layout
5360 @section Global layout
5361
5362 The global layout determined by three factors: the page layout, the
5363 line breaks and the spacing. These all influence each other: The
5364 choice of spacing determines how densely each system of music is set,
5365 where line breaks breaks are chosen, and thus ultimately how many
5366 pages a piece of music takes. In this section we will explain how the
5367 lilypond spacing engine works, and how you can tune its results.
5368
5369 Globally spoken, this procedure happens in three steps: first,
5370 flexible distances (``springs'') are chosen, based on durations. All
5371 possible line breaking combination are tried, and the one with the
5372 best results---a layout that has uniform density and requires as
5373 little stretching or cramping as possible---is chosen. When the score
5374 is processed by @TeX{}, page are filled with systems, and page breaks
5375 are chosen whenever the page gets full.
5376
5377 @menu
5378 * Vertical spacing::            
5379 * Horizontal spacing::          
5380 * Font Size::                   
5381 * Line breaking::               
5382 * Page layout::                 
5383 @end menu
5384
5385
5386 @node Vertical spacing
5387 @subsection Vertical spacing
5388
5389 @cindex vertical spacing
5390 @cindex distance between staves
5391 @cindex staff distance
5392 @cindex between staves, distance
5393 @cindex staffs per page
5394
5395
5396 The height of each system is determined automatically by lilypond, to
5397 keep systems from bumping into each other, some minimum distances are
5398 set.  By changing these, you can put staves closer together, and thus
5399 put more  systems onto one page.
5400
5401 Normally staves are stacked vertically. To make
5402 staves maintain a distance, their vertical size is padded. This is
5403 done with the property @code{minimumVerticalExtent}. It takes a pair
5404 of numbers, so if you want to make it smaller from its, then you could
5405 set
5406 @example
5407   \property Staff.minimumVerticalExtent = #'(-4 . 4)
5408 @end example
5409 This sets the vertical size of the current staff to 4 staff-space on
5410 either side of the center staff line.  The argument of
5411 @code{minimumVerticalExtent} is interpreted as an interval, where the
5412 center line is the 0, so the first number is generally negative.  you
5413 could also make the staff larger at the bottom by setting it to
5414 @code{(-6 . 4)}. The default value is @code{(-6 . 6)}.
5415
5416 Vertical aligment of staves is handled by the
5417 @internalsref{VerticalAlignment} object, which lives at
5418 @internalsref{Score} level.
5419
5420 The piano staves are handled a little differently: to make cross-staff
5421 beaming work correctly, it necessary that the distance between staves
5422 is fixed.  This is also done with a @internalsref{VerticalAlignment}
5423 object, created in @internalsref{PianoStaff}, but a forced distance is
5424 set. This is done with the object property #'forced-distance. If you
5425 want to override this, use a @code{\translator} block as follows:
5426 @example
5427   \translator @{
5428     \PianoStaffContext
5429     VerticalAlignment \override #'forced-distance = #9
5430   @}
5431 @end example
5432 This would bring the staves together at a distance of 9 staff spaces,
5433 and again this is measured from the center line of each staff.
5434
5435
5436
5437 @node Horizontal spacing
5438 @subsection Horizontal Spacing
5439
5440 The spacing engine translates differences in durations into
5441 stretchable distances (``springs'') of differing lengths. Longer
5442 durations get more space, shorter durations get less.  The basis for
5443 assigning spaces to durations, is that the shortest durations get a
5444 fixed amount of space, and the longer durations get more: doubling a
5445 duration adds a fixed amount of space to the note.
5446
5447 For example, the following piece contains lots of half, quarter and
5448 8th notes, the eighth note is followed by 1 note head width. The The
5449 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
5450 @lilypond[fragment, verbatim, relative=1]
5451  c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
5452 @end lilypond
5453
5454 These two amounts of space are @code{shortest-duration-space}
5455 @code{spacing-increment}, object properties of
5456 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
5457 set to 1.2, which is the width of a note head, and
5458 @code{shortest-duration-space} is set to 2.0, meaning that the
5459 shortest note gets 2 noteheads of space. For normal notes, this space
5460 is always counted from the left edge of the symbol, so the short notes
5461 in a score is generally followed by one note head width of space.
5462
5463 If one would follow the above procedure exactly, then adding a single
5464 32th note to a score that uses 8th and 16th notes, would widen up the
5465 entire score a lot. The shortest note is no longer a 16th, but a 64th,
5466 thus adding 2 noteheads of space to every note. To prevent this, the
5467 shortest duration for spacing is not the shortest note in the score,
5468 but the most commonly found shortest note.  Notes that are even
5469 shorter this are followed by a space that is proportonial to their
5470 duration relative to the common shortest note.  So if we were to add
5471 only a few 16th notes to the example above, they would be followed by
5472 half a NHW:
5473
5474 @lilypond[fragment, verbatim, relative=1]
5475  c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
5476 @end lilypond
5477
5478 The most common shortest duration is determined as follows: in every
5479 measure, the shortest duration is determined. The most common short
5480 duration, is taken as the basis for the spacing, with the stipulation
5481 that this shortest duration should always be equal to or shorter than
5482 1/8th note. The shortest duration is printed when you run lilypond
5483 with @code{--verbose}.  These durations may also be customized. If you
5484 set the @code{common-shortest-duration} in
5485 @internalsref{SpacingSpanner}, then this sets the base duration for
5486 spacing. The maximum duration for this base (normally 1/8th), is set
5487 through @code{base-shortest-duration}.
5488
5489 @cindex @code{common-shortest-duration}
5490 @cindex @code{base-shortest-duration}
5491 @cindex @code{stem-spacing-correction}
5492 @cindex @code{spacing}
5493
5494 In the introduction it was explained that stem directions influence
5495 spacing. This is controlled with @code{stem-spacing-correction} in
5496 @internalsref{NoteSpacing}. The @code{StaffSpacing} object contains the
5497 same property for controlling the stem/barline spacing. In the
5498 following example shows these corrections, once with default settings,
5499 and once with exaggerated corrections.  
5500
5501 @lilypond
5502     \score { \notes {
5503       c'4 e''4 e'4 b'4 |
5504       b'4 e''4 b'4 e''4|
5505       \property Staff.NoteSpacing \override #'stem-spacing-correction
5506       = #1.5
5507       \property Staff.StaffSpacing \override #'stem-spacing-correction
5508       = #1.5
5509       c'4 e''4 e'4 b'4 |
5510       b'4 e''4 b'4 e''4|      
5511     }
5512     \paper { linewidth = -1. } }
5513 @end lilypond
5514
5515 @cindex SpacingSpanner, overriding properties
5516
5517 The @internalsref{SpacingSpanner}, is score wide, so its properties
5518 must be overriden from the @code{\paper} block, e.g.
5519 @example
5520 \paper @{ \translator  @{
5521   \ScoreContext
5522   SpacingSpanner \override #'spacing-increment = #3.0
5523 @} @}
5524 @end example
5525
5526
5527 @refbugs
5528
5529 Spacing is determined on a score wide basis. If you have a score that
5530 changes its character (measured in durations) half way during the
5531 score, the part containing the longer durations will be spaced too
5532 widely.
5533
5534 Generating optically pleasing spacing is black magic. LilyPond tries
5535 to deal with a number of frequent cases. Here is an example that is
5536 not handled correctly, due to the combination of chord collisions and
5537 kneed stems.
5538
5539 @lilypond
5540 \score {
5541      \context PianoStaff \notes \transpose c c'' <
5542      \context Staff = up { s1 }
5543      \context Staff = down { [c8 c \translator Staff=up <<c d>> c 
5544 \translator Staff=down c c c] }
5545      >
5546      \paper { linewidth = -1 }
5547 }
5548 @end lilypond
5549
5550
5551 @c .  {Font size}
5552 @node Font Size
5553 @subsection Font size
5554 @cindex font size, setting
5555 @cindex staff size, setting
5556 @cindex @code{paper} file
5557
5558 The Feta font provides musical symbols at seven different sizes.
5559 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
5560 point, and 26 point.  The point size of a font is the height of the
5561 five lines in a staff when displayed in the font.
5562
5563 Definitions for these sizes are the files @file{paperSZ.ly}, where
5564 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26.  If you include any
5565 of these files, the identifiers @code{paperEleven},
5566 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
5567 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
5568 are defined respectively.  The default @code{\paper} block is also
5569 set. These files should be imported at toplevel, i.e.
5570 @example
5571         \include "paper26.ly"
5572         \score @{  ... @}
5573 @end example
5574
5575 The font definitions are generated using a Scheme function. For more
5576 details, see the file @file{scm/font.scm}.
5577
5578
5579 @c .  {Line break}
5580 @node Line breaking
5581 @subsection Line breaking
5582
5583 @cindex line breaks
5584 @cindex breaking lines
5585
5586 Line breaks are normally computed automatically. They are chosen such
5587 that it looks neither cramped nor loose, and that consecutive lines have
5588 similar density.
5589
5590 Occasionally you might want to override the automatic breaks; you can
5591 do this by specifying @code{\break}. This will force a line break at
5592 this point.  Line breaks can only occur at places where there are bar
5593 lines.  If you want to have a line break where there is no bar line,
5594 you can force an invisible bar line by entering @code{\bar
5595 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
5596 point.
5597
5598
5599 @cindex regular line breaks
5600 @cindex four bar music. 
5601
5602 If you want linebreaks at regular intervals, you can use the following:
5603 @example
5604 <  \repeat 7 unfold @{ s1 * 4 \break  @}
5605    @emph{real music}
5606
5607 @end  example
5608 This makes the following 28 measures (assuming 4/4 time) be broken every
5609 4 measures.
5610
5611 @node Page layout
5612 @subsection Page layout
5613
5614 @cindex page breaks
5615 @cindex breaking pages
5616
5617 @cindex @code{indent}
5618 @cindex @code{linewidth}
5619
5620 The most basic settings influencing the spacing are @code{indent} and
5621 @code{linewidth}. They are set in the @code{\paper} block. They
5622 control the indentation of the first line of music, and the lengths of
5623 the lines.  If @code{linewidth} set to a negative value, a single
5624 unjustified line is produced.  A similar effect for scores that are
5625 longer than one line, can be produced by setting @code{raggedright} to
5626 true in the @code{\paper} block.
5627
5628 @cindex page layout
5629 @cindex vertical spacing
5630
5631 The page layout process happens outside lilypond. Ly2dvi sets page
5632 layout instructions. Ly2dvi responds to the following variables in the
5633 @code{\paper} block.  The variable @code{textheight} sets the total
5634 height of the music on each page.  The spacing between systems is
5635 controlled with @code{interscoreline}, its default is 16pt.
5636 The distance between the score lines will stretch in order to fill the
5637 full page @code{interscorelinefill} is set to a positive number.  In
5638 that case @code{interscoreline} specifies the minimum spacing.
5639
5640 @cindex @code{textheight}
5641 @cindex @code{interscoreline}
5642 @cindex @code{interscorelinefill}
5643
5644 If the variable @code{lastpagefill} is defined (that is, it gets any
5645 value assigned in the @code{\paper} block), systems are evenly
5646 distributed vertically on the last page.  This might produce ugly
5647 results in case there are not enough systems on the last page.  Note
5648 that @command{lilypond-book} ignores @code{lastpagefill}.  See
5649 @ref{Integrating text and music with lilypond-book} for
5650 more information.
5651
5652 @cindex @code{lastpagefill}
5653
5654 Page breaks are normally computed by @TeX{}, so they are not under
5655 direct control of LilyPond.  However, you can insert a commands into
5656 the @file{.tex} output to instruct @TeX{} where to break pages. You
5657 can insert a @code{\newpage} from within lilypond. This is done by
5658 setting the @code{between-systems-strings} on the
5659 @internalsref{NonMusicalPaperColumn} where the system is broken.
5660
5661 @cindex paper size
5662 @cindex page size
5663 @cindex @code{papersize}
5664
5665 To change the paper size, you must first set the
5666 @code{papersize} paper variable variable.  Set it to
5667 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
5668 specification, you must set the font as described above.  If you want
5669 the default font, then use the 20 point font.
5670
5671 @example
5672         \paper@{ papersize = "a4" @}
5673         \include "paper16.ly"
5674 @end example
5675
5676 The file @code{paper16.ly}  will now include a file named @file{a4.ly}, which
5677 will set the paper variables @code{hsize} and @code{vsize} (used by
5678 Lilypond and @code{ly2dvi})
5679
5680
5681
5682
5683 @c . {Sound}
5684 @node Sound
5685 @section Sound
5686 @cindex Sound
5687
5688 LilyPond can produce MIDI output.  The performance lacks lots of
5689 interesting effects, such as swing, articulation, slurring, etc., but it
5690 is good enough for proof-hearing the music you have entered.  Ties,
5691 dynamics and tempo changes are interpreted.
5692
5693 Dynamic marks, crescendi and decrescendi translate into MIDI volume
5694 levels.  Dynamic marks translate to a fixed fraction of the available
5695 MIDI volume range, crescendi and decrescendi make the the volume vary
5696 linearly between their two extremities.  The fractions be adjusted by
5697 overriding the @code{absolute-volume-alist} defined in
5698 @file{scm/midi.scm}.
5699
5700 For each type of musical instrument (that MIDI supports), a volume range
5701 can be defined.  This gives you basic equalizer control, which can
5702 enhance the quality of the MIDI output remarkably.  You can add
5703 instruments and ranges or change the default settings by overriding the
5704 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
5705
5706 Both loudness controls are combined to produce the final  MIDI volume. 
5707
5708 @menu
5709 * MIDI block::                  
5710 * MIDI instrument names::       
5711 @end menu
5712
5713 @c .  {MIDI block}
5714 @node MIDI block
5715 @subsection MIDI block
5716 @cindex MIDI block
5717
5718
5719 The MIDI block is analogous to the paper block, but it is somewhat
5720 simpler.  The @code{\midi} block can contain:
5721 @cindex MIDI block
5722
5723 @itemize @bullet
5724   @item  a @code{\tempo} definition
5725   @item  context definitions
5726 @end itemize
5727
5728 Assignments in the @code{\midi} block are not allowed.
5729
5730
5731
5732 @cindex context definition
5733
5734 Context definitions follow precisely the same syntax as within the
5735 \paper block.  Translation modules for sound are called performers.
5736 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
5737
5738
5739 @node MIDI instrument names
5740 @subsection MIDI instrument names
5741
5742 @cindex instrument names
5743 @cindex @code{Staff.midiInstrument}
5744 @cindex @code{Staff.instrument}
5745
5746 The MIDI instrument name is set by the @code{Staff.midiInstrument}
5747 property or, if that property is not set, the @code{Staff.instrument}
5748 property.  The instrument name should be chosen from the list in
5749 @ref{MIDI instruments}.
5750
5751 @refbugs
5752
5753 If the selected string does not exactly match, then LilyPond uses the
5754 default (Grand Piano). It is not possible to select an instrument by
5755 number.
5756
5757