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