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