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