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