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