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