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