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