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