]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
Point and click: KDVI
[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
7 @c FIXME: singular vs. plural:  Beams/Beam
8
9
10 @macro refbugs
11 @strong{BUGS}
12
13 @end macro
14
15
16 @c .{Reference Manual}
17
18 @node Reference Manual
19 @chapter Reference Manual
20
21 @html
22 <!--- @@WEB-TITLE@@=Reference Manual --->
23 @end html
24
25 This document describes GNU LilyPond and its input format. The last
26 revision of this document was made for LilyPond 1.4.1.  It supposes a
27 passing familiarity with how LilyPond input works. New users are
28 encouraged to study the tutorial first.
29
30
31 @menu
32 * Note entry::                  
33 * Easier music entry::          
34 * Staff notation::              
35 * Polyphony::                   
36 * Beaming::                     
37 * Accidentals::                 
38 * Expressive marks::            
39 * Ornaments::                   
40 * Repeats::                     
41 * Rhythmic music::              
42 * Piano music::                 
43 * Tablatures::                  
44 * Chords::                      
45 * Writing parts::               
46 * Ancient notation ::           
47 * Tuning output::               
48 * Global layout::               
49 * Output formats::              
50 * Sound::                       
51 @end menu
52
53 @c FIXME: Note entry vs Music entry at top level menu is confusing.
54 @c . {Note entry}
55 @node Note entry
56 @section Note entry
57 @cindex Note entry
58
59 The most basic forms of music are notes.  Notes on their own don't
60 form valid input, but for the sake of brevity we omit @code{\score}
61 blocks and @code{\paper} declarations.
62
63
64 @menu
65 * Notes::                       
66 * Pitches::                     
67 * Chromatic alterations::       
68 * Rests::                       
69 * Skips::                       
70 * Durations::                   
71 * Ties::                        
72 * Automatic note splitting ::   
73 * Tuplets::                     
74 * Easy Notation note heads ::   
75 @end menu
76
77 @c . {Notes}
78 @node Notes
79 @subsection Notes
80
81
82 A note is printed by specifying its pitch, and then its duration.
83 @lilypond[fragment,verbatim]
84   cis'4 d'8 e'16 c'16
85 @end lilypond
86
87 @c .  {Pitches}
88 @node Pitches
89 @subsection Pitches
90
91 @cindex Pitch names
92 @cindex Note specification
93 @cindex pitches
94 @cindex entering notes
95
96 The verbose syntax for pitch specification is
97
98 @cindex @code{\pitch}
99 @example
100   \pitch @var{scmpitch}
101 @end example
102
103 @var{scmpitch} is a pitch scheme object.
104
105 In Note and Chord mode, pitches may be designated by names.  The default
106 names are the Dutch note names.  The notes are specified by the letters
107 @code{a} through @code{g} (where the octave is formed by notes ranging
108 from @code{c} to @code{b}).  The pitch @code{c} is an octave below
109 middle C and the letters span the octave above that C.
110
111 @cindex note names, Dutch
112
113 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
114 name and a flat is formed by adding @code{-es}. Double sharps and double
115 flats are obtained by adding @code{-isis} or @code{-eses}.  @code{aes}
116 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
117 both forms are accepted.
118
119 LilyPond has predefined sets of note names for various other languages.
120 To use them, simply include the language specific init file.  For
121 example: @code{\include "english.ly"}.  The available language files and
122 the names they define are:
123
124 @example 
125                         Note Names               sharp       flat
126 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
127 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
128 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
129 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
130 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
131 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
132 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b 
133 espanol.ly     do  re  mi  fa  sol la  sib si  -s          -b 
134
135 @end example 
136
137 @cindex @code{'}
138 @cindex @code{,}
139
140
141
142 The optional octave specification takes the form of a series of
143 single quote (`@code{'}') characters or a series of comma
144 (`@code{,}') characters.  Each @code{'} raises the pitch by one
145 octave; each @code{,} lowers the pitch by an octave.
146
147 @lilypond[fragment,verbatim,center]
148   c' c'' es' g' as' gisis' ais'  
149 @end lilypond
150
151 @node Chromatic alterations
152 @subsection Chromatic alterations
153
154 Normally, accidentals are printed automatically, but you may force
155 accidentals in the following ways: A reminder accidental
156 @cindex reminder accidental
157 @cindex @code{?}
158 can be forced by adding an exclamation mark @code{!} after the pitch.  A
159 cautionary accidental,
160 @cindex cautionary accidental
161 @cindex parenthesized accidental
162 i.e., an accidental within parentheses can be obtained by adding the
163 question mark `@code{?}' after the pitch.
164
165 The automatic production of accidentals can be tuned in many
166 ways. Refer to @ref{Accidentals} for more information.
167
168 @c .  {Rests}
169 @node  Rests
170 @subsection Rests
171 @cindex Rests
172
173 A rest is entered like a note, with note name `@code{r}':
174
175 @lilypond[singleline,verbatim]
176 r1 r2 r4 r8
177 @end lilypond
178
179 Whole bar rests centered in the bar are specified using @code{R}, see
180 @ref{Multi measure rests}. See also @seeinternals{Rest}.
181
182 For polyphonic music, it can be convenient to specify the rest position
183 directly. You can do that by entering a note, with the keyword
184 @code{\rest} appended, e.g. Rest collisions will leave these rests alone.
185
186 @lilypond[singleline,verbatim]
187 a'4\rest d'4\rest
188 @end lilypond
189
190
191 @c .  {Skips}
192 @c FIXME: naming.
193 @node Skips
194 @subsection Skips
195 @cindex Skip
196 @cindex Invisible rest
197 @cindex Space note
198
199 An invisible rest, or skip, can be entered like a note with note name
200 @code{s}, or with @code{\skip @var{duration}}:
201
202 @lilypond[singleline,verbatim]
203 a2 s4 a4 \skip 1 a4 
204 @end lilypond
205
206 The @code{s} syntax  is only available in Note mode and Chord mode. 
207 In other situations, you should use the @code{\skip} command, and it is
208 only available in Note mode and Chord mode.
209
210 @c FIXME: in lyrics mode, we have " " and _
211
212 In Lyrics mode, you can use `@code{" "}' and `@code{_}':
213 @lilypond[singleline,verbatim]
214 <
215   \context Lyrics \lyrics { lah2 di4 " " dah2 _4 di }
216   \notes\relative c'' { a2 a4 a a2 a4 a }
217 >
218 @end lilypond
219
220 The unabbreviated `@code{\skip} @var{duration}' also works outside of
221 note mode:
222
223 @lilypond[singleline,verbatim]
224 \score {
225   \context Staff <
226     { \time 4/8 \skip 2 \time 4/4 } 
227     \notes\relative c'' { a2 a1 }
228   >
229 }
230 @end lilypond
231
232 The skip command is merely a empty musical placeholder. It does not
233 produce any output, not even transparent output.
234
235
236 @c .  {Durations}
237 @node Durations
238 @subsection Durations
239
240
241 @cindex duration
242 @cindex @code{\duration}
243
244
245 In Note, Chord, and Lyrics mode, durations may be designated by numbers
246 and dots: durations are entered as their reciprocal values.  For notes
247 longer than a whole you must use identifiers.
248
249 @example 
250  c'\breve  
251 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 
252 r\longa r\breve  
253 r1 r2 r4 r8 r16 r32 r64 r64 
254 @end example 
255
256
257 @lilypond[]
258 \score {
259   \notes \relative c'' {
260     a\breve  \autoBeamOff
261     a1 a2 a4 a8 a16 a32 a64 a64 
262     r\longa r\breve  
263     r1 r2 r4 r8 r16 r32 r64 r64 
264   }
265   \paper {
266     \translator {
267       \StaffContext
268         \remove "Clef_engraver"
269         \remove "Staff_symbol_engraver"
270         \remove "Time_signature_engraver"
271         \consists "Pitch_squash_engraver"
272     }
273   }
274 }
275 @end lilypond
276
277
278 If the duration is omitted then it is set to the previous duration
279 entered.  At the start of parsing a quarter note is assumed.  The
280 duration can be followed by dots (`@code{.}')  to obtain dotted note
281 lengths.
282 @cindex @code{.}
283
284 @lilypond[fragment,verbatim,center]
285   a'4. b'4.. c'8.
286 @end lilypond
287 @cindex @code{r}
288 @cindex @code{s}
289
290 You can alter the length of duration by a fraction @var{N/M} by
291 appending `@code{*}@var{N/M}' (or `@code{*}@var{N}' if @var{M=1}). This
292 will not affect the appearance of the notes or rests produced.
293
294 Durations can also be produced through GUILE extension mechanism. 
295 @lilypond[verbatim,fragment]
296  c\duration #(make-duration 2 1)
297 @end lilypond
298
299
300 @node Ties
301 @subsection Ties
302
303 @cindex Tie
304 @cindex ties
305 @cindex @code{~}
306
307 A tie connects two adjacent note heads of the same pitch.  The tie in
308 effect extends the length of a note. A tie is entered with @code{~}.
309
310 @lilypond[fragment,verbatim,center]
311   e' ~ e' <c' e' g'> ~ <c' e' g'>
312 @end lilypond
313
314 When ties are used with chords, all note heads whose pitches match are
315 connected.  Ties are indicated using the tilde symbol `@code{~}'.  If
316 you try to tie together chords which have no common pitches then no
317 ties will be created.
318
319 If you want less  ties created for a chord, you can  set
320 @code{Voice.sparseTies} to true. In this case, a single tie is used
321 for every tied chord.
322 @lilypond[fragment,verbatim,center]
323   \property Voice.sparseTies = ##t
324   <c' e' g'> ~ <c' e' g'>
325 @end lilypond
326
327 In its meaning a tie is just a way of extending a note duration, similar
328 to the augmentation dot: the following example are two ways of notating
329 exactly the same concept.
330 @c
331 @lilypond[fragment, singleline]
332 \time 3/4 c'2. c'2 ~ c'4
333 @end lilypond
334 Ties should not be confused with slurs, which indicate articulation,
335 and phrasing slurs, which indicate musical phrasing.
336
337 See also  @seeinternals{Tie}.
338
339
340 @refbugs
341
342 At present, the tie is represented as a separate event, temporally
343 located in between the notes.  Tieing only a subset of the note heads
344 of a chord is not supported in a simple way.  It can be achieved by
345 moving the tie-engraver into the Thread context and turning on and off
346 ties per Thread.
347
348 @node Automatic note splitting 
349 @subsection Automatic note splitting
350 @c FIXME: This subsection doesn't belong in @ref{Note entry}.
351
352 There is a facility for automatically converting long notes to  tied
353 notes. This is done by replacing the @code{Note_heads_engraver} by the
354 @code{Completion_heads_engraver}. 
355
356 @lilypond[verbatim,center]
357 \score{
358   \notes\relative c'{ \time 2/4
359   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 
360   }
361   \paper{ \translator{
362       \ThreadContext
363       \remove "Note_heads_engraver"
364       \consists "Completion_heads_engraver"
365   } } }
366 @end lilypond
367
368 This engraver splits all running notes at the bar line, and inserts
369 ties. One of its uses is to debug complex scores: if the measures are
370 not entirely filled, then the ties exactly show how much each measure
371 is off.
372
373 @refbugs
374
375 Not all durations (especially those containing tuplets) can be
376 represented exactly; the engraver will not insert tuplets. 
377
378 @node Tuplets
379 @subsection Tuplets
380
381 @cindex tuplets
382 @cindex triplets
383 @cindex @code{\times}
384
385 Tuplets are made out of a music expression by multiplying all duration
386 with a fraction.
387
388 @cindex @code{\times}
389 @example
390   \times @var{fraction} @var{musicexpr}
391 @end example
392
393 The duration of @var{musicexpr} will be multiplied by the fraction. 
394 In print, the fraction's denominator will be printed over the notes,
395 optionally with a bracket.  The most common tuplet is the triplet in
396 which 3 notes have the length of 2, so the notes are 2/3 of
397 their written length:
398
399 @lilypond[fragment,verbatim,center]
400   g'4 \times 2/3 {c'4 c' c'} d'4 d'4
401 @end lilypond
402
403 The property @code{tupletSpannerDuration} specifies how long each bracket
404 should last.  With this, you can make lots of tuplets while typing
405 @code{\times} only once, thus  saving typing work.
406
407 @lilypond[fragment,  relative, singleline, verbatim]
408 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
409 \times 2/3 { c'8 c c c c c }
410 @end lilypond
411
412 The format of the number is determined by the property
413 @code{tupletNumberFormatFunction}. The default prints only the
414 denominator, but if you set it to the Scheme function
415 @code{fraction-tuplet-formatter}, Lilypond will print @var{num}:@var{den}
416 instead.
417
418
419 @cindex @code{tupletNumberFormatFunction}
420 @cindex tuplet formatting 
421
422 See also @seeinternals{TupletBracket}.
423
424 @refbugs
425
426 Nested tuplets are not formatted automatically. In this case, outer
427 tuplet brackets should be moved automatically.
428
429 @node Easy Notation note heads 
430 @subsection Easy Notation note heads
431
432 @cindex easy notation
433 @cindex Hal Leonard
434
435 A entirely different type of note head is the "easyplay" note head: a
436 note head that includes a note name.  It is used in some publications by
437 Hal-Leonard Inc.  music publishers.
438
439 @lilypond[singleline,verbatim,26pt]
440 \score {
441   \notes { c'2 e'4 f' | g'1 }
442   \paper { \translator { \EasyNotation } } 
443 }
444 @end lilypond
445
446 Note that @code{EasyNotation} overrides a @internalsref{Score} context.  You
447 probably will want to print it with magnification or a large font size to make it more
448 readable.
449
450
451 @cindex Xdvi
452 @cindex ghostscript
453
454 If you view the result with Xdvi, then staff lines will show through
455 the letters.  Printing the postscript file obtained with ly2dvi does
456 produce the correct result.
457
458
459 @node Easier music entry
460 @section Easier music entry
461 @cindex Music entry
462 @menu
463 * Relative octaves::            
464 * Bar check::                   
465 * Point and click::             
466 * Skipping corrected music::    
467 @end menu
468
469 When entering music with LilyPond, it is easy to introduce errors. This
470 section deals with tricks and features that help you enter music, and
471 find and correct mistakes.
472
473 @c .  {Relative}
474 @node Relative octaves
475 @subsection Relative octaves
476 @cindex Relative
477 @cindex relative octave specification
478
479 Octaves are specified by adding @code{'} and @code{,} to pitch names.
480 When you copy existing music, it is easy to accidentally put a pitch in
481 the wrong octave and hard to find such an error.  To prevent these
482 errors, LilyPond features octave entry.
483
484 @cindex @code{\relative}
485 @example
486   \relative @var{startpitch} @var{musicexpr}
487 @end example
488
489 The octave of notes that appear in @var{musicexpr} are calculated as
490 follows: If no octave changing marks are used, the basic interval
491 between this and the last note is always taken to be a fourth or less
492 (This distance is determined without regarding alterations; a
493 @code{fisis} following a @code{ceses} will be put above the
494 @code{ceses})
495
496 The octave changing marks @code{'} and @code{,} can be added to raise or
497 lower the pitch by an extra octave.  Upon entering relative mode, an
498 absolute starting pitch must be specified that will act as the
499 predecessor of the first note of @var{musicexpr}.
500
501 Entering music that changes octave frequently  is easy in relative mode.
502 @lilypond[fragment,singleline,verbatim,center]
503   \relative c'' {
504     b c d c b c bes a 
505   }
506 @end lilypond
507
508 And octave changing marks are used for intervals greater than a fourth.
509 @lilypond[fragment,verbatim,center]
510   \relative c'' {
511     c g c f, c' a, e'' }
512 @end lilypond
513
514 If the preceding item is a chord, the first note of the chord is used
515 to determine the first note of the next chord. However, other notes
516 within the second chord are determined by looking at the immediately
517 preceding note.
518
519 @lilypond[fragment,verbatim,center]
520   \relative c' {
521     c <c e g> 
522     <c' e g>
523     <c, e' g>
524   }
525 @end lilypond 
526 @cindex @code{\notes}
527
528 The pitch after the @code{\relative} contains a note name.  To parse
529 the pitch as a note name, you have to be in note mode, so there must
530 be a surrounding @code{\notes} keyword (which is not
531 shown here).
532
533 The relative conversion will not affect @code{\transpose},
534 @code{\chords} or @code{\relative} sections in its argument.  If you
535 want to use relative within transposed music, you must place an
536 additional @code{\relative} inside the @code{\transpose}.
537
538
539 @c .  {Bar check}
540 @node Bar check
541 @subsection Bar check
542 @cindex Bar check
543
544 @cindex bar check
545 @cindex @code{barCheckSynchronize}
546 @cindex @code{|}
547
548
549 Whenever a bar check is encountered during interpretation, a warning
550 message is issued if it doesn't fall at a measure boundary.  This can
551 help you find errors in the input.  Depending on the value of
552 @code{barCheckSynchronize}, the beginning of the measure will be
553 relocated, so this can also be used to shorten measures.
554
555 A bar check is entered using the bar symbol, @code{|}:
556 @example
557   \time 3/4 c2 e4 | g2.
558 @end example
559
560
561
562 @cindex skipTypesetting
563
564 Failed bar checks are most often caused by entering incorrect
565 durations. Incorrect durations often completely garble up the score,
566 especially if it is polyphonic, so you should start correcting the score
567 by scanning for failed bar checks and incorrect durations.  To speed up
568 this process, you can use @code{skipTypesetting} (See @ref{Skipping
569 corrected music})). 
570
571 @c .  {Point and click}
572 @node Point and click
573 @subsection Point and click
574 @cindex poind and click
575
576 Point and click lets you find notes in the input by clicking on them in
577 the Xdvi window. This makes it very easy to find input that causes some
578 error in the sheet music.
579
580 To use it, you need the following software
581
582 @itemize @bullet
583 @item A dvi viewer that supports src specials.
584 @itemize @bullet
585 @item Plain Xdvi, version 22.36 or newer.  Available from
586 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
587
588   Note that most @TeX{} distributions ship with xdvik, which is a
589   different and less well maintained program. To find out which xdvi you
590   are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
591 @item KDVI.  A dvi viewer for KDE.  You need KDVI from KDE 3.0 or newer.
592 @end itemize
593 @item An editor with a client/server interface (or a lightweight GUI editor).
594 @itemize @bullet
595 @item Emacs. Emacs is an extensible text-editor.  It is available from
596 @uref{http://www.gnu.org/software/emacs/}.  You need version 21 to use
597 column location.
598 @item GVim.  GVim is a lightweight GUI variant of VIM, the popular VI
599 clone.  It is available from @uref{http://www.vim.org}.
600 @item NEdit.  NEdit is a somewhat Windows like editor, that has recently
601 become Free Software.  It is available from @uref{http://www.nedit.org}.
602 @end itemize
603 @end itemize
604
605 Xdvi must be configured to find the @TeX{} fonts and music
606 fonts. Refer to the Xdvi documentation for more information.
607
608 To use point-and-click, add one of these lines to the top of your .ly
609 file.
610 @example
611 #(set! point-and-click line-location)
612 @end example
613 @cindex line-location
614
615 When viewing, Control-Mousebutton 1 will take you to the originating
616 spot in the @file{.ly} file.  Control-Mousebutton 2 will show all
617 clickable boxes.
618
619 If you correct large files with point-and-click, be sure to start
620 correcting at the end of the file. When you start at the top, and
621 insert one line, all following locations will be off by a line.
622
623 @subsubsection Emacs
624 @cindex Emacs
625 In your emacs startup file (usually @file{~/.emacs}), add the following
626 @example
627 (server-start)
628 @end example
629
630 Make sure that the environment variable @var{XEDITOR} is set to
631 @example
632 emacsclient --no-wait +%l %f
633 @end example
634 use this argument with xdvi's @code{-editor} option.
635 @cindex @var{XEDITOR}
636
637 If you use Emacs version 21, you can make emacs jump to the exact spot
638 (and not just the line) on a click.  To use this feature, you must
639 enable column positioning.  At the top of the @code{ly} file, replace
640 the @code{set!} line with the following line
641 @example
642 #(set! point-and-click line-column-location)
643 @end example
644 @cindex line-colomn-location
645 Set @var{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}, or
646 use this argument with xdvi's @file{-editor} option.
647
648 @subsubsection GVim
649 @cindex GVIM
650 Set @var{XEDITOR} to @code{gvim +%l %f}, or
651 use this argument with xdvi's @code{-editor} option.
652
653 @subsubsection NEdit
654 @cindex NEdit
655 Set @var{XEDITOR} to @code{nc -noask +%l %f}, or
656 use this argument with xdvi's @code{-editor} option.
657
658
659 @refbugs
660
661 When you convert the @TeX{} file to PostScript using @code{dvips}, it
662 will complain about not finding @code{src:X:Y} files. These complaints
663 are harmless, and can be ignored.
664
665 @node Skipping corrected music
666 @subsection Skipping corrected music
667
668 The property @code{Score.skipTypesetting} can be used to switch on and
669 off typesetting completely during the interpretation phase. When
670 typesetting is switched off, the music is processed much more quickly.
671 You can use this to skip over the parts of a score that you have already
672 checked for errors. 
673
674 @lilypond[fragment,singleline,verbatim]
675 \relative c'' { c8 d
676 \property Score.skipTypesetting = ##t
677   e f g a g c, f e d
678 \property Score.skipTypesetting = ##f
679 c d b bes a g c2 } 
680 @end lilypond
681
682
683
684
685 @node Staff notation
686 @section Staff notation
687
688 This section deals with music notation that occurs on staff level,
689 such as keys, clefs and time signatures.
690
691 @cindex Staff notation
692
693 @menu
694 * Key signature::               
695 * Clef::                        
696 * Time signature::              
697 * Unmetered music::             
698 * Bar lines::                   
699 @end menu
700
701 @c .  {Key}
702 @node Key signature
703 @subsection Key signature
704 @cindex Key
705
706 @cindex @code{\key}
707
708 Setting or changing the key signature is done with the @code{\key}
709 command.
710 @example
711   @code{\key} @var{pitch} @var{type}
712 @end example
713
714 @cindex @code{\minor}
715 @cindex @code{\major}
716 @cindex @code{\minor}
717 @cindex @code{\ionian}
718 @cindex @code{\locrian}
719 @cindex @code{\aeolian}
720 @cindex @code{\mixolydian}
721 @cindex @code{\lydian}
722 @cindex @code{\phrygian}
723 @cindex @code{\dorian}
724
725 Here, @var{type} should be @code{\major} or @code{\minor} to get
726 @var{pitch}-major or @var{pitch}-minor, respectively.
727 The standard mode names @code{\ionian},
728 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
729 @code{\phrygian}, and @code{\dorian} are also defined.
730
731 This command sets the context property @code{Staff.keySignature}. 
732 Non-standard key signatures can be specified by setting this property
733 directly.
734
735 The printed signature is a @internalsref{KeySignature} grob, typically
736 created in @internalsref{Staff} context.
737
738 @cindex @code{keySignature}
739
740 @c .  {Clef}
741 @node Clef
742 @subsection Clef
743 @cindex @code{\clef}
744
745 The clef can be set or changed with the @code{\clef} command:
746 @lilypond[fragment,verbatim]
747   \key f\major  c''2 \clef alto g'2
748 @end lilypond
749
750 Supported clef-names include 
751 @c Moved standard clefs to the top /MB
752 @table @code
753 @item treble, violin, G, G2
754 G clef on 2nd line
755 @item alto, C
756  C clef on 3rd line
757 @item tenor
758  C clef on 4th line
759 @item bass, F
760  F clef on 4th line
761 @item french
762  G clef on 1st line, so-called French violin clef
763 @item soprano
764  C clef on 1st line
765 @item mezzosoprano
766  C clef on 2nd line
767 @item baritone
768  C clef on 5th line
769 @item varbaritone
770  F clef on 3rd line
771 @item subbass
772  F clef on 5th line
773 @item percussion
774  percussion clef
775 @end table
776
777 By adding @code{_8} or @code{^8} to the clef name, the clef is
778 transposed one octave down or up, respectively.  Note that you have to
779 enclose @var{clefname} in quotes if you use underscores or digits in the
780 name. For example,
781 @example
782         \clef "G_8"
783 @end example
784
785 The grob for this symbol is @internalsref{Clef}. 
786
787
788 This command is equivalent to setting @code{clefGlyph},
789 @code{clefPosition} (which controls the Y position of the clef),
790 @code{centralCPosition} and @code{clefOctavation}. A clef is created
791 when any of these properties are changed.
792
793
794 @c .  {Time signature}
795 @node Time signature
796 @subsection Time signature
797 @cindex Time signature
798 @cindex meter
799 @cindex @code{\time}
800
801 The time signature is set or changed by the @code{\time}
802 command.
803 @lilypond[fragment,verbatim]
804  \time 2/4 c'2 \time 3/4 c'2. 
805 @end lilypond
806
807 The actual symbol that's printed can be customized with the @code{style}
808 property. Setting it to @code{#'()} uses fraction style for 4/4 and
809 2/2 time.
810
811
812 The grob for this symbol is @internalsref{TimeSignature}.  There are
813 many more options for its layout. They are selected through the
814 @code{style} grob property. See @file{input/test/time.ly} for more
815 examples.
816
817 This command sets the property @code{timeSignatureFraction},
818 @code{beatLength} and @code{measureLength}.  The property
819 @code{timeSignatureFraction} determine where bar lines should be
820 inserted, and how automatic beams should be generated.  Changing the
821 value of @code{timeSignatureFraction} also causes a time signature
822 symbol to be printed.
823
824 @c .   {Partial}
825 @subsection Partial
826 @cindex Partial
827 @cindex anacrusis
828 @cindex upbeat
829 @cindex partial measure
830 @cindex measure, partial
831 @cindex shorten measures
832 @cindex @code{\partial}
833
834 Partial measures, for example in upbeats, are entered using the
835 @code{\partial} command:
836 @lilypond[fragment,verbatim]
837 \partial 4* 5/16  c'16 c4 f16 a'2. ~ a'8. a'16 | g'1
838 @end lilypond
839
840 The syntax for this command is 
841 @example
842   \partial @var{duration} 
843 @end example
844 This is  internally translated into
845 @example
846   \property Score.measurePosition = -@var{length of duration}
847 @end example
848 @cindex @code{|}
849 The property @code{measurePosition} contains a rational number
850 indicating how much of the measure has passed at this point.
851
852
853 @node Unmetered music
854 @subsection Unmetered music
855
856 Bar lines and bar numbers are calculated automatically. For unmetered
857 music (e.g. cadenzas), this is not desirable.  The commands
858 @code{\cadenzaOn} and @code{\cadenzaOff} can be used to switch off the
859 timing information:
860
861 @lilypond[fragment,relative,singleline,verbatim]
862 c'2.
863 \cadenzaOn
864 c2
865 \cadenzaOff
866 c4 c4 c4 
867 @end lilypond
868
869 The property @code{Score.timing} can be used to switch off this
870 automatic timing
871
872 @c .   {Bar lines}
873 @node Bar lines
874 @subsection Bar lines
875 @cindex Bar lines
876
877 @cindex @code{\bar}
878 @cindex measure lines
879 @cindex repeat bars
880
881 Bar lines are inserted automatically, but if you need a special type
882 of barline, you can force one using the @code{\bar} command:
883 @lilypond[fragment,verbatim] c4 \bar "|:" c4
884 @end lilypond
885
886 The following bar types are available
887 @lilypond[fragment,  relative, singleline, verbatim]
888 c4
889 \bar "|" c
890 \bar "" c
891 \bar "|:" c
892 \bar "||" c
893 \bar ":|" c
894 \bar ".|" c
895 \bar ".|." c
896 \bar "|." 
897 @end lilypond
898
899 You are encouraged to use @code{\repeat} for repetitions.  See
900 @ref{Repeats}.
901
902 In scores with many staffs, the barlines are automatically placed at
903 top level, and they are connected between different staffs of a
904 @internalsref{StaffGroup}:
905 @lilypond[fragment, verbatim]
906 < \context StaffGroup <
907   \context Staff = up { e'4 d'
908      \bar "||"
909      f' e' }
910   \context Staff = down { \clef bass c4 g e g } >
911 \context Staff = pedal { \clef bass c2 c2 } >
912 @end lilypond
913
914 The grobs that are created at @internalsref{Staff} level. The name is
915 @internalsref{BarLine}.
916
917 The command @code{\bar @var{bartype}} is a short cut for
918 doing  @code{\property Score.whichBar = @var{bartype}}
919 Whenever @code{whichBar} is set to a string, a bar line of that type is
920 created.  @code{whichBar} is usually set automatically: at the start of
921 a measure it is set to @code{defaultBarType}. The contents of
922 @code{repeatCommands} is used to override default measure bars.
923
924 @code{whichBar} can also be set directly, using @code{\property} or
925 @code{\bar  }.  These settings take precedence over the automatic
926 @code{whichBar} settings. 
927
928
929 @cindex Bar_line_engraver
930 @cindex whichBar
931 @cindex repeatCommands
932 @cindex defaultBarType
933
934
935
936 @c .   {Polyphony}
937 @node Polyphony
938 @section Polyphony
939 @cindex polyphony
940
941 The easiest way to enter such fragments with more than one voice on a
942 staff is to split chords using the separator @code{\\}.  You can use
943 it for small, short-lived voices (make a chord of voices) or for
944 single chords:
945
946 @lilypond[verbatim,fragment]
947 \context Voice = VA \relative c'' {
948  c4 < { f d e  } \\ { b c2 } > c4 < g' \\ b, \\  f \\ d >
949 }
950 @end lilypond
951
952 The separator causes @internalsref{Voice} contexts to be instantiated,
953 bearing the names @code{"1"}, @code{"2"}, etc.
954
955 Sometimes, it is necessary to instantiate these contexts by hand: For
956 Instantiate a separate Voice context for each part, and use
957 @code{\voiceOne}, up to @code{\voiceFour} to assign a stem directions
958 and horizontal shift for each part.
959 @c
960
961 @lilypond[singleline, verbatim]
962 \relative c''
963 \context Staff < \context Voice = VA { \voiceOne cis2 b  }
964   \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 } 
965   \context Voice = VC { \voiceTwo fis4~  fis4 f ~ f  } >
966 @end lilypond
967
968 The identifiers @code{\voiceOne} to @code{\voiceFour} set directions
969 ties, slurs and stems, and set shift directions.
970
971 If you want more than four voices, you can also manually set
972 horizontal shifts and stem directions, as is shown  in the following example:
973 @lilypond[fragment, verbatim]
974   \context Staff \notes\relative c''<
975        \context Voice=one {
976        \shiftOff \stemUp e4
977        }
978        \context Voice=two {
979           \shiftOn \stemUp cis
980        }
981        \context Voice=three {
982          \shiftOnn \stemUp ais
983        }
984        \context Voice=four {
985           \shiftOnnn \stemUp fis
986        }
987   >
988 @end lilypond
989
990
991 Normally, note heads with a different number of dots are not merged, but
992 if you set the grob property @code{merge-differently-dotted}, they are:
993 @lilypond[verbatim,fragment,singleline]
994 \context Voice < {
995      g'8 g'8 
996      \property Staff.NoteCollision \override
997         #'merge-differently-dotted = ##t
998      g'8 g'8
999   } \\ { [g'8. f16] [g'8. f'16] } 
1000   >
1001 @end lilypond
1002
1003 Similarly, you can merge half note heads with eighth notes, by setting
1004 @code{merge-differently-headed}:
1005 @lilypond[fragment, relative=2,verbatim]
1006 \context Voice < {
1007     c8 c4.
1008     \property Staff.NoteCollision
1009       \override #'merge-differently-headed = ##t
1010     c8 c4. } \\ { c2 c2 } >
1011 @end lilypond
1012
1013 LilyPond also vertically shifts rests that are opposite of a stem. 
1014
1015 @lilypond[singleline,fragment,verbatim]
1016 \context Voice < c''4 \\  r4 >
1017 @end lilypond
1018
1019 See also @internalsref{NoteCollision} and @internalsref{RestCollision}
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} grob 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're 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 the patterns for automatic beamer.
1041
1042 See also @internalsref{Beam}.
1043
1044 @c .    {Manual beams}
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 LilyPond's automatic
1052 beaming algorithm.  For example, the auto beamer will not beam over
1053 rests or bar lines, If you want that, specify the begin and end point
1054 manually using a @code{[} before the first beamed note and a @code{]}
1055 after the last note:
1056
1057 @lilypond[fragment,relative,verbatim]
1058   \context Staff {
1059     r4 [r8 g' a r8] r8 [g | a] r8
1060   }
1061 @end lilypond
1062
1063 @cindex @code{stemLeftBeamCount}
1064
1065 Normally, beaming patterns within a beam are determined automatically.
1066 When this mechanism fouls up, the properties
1067 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount} can
1068 be used to control the beam subdivision on a stem.  If you set either
1069 property, its value will be used only once, and then it is erased.
1070
1071 @lilypond[fragment,relative,verbatim]
1072   \context Staff {
1073     [f8 r16 f g a]
1074     [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
1075   }
1076 @end lilypond
1077 @cindex @code{stemRightBeamCount}
1078
1079
1080 The property @code{subdivideBeams} can be set in order to subdivide
1081 all 16th or shorter beams at beat positions.  This accomplishes the
1082 same effect as twiddling with @code{stemLeftBeamCount} and
1083 @code{stemRightBeamCount}, but it take less typing.
1084
1085
1086 @example
1087 [c16 c c c c c c c]
1088 \property Voice.subdivideBeams = ##t
1089 [c16 c c c c c c c]
1090 [c32 c c c c c c c c c c c c c c c]
1091 \property Score.beatLength = #(make-moment 1 8)
1092 [c32 c c c c c c c c c c c c c c c]
1093 @end example
1094 @lilypond[]
1095 \score {
1096     \notes \relative c' {
1097         [c16 c c c c c c c]
1098         \property Voice.subdivideBeams = ##t
1099         [c16 c c c c c c c]
1100         [c32 c c c c c c c c c c c c c c c]
1101         \property Score.beatLength = #(make-moment 1 8)
1102         [c32 c c c c c c c c c c c c c c c]
1103     }
1104 }
1105 @end lilypond
1106 @cindex subdivideBeams
1107
1108 Kneed beams are inserted automatically, when a large gap between two
1109 adjacent beamed notes is detected. This behavior can be tuned through
1110 the grob property @code{auto-knee-gap}.
1111
1112 @cindex beams, kneed
1113 @cindex kneed beams
1114 @cindex auto-knee-gap
1115 @cindex hara kiri
1116
1117
1118 @c TODO -> why this ref? Document? 
1119 @cindex @code{neutral-direction}
1120
1121 @refbugs
1122
1123 Auto knee beams can not be used together with hara kiri staffs.
1124
1125 @menu
1126 * Setting automatic beam behavior ::  
1127 @end menu
1128
1129 @ignore
1130 @no de Beam typography
1131 @sub section Beam typography
1132
1133 One of the strong points of LilyPond is how beams are formatted. Beams
1134 are quantized, meaning that the left and right endpoints beams start
1135 exactly on staff lines. Without quantization, small wedges of white
1136 space appear between the beam and staff line, and this looks untidy.
1137
1138 Beams are also slope-damped: melodies that go up or down should also
1139 have beams that go up or down, but the slope of the beams should be
1140 less than the slope of the notes themselves.
1141
1142 Some beams should be horizontal. These are so-called concave beams. 
1143
1144 [TODO: some pictures.]
1145 @end ignore
1146
1147 @c .    {Automatic beams}
1148 @node Setting automatic beam behavior 
1149 @subsection Setting automatic beam behavior 
1150
1151 @cindex @code{autoBeamSettings}
1152 @cindex @code{(end * * * *)}
1153 @cindex @code{(begin * * * *)}
1154 @cindex automatic beams, tuning
1155 @cindex tuning automatic beaming
1156
1157 In normal time signatures, automatic beams can start on any note but can
1158 only end in a few positions within the measure: beams can end on a beat,
1159 or at durations specified by the properties in
1160 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
1161 are defined in @file{scm/auto-beam.scm}.
1162
1163 The value of @code{autoBeamSettings} is changed using
1164 @code{\override} and unset using @code{\revert}:
1165 @example
1166 \property Voice.autoBeamSettings \override #'(@var{BE} @var{P} @var{Q} @var{N} @var{M}) = @var{dur}
1167 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{P} @var{Q} @var{N} @var{M})
1168 @end example
1169 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
1170 whether the rule applies to begin or end-points.  The quantity
1171 @var{P}/@var{Q} refers to the length of the beamed notes (and `@code{*
1172 *}' designates notes of any length), @var{N}/@var{M} refers to a time
1173 signature (wildcards, `@code{* *}' may be entered to designate all time
1174 signatures).
1175
1176 For example, if you want automatic beams to end on every quarter note,
1177 you can use the following:
1178 @example
1179 \property Voice.autoBeamSettings \override
1180     #'(end * * * *) = #(make-moment 1 4)
1181 @end example
1182 Since the duration of a quarter note is 1/4 of a whole note, it is
1183 entered as @code{(make-moment 1 4)}.
1184
1185 The same syntax can be used to specify beam starting points. In this
1186 example, automatic beams can only end on a dotted quarter note. 
1187 @example
1188 \property Voice.autoBeamSettings \override
1189     #'(end * * * *) = #(make-moment 3 8)
1190 @end example
1191 In 4/4 time signature, this means that automatic beams could end only on
1192 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1193 3/8 has passed within the measure).
1194
1195 You can also restrict rules to specific time signatures. A rule that
1196 should only be applied in @var{N}/@var{M} time signature is formed by
1197 replacing the second asterisks by @var{N} and @var{M}. For example, a
1198 rule for 6/8 time exclusively looks like
1199 @example
1200 \property Voice.autoBeamSettings \override
1201     #'(begin * * 6 8) =  ... 
1202 @end example
1203
1204 If you want a rule to apply to certain types of beams, you can use the
1205 first pair of asterisks. Beams are classified according to the shortest
1206 note they contain. For a beam ending rule that only applies to beams
1207 with 32nd notes (and no shorter notes), you would use @code{(end 1
1208 32 * *)}.
1209
1210 @c not true
1211 @c Automatic beams can not be put on the last note in a score.
1212
1213 If a score ends while an automatic beam has not been ended and is still
1214 accepting notes, this last beam will not be typeset at all.
1215
1216 @cindex automatic beam generation
1217 @cindex autobeam
1218 @cindex @code{Voice.autoBeaming}
1219 @cindex lyrics
1220
1221 For melodies that have lyrics, you may want to switch off 
1222 automatic beaming. This is done by setting @code{Voice.autoBeaming} to
1223 @code{#f}. 
1224
1225
1226 @refbugs
1227
1228 It is not possible to specify beaming parameters for beams with mixed
1229 durations, that differ from the beaming parameters of all separate
1230 durations, i.e., you'll have to specify manual beams to get:
1231 @lilypond[fragment,singleline,relative]
1232   \property Voice.autoBeamSettings
1233   \override #'(end * * * *) = #(make-moment 3 8)
1234   \time 12/8 c'8 c c c16 c c c c c [c c c c] c8 c c4
1235 @end lilypond
1236
1237 It is not possible to specify beaming parameters that act differently in
1238 different parts of a measure. This means that it is not possible to use
1239 automatic beaming in irregular meters such as @code{5/8}.
1240
1241 @node Accidentals
1242 @section Accidentals
1243 @cindex Accidentals
1244 This section describes how to change the way that LilyPond automatically
1245 inserts accidentals before the running notes.
1246
1247 @menu
1248 * Using the predefined accidental macros::  
1249 * Defining your own accidental typesettings::  
1250 @end menu
1251
1252 @node Using the predefined accidental macros
1253 @subsection Using the predefined accidental macros
1254 The constructs for describing the accidental typesetting rules are
1255 quite hairy, so non-experts should stick to the macros defined in
1256 @file{ly/property-init.ly}.
1257 @cindex @file{property-init.ly}
1258
1259 The normal way of using the macros is to enter the macro name right after the
1260 creation of the context in which the accidental typesetting described
1261 by the macro is to take effect. I.e. if you want to use
1262 piano-accidentals in a pianostaff then you issue
1263 @code{\pianoAccidentals} first thing after the creation of the piano
1264 staff:
1265 @example
1266 \score @{
1267     \notes \relative c'' <
1268         \context Staff = sa @{ cis4 d e2 @}
1269         \context GrandStaff <
1270             \pianoAccidentals
1271             \context Staff = sb @{ cis4 d e2 @}
1272             \context Staff = sc @{ es2 c @}
1273         >
1274         \context Staff = sd @{ es2 c @}
1275     >
1276 @}
1277 @end example
1278 @lilypond[singleline]
1279 \score {
1280     \notes \relative c'' <
1281         \context Staff = sa { cis4 d e2 }
1282         \context GrandStaff <
1283             \pianoAccidentals
1284             \context Staff = sb { cis4 d e2 }
1285             \context Staff = sc { es2 c }
1286         >
1287         \context Staff = sd { es2 c }
1288     >
1289     \paper {
1290         \translator {
1291             \StaffContext
1292             minimumVerticalExtent = #'(-4.0 . 4.0)
1293         }
1294     }
1295 }
1296 @end lilypond
1297
1298 The macros are:
1299 @table @code
1300 @item \defaultAccidentals
1301       @cindex @code{\defaultAccidentals}
1302       This is the default typesetting behaviour. It should correspond
1303       to 18th century common practice: Accidentals are
1304       remembered to the end of the measure in which they occur and
1305       only on their own octave.
1306
1307 @item \voiceAccidentals
1308       @cindex @code{\voiceAccidentals}
1309       The normal behaviour is to remember the accidentals on
1310       Staff-level.
1311       This macro, however, typesets accidentals individually for each
1312       voice.
1313       Apart from that the rule is similar to
1314       @code{\defaultAccidentals}.
1315
1316       Warning: This leads to some weird and often unwanted results
1317       because accidentals from one voice DO NOT get cancelled in other
1318       voices:
1319 @lilypond[singleline,relative,fragment,verbatim]
1320     \context Staff <
1321         \voiceAccidentals
1322         \context Voice=va { \voiceOne es g }
1323         \context Voice=vb { \voiceTwo c, e }
1324     >
1325 @end lilypond
1326       Hence you should only use @code{\voiceAccidentals}
1327       if the voices are to be read solely by
1328       individual musicians. if the staff should be readable also
1329       by one musician/conductor then you should use
1330       @code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
1331       instead.
1332
1333 @item \modernAccidentals
1334       @cindex @code{\modernAccidentals}
1335       This rule should correspond to the common practice in the 20th
1336       century.
1337       The rule is a bit more complex than @code{\defaultAccidentals}:
1338       You get all the same accidentals, but temporary
1339       accidentals also get cancelled in other octaves. Further more,
1340       in the same octave, they also get cancelled in the following measure:
1341 @lilypond[singleline,fragment,verbatim]
1342       \modernAccidentals
1343       cis' c'' cis'2 | c'' c'
1344 @end lilypond
1345
1346 @item \modernCautionaries
1347       @cindex @code{\modernCautionaries}
1348      This rule is similar to @code{\modernAccidentals}, but the
1349      ``extra'' accidentals (the ones not typeset by
1350      @code{\defaultAccidentals}) are typeset as cautionary accidentals
1351      (i.e. in reduced size):
1352 @lilypond[singleline,fragment,verbatim]
1353       \modernCautionaries
1354       cis' c'' cis'2 | c'' c'
1355 @end lilypond
1356
1357 @item \modernVoiceAccidentals
1358       @cindex @code{\modernVoiceAccidentals}
1359       Multivoice accidentals to be read both by musicians playing one voice
1360       and musicians playing all voices.
1361
1362       Accidentals are typeset for each voice, but they ARE cancelled
1363       across voices in the same @internalsref{Staff}.
1364
1365 @item \modernVoiceCautionaries
1366       @cindex @code{\modernVoiceCautionaries}
1367       The same as @code{\modernVoiceAccidentals}, but with the
1368       extra accidentals (the ones not typeset by
1369       @code{\voiceAccidentals}) typeset as cautionaries.
1370       Notice that even though all accidentals typeset by
1371       @code{\defaultAccidentals} ARE typeset by this macro then some
1372       of them are typeset as cautionaries.
1373
1374 @item \pianoAccidentals
1375       @cindex @code{\pianoAccidentals}
1376       20th century practice for piano notation. Very similar to
1377       @code{\modernAccidentals} but accidentals also get cancelled
1378       across the staves in the same @internalsref{GrandStaff} or
1379       @internalsref{PianoStaff}.
1380
1381 @item \pianoCautionaries
1382       @cindex @code{\pianoCautionaries}
1383       As @code{\pianoAccidentals} but with the extra accidentals
1384       typeset as cationaries.
1385
1386 @item \noResetKey
1387       @cindex @code{\noResetKey}
1388       Same as @code{\defaultAccidentals} but with accidentals lasting
1389       ``forever'' and not only until the next measure:
1390 @lilypond[singleline,fragment,verbatim,relative]
1391       \noResetKey
1392       c1 cis cis c
1393 @end lilypond
1394
1395 @item \forgetAccidentals
1396       @cindex @code{\forgetAccidentals}
1397       This is sort of the opposite of @code{\noResetKey}: Accidentals
1398       are not remembered at all - and hence all accidentals are
1399       typeset relative to the key signature, regardless of what was
1400       before in the music:
1401 @lilypond[singleline,fragment,verbatim,relative]
1402       \forgetAccidentals
1403       \key d\major c4 c cis cis d d dis dis
1404 @end lilypond
1405 @end table
1406
1407 @node Defining your own accidental typesettings
1408 @subsection Defining your own accidental typesettings
1409
1410 This section must be considered gurus-only, and hence it must be
1411 sufficient with a short description of the system and a reference to
1412 the internal documentation.
1413
1414 The idea of the algorithm is to try several different rules and then
1415 use the rule that gives the highest number of accidentals.
1416 Each rule cosists of
1417 @table @asis
1418 @item Context:
1419       In which context is the rule applied. I.e. if context is
1420       @internalsref{Score} then all staves share accidentals, and if
1421       context is @internalsref{Staff} then all voices in the same
1422       staff share accidentals, but staves don't - like normally.
1423 @item Octavation:
1424       Whether the accidental changes all octaves or only the current
1425       octave.
1426 @item Lazyness:
1427       Over how many barlines the accidental lasts.
1428       If lazyness is @code{-1} then the accidental is forget
1429       immidiately, and if lazyness is @code{#t} then the accidental
1430       lasts forever.
1431 @end table
1432
1433 As described in the internal documentation of
1434 @reng{Accidental_engraver}, the properties @code{autoAccidentals} and
1435 @code{autoCautionaries} contain lists of rule descriptions. Notice
1436 that the contexts must be listed from in to out - that is
1437 @internalsref{Thread} before @internalsref{Voice},
1438 @internalsref{Voice} before @internalsref{Staff}, etc. 
1439 see the macros in @file{ly/property-init.ly} for examples of how the
1440 properties are set.
1441
1442 @refbugs
1443
1444 Currently the simultaneous notes are considered to be entered in
1445 sequential mode. This means that in a chord the accidentals are
1446 typeset as if the notes in the chord happened one at a time - in the
1447 order in which they appear in the input file.
1448
1449 Of course this is only a problem when you have simultainous notes
1450 which accidentals should depend on each other.
1451 Notice that the problem only occurs when using non-default accidentals
1452 - as the default accidentals only depend on other accidentals on the
1453 same staff and same pitch and hence cannot depend on other
1454 simultainous notes.
1455
1456 This example shows two examples of the same music giving different
1457 accidentals depending on the order in which the notes occur in the
1458 input file:
1459
1460 @lilypond[singleline,fragment,verbatim]
1461 \property Staff.autoAccidentals = #'( Staff (any-octave . 0) )
1462 cis'4 <c'' c'> r2 | cis'4 <c' c''> r2 | <cis' c''> r | <c'' cis'> r | 
1463 @end lilypond
1464
1465 The only solution is to manually insert the problematic
1466 accidentals using @code{!} and @code{?}.
1467
1468 @node Expressive marks
1469 @section Expressive marks
1470
1471 @c .   {Slurs}
1472 @menu
1473 * Slurs ::                      
1474 * Phrasing slurs::              
1475 * Breath marks::                
1476 * Tempo::                       
1477 * Text spanners::               
1478 @end menu
1479
1480 @node Slurs 
1481 @subsection Slurs
1482 @cindex Slurs
1483
1484 A slur indicates that notes are to be played bound or @emph{legato}.
1485 They are entered using parentheses:
1486 @lilypond[fragment,verbatim,center]
1487   f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1488 @end lilypond
1489
1490 See also @seeinternals{Slur}.
1491
1492 Slurs avoid crossing stems, and are generally attached to note heads.
1493 However, in some situations with beams, slurs may be attached to stem
1494 ends.  If you want to override this layout you can do this through the
1495 grob-property @code{attachment} of @internalsref{Slur} in
1496 @internalsref{Voice} context It's value is a pair of symbols, specifying
1497 the attachment type of the left and right end points.
1498
1499 @lilypond[fragment,relative,verbatim]
1500   \slurUp
1501   \property Voice.Stem \set #'length = #5.5
1502   g'8(g)g4
1503   \property Voice.Slur \set #'attachment = #'(stem . stem)
1504   g8(g)g4
1505 @end lilypond
1506
1507 If a slur would strike through a stem or beam, the slur will be moved
1508 away upward or downward. If this happens, attaching the slur to the
1509 stems might look better:
1510
1511 @lilypond[fragment,relative,verbatim]
1512   \stemUp \slurUp
1513   d32( d'4 )d8..
1514   \property Voice.Slur \set #'attachment = #'(stem . stem)
1515   d,32( d'4 )d8..
1516 @end lilypond
1517
1518 @ignore
1519 Similarly, the curvature of a slur is adjusted to stay clear of note
1520 heads and stems.  When that would increase the curvature too much, the
1521 slur is reverted to its default shape.  The threshold for this
1522 decision is in @internalsref{Slur}'s grob-property @code{beautiful}.
1523 It is loosely related to the enclosed area between the slur and the
1524 notes.  Usually, the default setting works well, but in some cases you
1525 may prefer a curved slur when LilyPond decides for a vertically moved
1526 one.  You can indicate this preference by increasing the
1527 @code{beautiful} value:
1528
1529 @lilyp ond[verbatim,singleline,relative]
1530   \stemDown \slurUp
1531   c16( a' f' a a f a, )c,
1532   c( a' f' a a f d, )c
1533   \property Voice.Slur \override #'beautiful = #5.0
1534   c( a' f' a a f d, )c
1535 @end lilypond
1536 @end ignore
1537
1538 @refbugs
1539
1540 Producing nice slurs is a difficult problem, and LilyPond currently
1541 uses a simple, empiric method to produce slurs. In some cases, the
1542 results of this method are ugly.
1543
1544 @ignore
1545 This is reflected by the
1546 @code{beautiful} property, which it is an arbitrary parameter in the
1547 slur formatter.  Useful values can only be determined by trial and
1548 error.
1549 @end ignore
1550
1551 @cindex Adjusting slurs
1552
1553 @node Phrasing slurs
1554 @subsection Phrasing slurs
1555
1556 @cindex phrasing slurs
1557 @cindex phrasing marks
1558
1559 A phrasing slur (or phrasing mark) connects chords and is used to
1560 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1561 respectively.
1562
1563 @lilypond[fragment,verbatim,center,relative]
1564   \time 6/4 c' \(  d () e f () e  \) d
1565 @end lilypond
1566
1567 Typographically, the phrasing slur behaves almost exactly like a normal
1568 slur. See also  @seeinternals{PhrasingSlur}.
1569
1570
1571 @node Breath marks
1572 @subsection Breath marks
1573
1574 Breath marks are entered using @code{\breathe}.  See also
1575 @seeinternals{BreathingSign}.
1576
1577 @lilypond[fragment,relative]
1578 c'4 \breathe d4
1579 @end lilypond
1580
1581
1582 @c .  {Tempo}
1583 @node Tempo
1584 @subsection Tempo
1585 @cindex Tempo
1586 @cindex beats per minute
1587 @cindex metronome marking
1588
1589 Metronome settings can be entered as follows:
1590
1591 @cindex @code{\tempo}
1592 @example
1593   \tempo @var{duration} = @var{perminute} 
1594 @end example
1595
1596 For example, @code{\tempo 4 = 76} requests output with 76 quarter notes
1597 per minute.
1598   
1599 @refbugs
1600   
1601 The tempo setting is not printed, but is only used in the MIDI
1602 output. You can trick lily into producing a metronome mark,
1603 though. Details are in @ref{Text markup}.
1604   
1605
1606
1607 @node Text spanners
1608 @subsection Text spanners
1609 @cindex Text spanners
1610
1611 Some textual indications, e.g. rallentando or accelerando, often extend
1612 over many measures. This is indicated by following the text with a
1613 dotted line.  You can create such texts using text spanners. The syntax
1614 is as follows:
1615 @example
1616 \spanrequest \start "text"
1617 \spanrequest \stop "text"
1618 @end example
1619 LilyPond will respond by creating a @internalsref{TextSpanner} grob (typically
1620 in @internalsref{Voice} context).  The string to be printed, as well as the
1621 style is set through grob properties.
1622
1623 An application---or rather, a hack---is to fake octavation indications.
1624 @lilypond[fragment,relative,verbatim]
1625  \relative c' {  a''' b c a
1626   \property Voice.TextSpanner \set #'type = #'dotted-line
1627   \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1628   \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1629   \property Staff.centralCPosition = #-13
1630   a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1631 @end lilypond
1632
1633
1634 @c .  {Ornaments}
1635 @node Ornaments
1636 @section Ornaments
1637 @cindex Ornaments
1638 @menu
1639 * Articulations::               
1640 * Text scripts::                
1641 * Grace notes::                 
1642 * Glissando ::                  
1643 * Dynamics::                    
1644 @end menu
1645
1646 @c .   {Articulation}
1647 @node Articulations
1648 @subsection Articulations
1649 @cindex Articulations
1650
1651 @cindex articulations
1652 @cindex scripts
1653 @cindex ornaments
1654
1655 A variety of symbols can appear above and below notes to indicate
1656 different characteristics of the performance. They are added to a note
1657 by adding a dash and the the character signifying the
1658 articulation. They are demonstrated here.
1659 @lilypond[singleline]
1660   \score {
1661     \notes \context Voice {
1662       \property Voice.TextScript \set #'font-family = #'typewriter
1663       \property Voice.TextScript \set #'font-shape = #'upright
1664       c''4-._"c-."      s4
1665       c''4--_"c-{}-"    s4
1666       c''4-+_"c-+"      s4
1667       c''4-|_"c-|"      s4
1668       c''4->_"c->"      s4
1669       c''4-^_"c-\\^{ }" s4
1670     }
1671   }
1672 @end lilypond
1673
1674 The script is automatically placed, but if you need to force
1675 directions, you can use @code{_} to force them down, or @code{^} to
1676 put them up:
1677 @lilypond[fragment, verbatim]
1678   c''4^^ c''4_^
1679 @end lilypond
1680
1681
1682 Other symbols can be added using the syntax
1683 @var{note}@code{-\}@var{name}. Again, they can be forced up or down
1684 using @code{^} and @code{_}.
1685
1686 @cindex accent      
1687 @cindex marcato      
1688 @cindex staccatissimo
1689 @cindex fermata 
1690 @cindex stopped     
1691 @cindex staccato     
1692 @cindex tenuto        
1693 @cindex upbow
1694 @cindex downbow
1695 @cindex foot marks
1696 @cindex organ pedal marks
1697 @cindex turn         
1698 @cindex open          
1699 @cindex flageolet
1700 @cindex reverseturn 
1701 @cindex trill        
1702 @cindex prall         
1703 @cindex mordent
1704 @cindex prallprall  
1705 @cindex prallmordent 
1706 @cindex prall, up
1707 @cindex prall, down
1708 @cindex mordent
1709 @cindex thumb marking
1710 @cindex segno         
1711 @cindex coda
1712
1713 @lilypond[]
1714   \score {
1715     <
1716       \property Score.LyricText \override #'font-family =#'typewriter
1717       \property Score.LyricText \override #'font-shape = #'upright
1718       \context Staff \notes {
1719         c''-\accent      c''-\marcato      c''-\staccatissimo c''^\fermata 
1720         c''-\stopped     c''-\staccato     c''-\tenuto        c''-\upbow
1721         c''-\downbow     c''^\lheel        c''-\rheel         c''^\ltoe
1722         c''-\rtoe        c''-\turn         c''-\open          c''-\flageolet
1723         c''-\reverseturn c''-\trill        c''-\prall         c''-\mordent
1724         c''-\prallprall  c''-\prallmordent c''-\upprall       c''-\downprall
1725         c''-\upmordent   c''-\downmordent  c''-\pralldown     c''-\prallup
1726         c''-\lineprall   c''-\thumb        c''-\segno         c''-\coda
1727       }
1728       \context Lyrics \lyrics {
1729         accent__      marcato__      staccatissimo__ fermata
1730         stopped__     staccato__     tenuto__        upbow
1731         downbow__     lheel__        rheel__         ltoe
1732         rtoe__        turn__         open__          flageolet
1733         reverseturn__ trill__        prall__         mordent
1734         prallprall__  prallmordent__ uprall__        downprall
1735         upmordent__   downmordent__  pralldown__  prallup__
1736         lineprall__   thumb__       segno__        coda
1737       }
1738     >
1739     \paper {
1740       linewidth = 5.875\in
1741       indent    = 0.0
1742     }
1743   }
1744 @end lilypond
1745
1746
1747 @cindex fingering
1748
1749 Fingering instructions can also be entered in this shorthand. For
1750 finger changes, use markup texts:
1751 @c
1752 @lilypond[verbatim, singleline, fragment]
1753       c'4-1 c'4-2 c'4-3 c'4-4
1754       c^#'(finger "2-3")
1755 @end lilypond
1756
1757
1758 @cindex @code{\script}
1759 @cindex scripts
1760 @cindex superscript
1761 @cindex subscript
1762
1763 See also @seeinternals{Script} and @seeinternals{Fingering}.
1764
1765 @refbugs
1766
1767 All of these note ornaments appear in the printed output but have no
1768 effect on the MIDI rendering of the music.
1769
1770 Unfortunately, there is no support for adding fingering instructions or 
1771 ornaments to individual note heads. Some hacks exist, though. See
1772 @file{input/test/script-horizontal.ly}.
1773
1774
1775 @c .  {Text scripts}
1776 @node Text scripts
1777 @subsection Text scripts
1778 @cindex Text scripts
1779
1780 In addition, it is possible to place arbitrary strings of text or markup
1781 text (see @ref{Text markup}) above or below notes by using a string:
1782 @code{c^"text"}. 
1783
1784 By default, these indications do not influence the note spacing, but
1785 by using the command @code{\fatText}, the widths will be taken into
1786 account.
1787 @c
1788 @lilypond[fragment,singleline,verbatim] \relative c' {
1789 c4^"longtext" \fatText c4_"longlongtext" c4 }
1790 @end lilypond
1791
1792 It is possible to use @TeX{} commands in the strings, but this should be
1793 avoided because it makes it impossible for LilyPond to compute the
1794 exact length of the string, which may lead to collisions.  Also, @TeX{}
1795 commands won't work with direct PostScript output (see @ref{PostScript
1796 output}).
1797
1798 Text scripts are created in form of @internalsref{TextScript} grobs, in
1799 @internalsref{Voice} context. 
1800
1801 @ref{Text markup} describes how to change the font or access
1802 special symbols in text scripts.
1803
1804
1805 @c .   {Grace notes}
1806 @node Grace notes
1807 @subsection Grace notes
1808
1809
1810
1811 @cindex @code{\grace}
1812 @cindex ornaments
1813 @cindex grace notes
1814
1815 Grace notes are ornaments  are written out ornaments
1816 @lilypond[relative=2,verbatim,ifragment] 
1817   c4  \grace c16  c4 \grace { [c16 d16] } c4 
1818 @end lilypond
1819
1820 In normal notation, grace notes are supposed to take up no logical
1821 time in a measure. Such an idea is practical for normal notation, but
1822 is not strict enough to put it into a program. The model that LilyPond
1823 uses for grace notes internally is that all timing is done in two
1824 steps:
1825
1826 Every point in musical time consists of two rational numbers: one
1827 denotes the logical time, one denotes the grace timing. The above
1828 example is shown here with timing tuples.
1829
1830 @lilypond[]
1831 \score { \notes \relative c''{ 
1832   c4^"(0,0)"  \grace c16_" "_"(1/4,-1/16)"  c4^"(1/4,0)"  \grace {
1833   [c16_"(2/4,-1/8)"  d16^"(2/4,-1/16)" ] } c4_" "_"(2/4,0)"
1834   }
1835 \paper {  linewidth = 8.\cm }
1836 }
1837 @end lilypond
1838
1839 The advantage of this approach is that you can use almost any lilypond
1840 construction together with grace notes, for example slurs and clef
1841 changes may appear halfway in between grace notes:
1842
1843 @lilypond[relative=2,verbatim,fragment] 
1844   c4  \grace { [ c16 c, \clef bass c, b(] }  )c4 
1845 @end lilypond
1846
1847 The placement of these grace notes is synchronized between different
1848 staffs, using this grace timing.
1849
1850 @lilypond[relative=2,verbatim,fragment] 
1851 < \context Staff = SA { e4 \grace { c16 d e f } e4 }
1852   \context Staff = SB { c4 \grace { g8 b } c4 } >
1853 @end lilypond
1854
1855
1856 Unbeamed eighth notes and shorter by default have a slash through the
1857 stem. This can be controlled with grob property @code{flag-style} of
1858 @internalsref{Stem}. The change in formatting is accomplished by
1859 inserting @code{\startGraceMusic} before handling the grace notes, and
1860 @code{\stopGraceMusic} after finishing the grace notes. You can add to
1861 these definitions to globally change grace note formatting. The
1862 standard definitions are in @file{ly/grace-init.ly}.
1863
1864
1865 @lilypond[fragment,verbatim]
1866 \relative c'' \context Voice {
1867   \grace c8 c4 \grace { [c16 c16] } c4
1868   \grace { 
1869     \property Voice.Stem \override #'flag-style = #'() 
1870     c16 
1871     \property Voice.Stem \revert #'flag-style
1872   } c4
1873 }
1874 @end lilypond
1875
1876 @refbugs
1877
1878 Grace note synchronization can also lead to surprises. Staff notation,
1879 such as key signatures, barlines, etc. are also synchronized. Take
1880 care when you mix staffs with grace notes and staffs without.
1881
1882 @lilypond[relative=2,verbatim,fragment]
1883 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
1884   \context Staff = SB { c4 \bar "|:"  d4 } >
1885 @end lilypond
1886
1887 Grace sections should only be used within sequential music
1888 expressions.  Nesting, juxtaposing, or ending sequential music with a
1889 grace section is not supported, and might produce crashes or other
1890 errors.
1891
1892 @menu
1893 * Glissando ::                  
1894 * Dynamics::                    
1895 @end menu
1896
1897
1898
1899 @c .   {Glissando}
1900 @node Glissando 
1901 @subsection Glissando
1902 @cindex Glissando 
1903
1904 @cindex @code{\glissando}
1905
1906 A glissando line can be requested by attaching a @code{\glissando} to
1907 a note:
1908
1909 @lilypond[fragment,relative,verbatim]
1910   c'-\glissando c'
1911 @end lilypond
1912
1913 @refbugs
1914
1915 Printing of an additional text (such as @emph{gliss.}) must be done
1916 manually. See also @seeinternals{Glissando}.
1917
1918
1919
1920 @c .   {Dynamics}
1921 @node Dynamics
1922 @subsection Dynamics
1923 @cindex Dynamics
1924
1925
1926
1927 @cindex @code{\ppp}
1928 @cindex @code{\pp}
1929 @cindex @code{\p}
1930 @cindex @code{\mp}
1931 @cindex @code{\mf}
1932 @cindex @code{\f}
1933 @cindex @code{\ff}
1934 @cindex @code{\fff}
1935 @cindex @code{\ffff}
1936 @cindex @code{\fp}
1937 @cindex @code{\sf}
1938 @cindex @code{\sff}
1939 @cindex @code{\sp}
1940 @cindex @code{\spp}
1941 @cindex @code{\sfz}
1942 @cindex @code{\rfz}
1943
1944
1945 Absolute dynamic marks are specified using an identifier after a
1946 note: @code{c4-\ff}.  The available dynamic marks are: @code{\ppp},
1947 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1948 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1949 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1950
1951 @lilypond[verbatim,singleline,fragment,relative]
1952   c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1953   c2\sf c\rfz
1954 @end lilypond
1955
1956 @cindex @code{\cr}
1957 @cindex @code{\rc}
1958 @cindex @code{\decr}
1959 @cindex @code{\rced}
1960 @cindex @code{\<}
1961 @cindex @code{\>}
1962 @cindex @code{\"!}
1963
1964
1965 A crescendo mark is started with @code{\cr} and terminated with
1966 @code{\rc} (the textual reverse of @code{cr}).  A decrescendo mark is
1967 started with @code{\decr} and terminated with @code{\rced}.  There are
1968 also shorthands for these marks.  A crescendo can be started with
1969 @code{\<} and a decrescendo can be started with @code{\>}.  Either one
1970 can be terminated with @code{\!}.  Note that @code{\!}  must go before
1971 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1972 after the last note.  Because these marks are bound to notes, if you
1973 want several marks during one note, you have to use spacer notes.
1974
1975 @lilypond[fragment,verbatim,center]
1976   c'' \< \! c''   d'' \decr e'' \rced 
1977   < f''1 { s4 s4 \< \! s4 \> \! s4 } >
1978 @end lilypond
1979
1980 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1981 is an example how to do it:
1982
1983 @lilypond[fragment,relative=2,verbatim]
1984   c4 \cresc c4 \endcresc c4
1985 @end lilypond
1986
1987
1988 @cindex crescendo
1989 @cindex decrescendo
1990
1991 You can also supply your own texts:
1992 @lilypond[fragment,relative,verbatim]
1993   \context Voice {
1994     \property Voice.crescendoText = "cresc. poco"
1995     \property Voice.crescendoSpanner = #'dashed-line
1996     a'2\mf\< a a \!a 
1997   }
1998 @end lilypond
1999
2000 @cindex diminuendo
2001
2002 Dynamics are grobs of @internalsref{DynamicText} and
2003 @internalsref{Hairpin}. Vertical positioning of these symbols is
2004 handled by the @internalsref{DynamicLineSpanner} grob.  If you want to
2005 adjust padding or vertical direction of the dynamics, you must set
2006 properties for the @internalsref{DynamicLineSpanner} grob. Predefined
2007 identifiers to set the vertical direction are \dynamicUp and
2008 \dynamicDown.
2009
2010 @cindex direction, of dynamics
2011 @cindex @code{\dynamicDown}
2012 @cindex @code{\dynamicUp}
2013
2014 @c .  {Repeats}
2015 @node Repeats
2016 @section Repeats
2017
2018
2019 @cindex repeats
2020 @cindex @code{\repeat}
2021
2022 To specify repeats, use the @code{\repeat} keyword.  Since repeats
2023 should work differently when played or printed, there are a few
2024 different variants of repeats.
2025
2026 @table @code
2027 @item unfold
2028 Repeated music is fully written (played) out.  Useful for MIDI
2029 output, and entering repetitive music.
2030
2031 @item volta
2032 This is the normal notation: Repeats are not written out, but
2033 alternative endings (voltas) are printed, left to right.
2034
2035 @item fold
2036 Alternative endings are written stacked. This has limited use but may be
2037 used to typeset two lines of lyrics in songs with repeats, see
2038 @file{input/star-spangled-banner.ly}.
2039
2040 @item tremolo
2041 Make tremolo beams.
2042
2043 @item percent
2044 Make beat or measure repeats. These look like percent signs.
2045
2046 @end table  
2047
2048 @menu
2049 * Repeat syntax::               
2050 * Repeats and MIDI::            
2051 * Manual repeat commands::      
2052 * Tremolo repeats::             
2053 * Tremolo subdivisions::        
2054 * Measure repeats::             
2055 @end menu
2056
2057 @node Repeat syntax
2058 @subsection Repeat syntax
2059
2060 The syntax for repeats is
2061
2062 @example
2063   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2064 @end example
2065
2066 If you have alternative endings, you may add
2067 @cindex @code{\alternative}
2068 @example
2069  \alternative @code{@{} @var{alternative1}
2070             @var{alternative2}
2071             @var{alternative3} @dots{} @code{@}}
2072 @end example
2073 where each @var{alternative} is a music expression.
2074
2075 Normal notation repeats are used like this:
2076 @lilypond[fragment,verbatim]
2077   c'1
2078   \repeat volta 2 { c'4 d' e' f' }
2079   \repeat volta 2 { f' e' d' c' }
2080 @end lilypond
2081
2082 With alternative endings:
2083 @lilypond[fragment,verbatim]
2084   c'1
2085   \repeat volta 2 {c'4 d' e' f'} 
2086   \alternative { {d'2 d'} {f' f} }
2087 @end lilypond
2088
2089 Folded repeats look like this:
2090
2091
2092 @lilypond[fragment,verbatim]
2093   c'1
2094   \repeat fold 2 {c'4 d' e' f'} 
2095   \alternative { {d'2 d'} {f' f} }
2096
2097 @end lilypond
2098
2099 If you don't give enough alternatives for all of the repeats, then
2100 the first alternative is assumed to be repeated often enough to equal
2101 the specified number of repeats.
2102
2103 @lilypond[fragment,verbatim]
2104 \context Staff {
2105   \relative c' {
2106     \partial 4
2107     \repeat volta 4 { e | c2 d2 | e2 f2 | }
2108     \alternative { { g4 g g } { a | a a a a | b2. } }
2109   }
2110 }
2111 @end lilypond
2112
2113 @node Repeats and MIDI
2114 @subsection Repeats and MIDI
2115
2116 @cindex expanding repeats
2117
2118 For instructions on how to unfoldi repeats for MIDI output, see
2119 the example file @file{input/test/unfold-all-repeats.ly}.
2120
2121
2122 @refbugs
2123
2124 Notice that timing information is not remembered at the start of an
2125 alternative, so you have to reset timing information after a repeat,
2126 e.g. using a bar-check (See @ref{Bar check}), setting
2127 @code{Score.measurePosition} or entering @code{\partial}.  Slurs or ties
2128 are also not repeated.
2129
2130 It is possible to nest @code{\repeat}s, although this probably is only
2131 meaningful for unfolded repeats.
2132
2133 Folded repeats offer little more over simultaneous music.
2134
2135 @node Manual repeat commands
2136 @subsection Manual repeat commands
2137
2138 @cindex @code{repeatCommands}
2139
2140 The property @code{repeatCommands} can be used to control the layout of
2141 repeats. Its value is a Scheme list of repeat commands, where each repeat
2142 command can be
2143
2144 @table @code
2145 @item 'start-repeat
2146  Print a |: bar line
2147 @item 'end-repeat
2148  Print a :| bar line
2149 @item (volta . @var{text})
2150   Print a volta bracket saying @var{text}.
2151 @item (volta . #f)
2152   Stop a running volta bracket
2153 @end table
2154
2155 @lilypond[verbatim, fragment]
2156  c''4
2157     \property Score.repeatCommands = #'((volta "93") end-repeat)
2158  c''4 c''4
2159     \property Score.repeatCommands = #'((volta #f))
2160  c''4 c''4
2161 @end lilypond
2162
2163
2164 Repeats brackets are @internalsref{VoltaBracket} grobs.
2165
2166 @node Tremolo repeats
2167 @subsection Tremolo repeats
2168 @cindex tremolo beams
2169
2170 To place tremolo marks between notes, use @code{\repeat} with tremolo
2171 style.  
2172 @lilypond[verbatim,center,singleline]
2173 \score { 
2174   \context Voice \notes\relative c' {
2175     \repeat "tremolo" 8 { c16 d16 }
2176     \repeat "tremolo" 4 { c16 d16 }    
2177     \repeat "tremolo" 2 { c16 d16 }
2178     \repeat "tremolo" 4 c16
2179   }
2180 }
2181 @end lilypond
2182
2183 Tremolo beams are @internalsref{Beam} grobs. Single stem tremolos are
2184 @internalsref{StemTremolo}. The single stem tremolo @emph{must} be
2185 entered without @code{@{} and @code{@}}.  
2186
2187 @refbugs
2188
2189 Only powers of two and undotted notes are supported repeat counts.
2190
2191 @node Tremolo subdivisions
2192 @subsection Tremolo subdivisions
2193 @cindex tremolo marks
2194 @cindex @code{tremoloFlags}
2195
2196 Tremolo marks can be printed on a single note by adding
2197 `@code{:}[@var{length}]' after the note.  The length must be at least 8.
2198 A @var{length} value of 8 gives one line across the note stem.  If the
2199 length is omitted, then then the last value (stored in
2200 @code{Voice.tremoloFlags}) is used.
2201
2202 @lilypond[verbatim,fragment,center]
2203   c'2:8 c':32 | c': c': |
2204 @end lilypond
2205
2206 @refbugs
2207
2208
2209 Tremolos in this style do not carry over into the MIDI output.
2210
2211
2212 @node Measure repeats
2213 @subsection Measure repeats
2214
2215 @cindex percent repeats
2216 @cindex measure repeats
2217
2218 In the @code{percent} style, a note pattern can be repeated. It is
2219 printed once, and then the pattern is replaced with a special sign.
2220 Patterns of a one and two measures are replaced by percent-like signs,
2221 patterns that divide the measure length are replaced by slashes.
2222
2223 @lilypond[verbatim,singleline]
2224  \context Voice { \repeat  "percent" 4  { c'4 }
2225     \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2226 }
2227 @end lilypond   
2228
2229 The signs are represented by these grobs: @internalsref{RepeatSlash} and
2230 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2231
2232 @refbugs
2233
2234 You can not nest percent repeats, e.g. by filling in the first measure
2235 with slashes, and repeating that measure with percents.
2236
2237 @node Rhythmic music
2238 @section Rhythmic music
2239
2240 Sometimes you might want to show only the rhythm of a melody.  This can
2241 be done with the rhythmic staff. All pitches of notes on such a staff
2242 are squashed, and the  staff itself  looks has  a single staff line:
2243
2244 @lilypond[fragment,relative,verbatim]
2245   \context RhythmicStaff {
2246       \time 4/4
2247       c4 e8 f  g2 | r4 g r2 | g1:32 | r1 |
2248   }
2249 @end lilypond
2250
2251 @menu
2252 * Percussion staves::           
2253 @end menu
2254
2255 @node Percussion staves
2256 @subsection Percussion staves
2257 @cindex percussion
2258 @cindex drums
2259 To typeset more than one piece of percussion to be played by the same
2260 musician one typically uses a multiline staff where each staff
2261 position refers to a specific piece of percussion.
2262
2263 LilyPond is shipped with a bunch of scheme functions which allows you
2264 to do this fairly easily.
2265
2266 The system is based on the general midi drum-pitches.
2267 In order to use the drum pitches you include
2268 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2269 variable @code{drum-pitch-names} - which definition can be read in
2270 @file{scm/drums.scm}. You see that each piece of percussion has a full
2271 name and an abbreviated name - and you may freely select whether to
2272 refer to the full name or the abbreviation in your music definition.
2273
2274 To typeset the music on a staff you apply the scheme function
2275 @code{drums->paper} to the percussion music. This function takes a
2276 list of percussion instrument names, notehead scripts and staff
2277 positions (that is: pitches relative to the C-clef) and uses this to
2278 transform the input music by moving the pitch, changing the notehead
2279 and (optionally) adding a script:
2280 @lilypond[singleline,verbatim]
2281 \include "drumpitch-init.ly"
2282 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2283 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2284 \score {
2285     \apply #(drums->paper 'drums) \context Staff <
2286         \clef percussion
2287         \context Voice = up { \voiceOne \up }
2288         \context Voice = down { \voiceTwo \down }
2289     >
2290 }
2291
2292 @end lilypond
2293 In the above example the music was transformed using the list @code{'drums}.
2294 Currently the following lists are defined in @file{scm/drums.scm}:
2295 @table @code
2296 @item 'drums
2297 To typeset a typical drum kit on a five line staff.
2298 @lilypond[]
2299 \include "drumpitch-init.ly"
2300 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2301     bd sn ss tomh tommh tomml toml tomfh tomfl }
2302 mus = \notes  { cymc cyms cymr hh hhc hho hhho hhp cb hc
2303     bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2304 \score {
2305     <
2306         \apply #(drums->paper 'drums) \context Staff <
2307             \clef percussion
2308             \mus
2309         >
2310         \context Lyrics \nam 
2311     >
2312     \paper {
2313         \translator {
2314             \StaffContext
2315             \remove Bar_engraver
2316             \remove Time_signature_engraver
2317             minimumVerticalExtent = #'(-4.0 . 5.0)
2318         }
2319         \translator {
2320             \VoiceContext
2321             \remove Stem_engraver
2322         }
2323    }   
2324 }
2325 @end lilypond
2326 Notice that the scheme supports six different toms.
2327 If you are using fewer toms then you simply select the toms that produce
2328 the desired result - i.e. to get toms on the three middle lines you
2329 use @code{tommh}, @code{tomml} and @code{tomfh}.
2330
2331 Because the general midi contain no rimshots we use the sidestick for
2332 this purpose instead.
2333 @item 'timbales
2334 To typeset timbales on a two line staff.
2335 @lilypond[singleline]
2336 \include "drumpitch-init.ly"
2337 nam = \lyrics { timh ssh timl ssl cb }
2338 mus = \notes  { timh ssh timl ssl cb s16 }
2339 \score {
2340     <
2341         \apply #(drums->paper 'timbales) \context Staff <
2342             \clef percussion
2343             \mus
2344         >
2345         \context Lyrics \nam 
2346     >
2347     \paper {
2348         \translator {
2349             \StaffContext
2350             \remove Bar_engraver
2351             \remove Time_signature_engraver
2352             StaffSymbol \override #'line-count = #2
2353             StaffSymbol \override #'staff-space = #2
2354             minimumVerticalExtent = #'(-3.0 . 4.0)
2355         }
2356         \translator {
2357             \VoiceContext
2358             \remove Stem_engraver
2359         }
2360
2361     }   
2362 }
2363 @end lilypond
2364 @item 'congas
2365 To typeset congas on a two line staff.
2366 @lilypond[singleline]
2367 \include "drumpitch-init.ly"
2368 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2369 mus = \notes  { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2370 \score {
2371     <
2372         \apply #(drums->paper 'congas) \context Staff <
2373             \clef percussion
2374             \mus
2375         >
2376         \context Lyrics \nam 
2377     >
2378     \paper {
2379         \translator {
2380             \StaffContext
2381             \remove Bar_engraver
2382             \remove Time_signature_engraver
2383             StaffSymbol \override #'line-count = #2
2384             StaffSymbol \override #'staff-space = #2
2385             minimumVerticalExtent = #'(-3.0 . 4.0)
2386         }
2387         \translator {
2388             \VoiceContext
2389             \remove Stem_engraver
2390         }
2391     }   
2392 }
2393 @end lilypond
2394 @item 'bongos
2395 To typeset bongos on a two line staff.
2396 @lilypond[singleline]
2397 \include "drumpitch-init.ly"
2398 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2399 mus = \notes  { boh boho bohm ssh bol bolo bolm ssl s16 }
2400 \score {
2401     <
2402         \apply #(drums->paper 'bongos) \context Staff <
2403             \clef percussion
2404             \mus
2405         >
2406         \context Lyrics \nam 
2407     >
2408     \paper {
2409         \translator {
2410             \StaffContext
2411             \remove Bar_engraver
2412             \remove Time_signature_engraver
2413             StaffSymbol \override #'line-count = #2
2414             StaffSymbol \override #'staff-space = #2
2415             minimumVerticalExtent = #'(-3.0 . 4.0)
2416         }
2417         \translator {
2418             \VoiceContext
2419             \remove Stem_engraver
2420         }
2421     }   
2422 }
2423 @end lilypond
2424 @item 'percussion
2425 To typeset all kinds of simple percussion on one line staves.
2426 @lilypond[singleline]
2427 \include "drumpitch-init.ly"
2428 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2429 mus = \notes  { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2430 \score {
2431     <
2432         \apply #(drums->paper 'percussion) \context Staff <
2433             \clef percussion
2434             \mus
2435         >
2436         \context Lyrics \nam 
2437     >
2438     \paper {
2439         \translator {
2440             \StaffContext
2441             \remove Bar_engraver
2442             \remove Time_signature_engraver
2443             StaffSymbol \override #'line-count = #1
2444             minimumVerticalExtent = #'(-2.0 . 3.0)
2445         }
2446         \translator {
2447             \VoiceContext
2448             \remove Stem_engraver
2449         }
2450     }   
2451 }
2452 @end lilypond
2453 @end table
2454
2455 If you don't like any of the predefined lists you can define your own
2456 list at the top of your file:
2457
2458 @lilypond[singleline, verbatim]
2459 #(define mydrums `(
2460         (bassdrum     default   #f        ,(make-pitch -1 2 0))
2461         (snare        default   #f        ,(make-pitch 0 1 0))
2462         (hihat        cross     #f        ,(make-pitch 0 5 0))
2463         (pedalhihat   xcircle   "stopped" ,(make-pitch 0 5 0))
2464         (lowtom       diamond   #f        ,(make-pitch -1 6 0))
2465 ))
2466 \include "drumpitch-init.ly"
2467 up = \notes { hh8 hh hh hh hhp4 hhp }
2468 down = \notes { bd4 sn bd toml8 toml }
2469 \score {    
2470     \apply #(drums->paper 'mydrums) \context Staff <
2471         \clef percussion
2472         \context Voice = up { \voiceOne \up }
2473         \context Voice = down { \voiceTwo \down }
2474     >
2475 }
2476 @end lilypond
2477
2478 To use a modified existing list instead of building your own from
2479 scratch you can append your modifications to the start of the existing
2480 list:
2481
2482 @example
2483 #(define mydrums (append `(
2484    (bassdrum default #f ,(make-pitch -1 2 0))
2485    (lowtom   diamond #f ,(make-pitch -1 6 0))
2486 ) drums ))
2487 @end example
2488
2489 @c FIXME: Too many levels of headers when using subsubsections.
2490 @c Perhaps junk subsection ``Percussion staves''
2491 @subsubsection Percussion staves with normal staves
2492 When you include @file{drumpitch-init.ly} then the default pitches
2493 are overridden so that you after the inclusion cannot use the common
2494 dutch pitch names anymore. Hence you might wan't to reinclude
2495 @file{nederlands.ly} after the drum-pattern-definitions:
2496 @lilypond[singleline,verbatim]
2497 \include "drumpitch-init.ly"
2498 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2499 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2500 \include "nederlands.ly"
2501 bass = \notes \transpose c, { a4. e8 r e g e }
2502 \score {
2503     <
2504         \apply #(drums->paper 'drums) \context Staff = drums <
2505             \clef percussion
2506             \context Voice = up { \voiceOne \up }
2507             \context Voice = down { \voiceTwo \down }
2508         >
2509         \context Staff = bass { \clef "F_8" \bass }
2510     >
2511 }
2512 @end lilypond
2513
2514 @subsubsection Percussion midi output
2515 In order to produce correct midi output you need to produce two score
2516 blocks - one for the paper and one for the midi.
2517 To use the percussion channel you set the property @code{instrument}
2518 to @code{'drums}. Because the drum-pitches themself are similar to the
2519 general midi pitches all you have to do is to insert the voices with
2520 none of the scheme functions to get the correct midi output:
2521
2522 @example
2523 \score @{    
2524     \apply #(drums->paper 'mydrums) \context Staff <
2525         \clef percussion
2526         \context Voice = up @{ \voiceOne \up @}
2527         \context Voice = down @{ \voiceTwo \down @}
2528     >
2529     \paper@{@}
2530 @}
2531 \score @{    
2532     \context Staff <
2533         \property Staff.instrument = #'drums
2534         \up \down
2535     >
2536     \midi@{@}
2537 @}
2538 @end example
2539
2540 @refbugs
2541
2542 This scheme is to be considered a temporary implementation. Even
2543 though the scheme will probably keep on working then the future might
2544 bring some other way of typesetting drums, and probably
2545 there will be made no great efforts in keeping things downwards
2546 compatible.
2547
2548 @c . {Piano music}
2549 @node Piano music
2550 @section Piano music
2551
2552 Piano music is an odd type of notation. Piano staves are two normal
2553 staves coupled with a brace.  The staves are largely independent, but
2554 sometimes voices can cross between the two staves.  The
2555 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2556 behavior.  In this section we discuss the @internalsref{PianoStaff} and some
2557 other pianistic peculiarities.
2558
2559 @menu
2560 * Automatic staff changes::     
2561 * Manual staff switches::       
2562 * Pedals::                      
2563 * Arpeggio::                    
2564 * Voice follower lines::        
2565 @end menu 
2566
2567
2568 @c .   {Automatic staff changes}
2569 @node Automatic staff changes
2570 @subsection Automatic staff changes
2571 @cindex Automatic staff changes
2572
2573 Voices can switch automatically between the top and the bottom
2574 staff. The syntax for this is
2575 @example
2576         \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2577 @end example        
2578 The autochanger switches on basis of pitch (central C is the turning
2579 point), and it looks ahead skipping over rests to switch rests in
2580 advance. Here is a practical example:
2581         
2582 @lilypond[verbatim,singleline]
2583 \score { \notes \context PianoStaff <
2584   \context Staff = "up" {
2585     \autochange Staff \context Voice = VA < \relative c' {
2586        g4 a  b c d r4 a g } > }
2587   \context Staff = "down" {
2588        \clef bass
2589        s1*2
2590 } > }
2591 @end lilypond
2592 Spacer rests are used to prevent the bottom staff from
2593 terminating too soon.
2594
2595
2596 @node Manual staff switches
2597 @subsection Manual staff switches
2598
2599 @cindex manual staff switches
2600 @cindex staff switch, manual
2601
2602 Voices can be switched between staves manually, using the following command:
2603 @example
2604   \translator Staff = @var{staffname} @var{music}
2605 @end example
2606 The string @var{staffname} is the name of the staff. It switches the
2607 current voice from its current staff to the Staff called
2608 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2609 @code{"down"}.
2610
2611 @c .   {Pedals}
2612 @node Pedals
2613 @subsection Pedals
2614 @cindex Pedals
2615
2616 Piano pedal instruction can be expressed using 
2617 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2618 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2619
2620 These identifiers are shorthands for spanner commands of the types
2621 @internalsref{Sustain}, @internalsref{UnaCorda} and @internalsref{Sostenuto}:
2622
2623 @lilypond[fragment,verbatim]
2624 c''4 \spanrequest \start "Sustain" c''4
2625 c''4 \spanrequest \stop "Sustain"
2626 @end lilypond
2627
2628 The symbols that are printed can be modified by setting
2629 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2630 Sustain, Sostenuto or UnaCorda.  Refer to the generated documentation of
2631 @rgrob{SustainPedal}, for example, for more information.
2632
2633 Pedals can also be indicated by a sequence of brackets, by setting the 
2634 @code{pedal-type} property of SustainPedal grobs: 
2635
2636 @lilypond[fragment,verbatim]
2637 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2638 c''4 \sustainDown d''4 e''4 a'4
2639 \sustainUp \sustainDown
2640  f'4 g'4 a'4 \sustainUp
2641 @end lilypond
2642
2643 A third style of pedal notation is a mixture of text and brackets,
2644 obtained by setting @code{pedal-type} to @code{mixed}:
2645
2646 @lilypond[fragment,verbatim]
2647 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2648 c''4 \sustainDown d''4 e''4 c'4
2649 \sustainUp \sustainDown
2650  f'4 g'4 a'4 \sustainUp
2651 @end lilypond
2652
2653 The default '*Ped' style for sustain and damper pedals corresponds to
2654 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2655 for a sostenuto pedal:
2656
2657 @lilypond[fragment,verbatim]
2658 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2659 @end lilypond
2660
2661 For fine-tuning of the appearance of a pedal bracket, the properties
2662 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2663 @code{PianoPedalBracket} grobs (see the detailed documentation of
2664 @rgrob{PianoPedalBracket}) can be modified.  For example, the bracket
2665 may be extended to the end of the note head.
2666
2667 @lilypond[fragment,verbatim]
2668 \property Staff.PianoPedalBracket \override
2669    #'shorten-pair = #'(0 . -1.0)
2670 c''4 \sostenutoDown d''4 e''4 c'4
2671 f'4 g'4 a'4 \sostenutoUp
2672 @end lilypond
2673
2674
2675
2676 @c .   {Arpeggio}
2677 @node Arpeggio
2678 @subsection Arpeggio
2679 @cindex Arpeggio
2680
2681 @cindex broken arpeggio
2682 @cindex @code{\arpeggio}
2683
2684 You can specify an arpeggio sign on a chord by attaching an
2685 @code{\arpeggio} to a note of the chord.
2686
2687
2688 @lilypond[fragment,relative,verbatim]
2689   \context Voice <c\arpeggio e g c>
2690 @end lilypond
2691
2692 When an arpeggio crosses staves in piano music, you attach an arpeggio
2693 to the chords in both staves, and set
2694 @code{PianoStaff.connectArpeggios}.
2695
2696 @lilypond[fragment,relative,verbatim]
2697   \context PianoStaff <
2698     \property PianoStaff.connectArpeggios = ##t
2699     \context Voice = one  { <c'\arpeggio e g c> }
2700     \context Voice = other { \clef bass  <c,,\arpeggio e g>}
2701   >  
2702 @end lilypond
2703
2704 This command creates @internalsref{Arpeggio} grobs.  Cross staff arpeggios
2705 are @code{PianoStaff.Arpeggio}.
2706
2707 To add an arrow head to explicitly specify the direction of the
2708 arpeggio, you should set the arpeggio grob property
2709 @code{arpeggio-direction}.
2710
2711 @lilypond[fragment,relative,verbatim]
2712   \context Voice {
2713      \property Voice.Arpeggio \set #'arpeggio-direction = #1
2714      <c\arpeggio e g c>
2715      \property Voice.Arpeggio \set #'arpeggio-direction = #-1
2716      <c\arpeggio e g c>
2717   }
2718 @end lilypond
2719
2720 A square bracket on the left indicates that the player should not
2721 arpeggiate the chord. To draw these brackets, set the
2722 @code{molecule-callback} property of @code{Arpeggio} or
2723 @code{PianoStaff.Arpeggio} grobs to @code{\arpeggioBracket}, and use
2724 @code{\arpeggio} statements within the chords as before.
2725
2726 @lilypond[fragment,relative,verbatim]
2727   \context PianoStaff <
2728     \property PianoStaff.connectArpeggios = ##t
2729     \property PianoStaff.Arpeggio \override
2730         #'molecule-callback = \arpeggioBracket
2731     \context Voice = one  { <c'\arpeggio e g c> }
2732     \context Voice = other { \clef bass  <c,,\arpeggio e g>}
2733   >  
2734 @end lilypond
2735
2736
2737 @refbugs
2738
2739 It is not possible to mix connected arpeggios and unconnected
2740 arpeggios in one PianoStaff at the same time.
2741
2742
2743
2744 @node  Voice follower lines
2745 @subsection Voice follower lines
2746
2747 @cindex follow voice
2748 @cindex staff switching
2749 @cindex cross staff
2750
2751 @cindex @code{followVoice}
2752
2753 Whenever a voice switches to another staff a line connecting the notes
2754 can be printed automatically. This is enabled if the property
2755 @code{PianoStaff.followVoice} is set to true:
2756
2757 @lilypond[fragment,relative,verbatim]
2758   \context PianoStaff <
2759     \property PianoStaff.followVoice = ##t
2760     \context Staff \context Voice {
2761       c1
2762       \translator Staff=two
2763       b2 a
2764     }
2765     \context Staff=two {\clef bass \skip 1*2 }
2766   >  
2767 @end lilypond
2768
2769 The associated grob is @internalsref{VoiceFollower}.
2770
2771
2772 @node Tablatures
2773 @section Tablatures
2774
2775 Tablature notation is used music for plucked string instruments.  It
2776 notates pitches not by using note heads, but by indicating on which
2777 string and fret a note must be played.  LilyPond offers limited
2778 support for tablature, by abusing the fingering system.
2779
2780 @menu
2781 * Tablatures basic::            
2782 * Non-guitar tablatures::       
2783 * Tablature in addition to normal staff::  
2784 @end menu
2785
2786 @node Tablatures basic
2787 @subsection Tablatures basic
2788 @cindex Tablatures basic
2789
2790 Tablature can be typeset with Lilypond by using the
2791 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
2792 tablature is a recent feature in Lilypond, most of the guitar special
2793 effects such as hammer, pull, bend are not yet supported.
2794
2795 With the @internalsref{TabStaff}, the string number associated to a note
2796 is given though the fingering mechanism, e.g. @code{c4-3} for a C
2797 quarter on the third string. The string 1 is the lowest one, and the
2798 tuning defaults to the standard guitar tuning (with 6 strings).
2799
2800 @lilypond[fragment,verbatim]
2801   \context TabStaff <
2802     \notes {
2803       \property Staff.Stem \override #'direction = #1
2804       
2805       a,4-2 c'-5 a-4 e'-6
2806       e-3 c'-5 a-4 e'-6
2807     }
2808   >  
2809 @end lilypond
2810
2811
2812 @node Non-guitar tablatures
2813 @subsection Non-guitar tablatures
2814 @cindex Non-guitar tablatures
2815
2816 There are many ways to customize Lilypond tablatures.
2817
2818 First you can change the number of strings, by setting the number of
2819 lines in the @internalsref{TabStaff}.  You can change the strings
2820 tuning. A string tuning is given as a Scheme list with one integer
2821 number for each string, the number being the pitch of an open string.
2822
2823 Finally, it is possible to change the Scheme function to format the
2824 tablature note text. The default is @var{fret-number-tablature-format},
2825 which uses the fret number, but for some instruments that may not use
2826 this notation, just create your own tablature-format function. This
2827 function takes three argument: the string number, the string tuning and
2828 the note pitch.
2829
2830
2831 @node Tablature in addition to normal staff
2832 @subsection Tablature in addition to normal staff
2833 @cindex Tablature in addition to normal staff
2834
2835 It is possible to typeset both tablature and a "normal" staff, as
2836 commonly done in many parts.
2837
2838 A common trick for that is to put the notes in a variables, and to hide
2839 the fingering information (which correspond to the string number) for
2840 the standard staff.
2841
2842 @lilypond[verbatim]
2843   part = \notes {
2844     a,4-2 c'-5 a-4 e'-6
2845     e-3 c'-5 a-4 e'-6
2846   }
2847   \score{
2848     \context StaffGroup <
2849       \context Staff <
2850         % Hide fingering number
2851         \property Staff.Fingering \override #'transparent = ##t
2852
2853         \part
2854       >
2855       \context TabStaff <
2856         \property Staff.Stem \override #'direction = #1
2857
2858         \part
2859       >
2860     >
2861   }
2862 @end lilypond
2863
2864
2865 @c . {Chords}
2866 @node Chords
2867 @section Chords
2868 @cindex Chords
2869
2870 LilyPond has support for both entering and printing chords. 
2871 @lilypond[verbatim,singleline]
2872 twoWays = \notes \transpose c'' {
2873   \chords {
2874     c1 f:sus4 bes/f
2875   }
2876   <c e g>
2877   <f bes c'>
2878   <f bes d'>
2879   }
2880
2881 \score {
2882    < \context ChordNames \twoWays
2883      \context Voice \twoWays > }
2884 @end lilypond
2885
2886 This example also shows that the chord printing routines do not try to
2887 be intelligent. If you enter @code{f bes d}, it does not interpret
2888 this as an inversion.
2889
2890 As you can see chords really are a set of pitches. They are internally
2891 stored as simultaneous music expressions. This means you can enter
2892 chords by name and print them as notes, enter them as notes and print
2893 them as chord names, or (the most common case) enter them by name, and
2894 print them as name.
2895
2896 @menu
2897 * Chords mode::                 
2898 * Printing named chords::       
2899 @end menu
2900
2901 @c .  {Chords mode}
2902 @node Chords mode
2903 @subsection Chords mode
2904 @cindex Chords mode
2905
2906 Chord mode is a mode where you can input sets of pitches using common
2907 names.  It is introduced by the keyword @code{\chords}.  It is similar
2908 to note mode, but words are also looked up in a chord modifier table
2909 (containing @code{maj}, @code{dim}, etc). Dashes and carets are used
2910 to indicate chord additions and subtractions, so articulation scripts
2911 can not be entered in Chord mode.
2912
2913 Throughout these examples, chords have been shifted around the staff
2914 using @code{\transpose}.
2915
2916 @lilypond[fragment,verbatim]
2917 \transpose c'' {
2918   \chords {
2919     c1  c:3-       c:7     c:8
2920     c:9 c:9-.5+.7+ c:3-.5- 
2921   }
2922 }
2923 @end lilypond
2924
2925 @cindex @code{aug}
2926 @cindex @code{dim}
2927 @cindex @code{maj}
2928 @cindex @code{sus}
2929
2930 The second type of modifier that may appear after the @code{:} is a
2931 named modifier.  Named modifiers are listed in the file
2932 @file{chord-modifiers.ly}.  The available modifiers are @code{m} and
2933 @code{min} which lower the 3rd half a step, `@code{aug}' which
2934 raises the 5th, `@code{dim}' which lowers the 5th,
2935 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2936 which replaces the 5th with a 4th.
2937
2938 @lilypond[fragment,verbatim]
2939 \transpose c'' {
2940   \chords {
2941     c1:m c:min7 c:maj c:aug c:dim c:sus
2942   }
2943 }
2944 @end lilypond
2945  
2946
2947 Chord subtractions are used to eliminate notes from a chord.  The
2948 notes to be subtracted are listed after a @code{^} character,
2949 separated by dots.
2950
2951 @lilypond[fragment,verbatim,center]
2952   \transpose c'' {
2953     \chords {
2954       c1^3 c:7^5.3 c:8^7
2955     }
2956   }
2957 @end lilypond 
2958 @cindex @code{/}
2959
2960 Chord inversions can be specified by appending `@code{/}' and the name
2961 of a single note to a chord.  In a chord inversion, the inverted note is
2962 transposed down until it is the lowest note in the chord.  If the note
2963 is not in the chord, a warning will be printed.
2964
2965 @lilypond[fragment,verbatim,center]
2966   \transpose c''' {
2967     \chords {
2968       c1 c/e c/g c:7/e
2969     }
2970   }
2971
2972 @end lilypond 
2973 @cindex @code{/+}
2974
2975 Bass notes can be added by `@code{/+}' and
2976 the name of a single note to a chord.  This has the effect of
2977 adding the specified note to the chord, lowered by an octave,
2978 so it becomes the lowest note in the chord.
2979
2980 @lilypond[fragment,verbatim,center]
2981   \transpose c''' {
2982     \chords {
2983       c1 c/+c c/+g c:7/+b
2984     }
2985   }
2986
2987 @end lilypond 
2988
2989 The formal syntax for named chords is as follows:
2990 @example
2991   @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2992 @end example
2993
2994 @var{tonic} should be the tonic note of the chord, and @var{duration} is
2995 the chord duration in the usual notation.  There are two kinds of
2996 modifiers.  One type is formed by @emph{chord additions}. Additions are
2997 obtained by listing intervals separated by dots.  An interval is written
2998 by its number with an optional @code{+} or @code{-} to indicate raising
2999 or lowering by half a step.  Chord additions have two effects: they adds
3000 the specified interval and all lower odd numbered intervals to the
3001 chord, and they may lower or raise the specified interval.
3002
3003
3004 @refbugs
3005
3006 Implementation details are gory. For example @code{c:4} not only adds
3007 a fourth, but also removes the third.
3008
3009
3010 @c .  {Printing named chords}
3011 @node Printing named chords
3012 @subsection Printing named chords
3013
3014 @cindex printing chord names
3015 @cindex chord names
3016 @cindex chords
3017
3018 For displaying printed chord names, use the @internalsref{ChordNames} context.
3019 The chords may be entered either using the notation described above, or
3020 directly using simultaneous music.
3021
3022 @lilypond[verbatim,singleline]
3023 scheme = \notes {
3024   \chords {a1 b c} <d f g>  <e g b>
3025 }
3026 \score {
3027   \notes<
3028     \context ChordNames \scheme
3029     \context Staff \transpose c'' \scheme
3030   >
3031 }
3032 @end lilypond
3033
3034 You can make the chord changes stand out by setting
3035 @code{ChordNames.chordChanges} to true.  This will only display chord
3036 names when there's a change in the chords scheme and at the start of a
3037 new line.
3038
3039 @lilypond[verbatim]
3040 scheme = \chords {
3041   c1:m c:m \break c:m c:m d
3042 }
3043 \score {
3044   \notes <
3045     \context ChordNames {
3046         \property ChordNames.chordChanges = ##t
3047         \scheme }
3048     \context Staff \transpose c'' \scheme
3049   >
3050 \paper{linewidth= 9.\cm}
3051 }
3052 @end lilypond
3053
3054 LilyPond examines chords specified as lists of notes to determine a name
3055 to give the chord. LilyPond will not try to identify chord inversions or
3056 an added bass note, which may result in strange chord names when chords
3057 are entered as a list of pitches:
3058
3059 @lilypond[verbatim,center,singleline]
3060 scheme = \notes {
3061   <c'1 e' g'>
3062   <e' g' c''>
3063   <e e' g' c''>
3064 }
3065
3066 \score {
3067   <
3068     \context ChordNames \scheme
3069     \context Staff \scheme
3070   >
3071 }
3072 @end lilypond
3073
3074
3075 By default, a chord name system proposed by Harald Banter (See
3076 @ref{Literature}) is used. The system is very regular and predictable.
3077 Typical American style chord names may be selected by setting the
3078 @code{style} property of the @code{ChordNames.ChordName} grob to
3079 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
3080
3081 Routines that determine the names to be printed are written in Scheme,
3082 and may be customized by the user.  The code can be found in
3083 @file{scm/chord-name.scm}.  Here's an example showing the differences in
3084 chord name styles:
3085
3086 @c too long?
3087 @c maybe just junk verbatim option?
3088 @lilypond[verbatim,singleline]
3089 scheme = \chords {
3090   c1 c:5^3 c:4^3 c:5+
3091   c:m7+ c:m5-.7
3092   c:5-.7 c:5+.7
3093   c:9^7
3094 }
3095
3096 \score {
3097   \notes <
3098     \context ChordNames = banter \scheme
3099     \context ChordNames = american {
3100       \property ChordNames.ChordName \override
3101         #'style = #'american \scheme }
3102     \context ChordNames = jazz {
3103       \property ChordNames.ChordName \override
3104         #'style = #'jazz \scheme }
3105     \context Staff \transpose c'' \scheme
3106   >
3107 }
3108 @end lilypond
3109
3110
3111 @node Writing parts
3112 @section Writing parts
3113
3114 Orchestral music involves some special notation, both in the full score,
3115 as in the individual parts. This section explains how to tackle common
3116 problems in orchestral music.
3117
3118
3119 @c .  {Transpose}
3120 @menu
3121 * Rehearsal marks::             
3122 * Bar numbers::                 
3123 * Instrument names::            
3124 * Transpose::                   
3125 * Multi measure rests::         
3126 * Automatic part combining::    
3127 * Hara kiri staves::            
3128 * Sound output for transposing instruments::  
3129 @end menu
3130
3131 @c .   {Rehearsal marks}
3132 @node Rehearsal marks
3133 @subsection Rehearsal marks
3134 @cindex Rehearsal marks
3135 @cindex mark
3136 @cindex @code{\mark}
3137
3138 To print a  rehearsal mark, use the @code{\mark} command. 
3139 @lilypond[fragment,verbatim]
3140 \relative c'' {
3141   c1 \mark "A"
3142   c1 \mark \default
3143   c1 \mark \default 
3144   c1 \mark "12"
3145   c1 \mark \default
3146   c1 \mark #'(music "scripts-segno") 
3147   c1
3148 }
3149 @end lilypond
3150
3151 As you can see, the mark is incremented automatically if you use
3152 @code{\mark \default}. The value to use is stored in the property
3153 @code{rehearsalMark} is used and automatically incremented.  The grob
3154 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3155 @code{input/test/boxed-molecule.ly} if you need boxes around the
3156 marks.
3157
3158 @node Bar numbers
3159 @subsection Bar numbers
3160
3161
3162 @cindex bar numbers
3163 @cindex measure numbers
3164 @cindex currentBarNumber
3165
3166 Bar numbers are printed by default at the start of the line.  The
3167 number itself is a property that can be set by modifying the
3168 @code{currentBarNumber} property, i.e.
3169 @example
3170   \property Score.currentBarNumber = #217
3171 @end example
3172
3173 If you want boxed bar numbers, see the example file
3174 @code{input/test/boxed-molecule.ly}.
3175
3176 See also @seeinternals{BarNumber}.
3177
3178 @refbugs
3179
3180 Printing bar numbers at regular intervals is not implemented.
3181 Barnumbers can collide with the StaffGroup, if there is one at the
3182 top. To solve this, You have to twiddle with the
3183 @internalsref{padding} property of @internalsref{BarNumber} if your
3184 score starts with a @internalsref{StaffGroup}.
3185
3186 @node Instrument names
3187 @subsection Instrument names
3188
3189 In scores, the instrument name is printed before the staff. This can
3190 be done by setting @code{Staff.instrument} and
3191 @code{Staff.instr}. This will print a string before the start of the
3192 staff. For the first start, @code{instrument} is used, for the next
3193 ones @code{instr} is used.
3194
3195 @lilypond[verbatim,singleline]
3196   \property Staff.instrument = "ploink " { c''4 }  
3197 @end lilypond
3198
3199 You can also use markup texts to construct more complicated instrument
3200 names:
3201
3202
3203 @lilypond[verbatim,singleline]
3204 #(define text-flat
3205   '((font-relative-size . -2 ) (music "accidentals--1")))
3206
3207 \score { \notes {
3208   \property Staff.instrument = #`((kern . 0.5) (lines
3209     "2 Clarinetti" (columns "     (B" ,text-flat ")")))
3210     c'' 4 }
3211 }
3212 @end lilypond
3213
3214
3215 @refbugs
3216
3217 When you put a name on a grand staff or piano staff the width of the
3218 brace is not taken into account. You must add extra spaces to the end of
3219 the name to avoid a collision.
3220
3221 @node Transpose
3222 @subsection Transpose
3223 @cindex Transpose
3224 @cindex transposition of pitches
3225 @cindex @code{\transpose}
3226
3227 A music expression can be transposed with @code{\transpose}.  The syntax
3228 is
3229 @example
3230   \transpose @var{pitch} @var{musicexpr}
3231 @end example
3232
3233 This means that middle C in @var{musicexpr} is transposed to
3234 @var{pitch}.
3235
3236 @code{\transpose} distinguishes between enharmonic pitches: both
3237 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
3238 a tone.  The first version will print sharps and the second version
3239 will print flats.
3240
3241 @lilypond[singleline, verbatim]
3242 mus =\notes { \key d \major cis d fis g }
3243 \score { \notes \context Staff {
3244   \clef "F" \mus
3245   \clef "G"
3246   \transpose g'' \mus
3247   \transpose f'' \mus
3248 }}
3249 @end lilypond
3250
3251 If you want to use both @code{\transpose} and @code{\relative}, then
3252 you must use @code{\transpose} first.  @code{\relative} will have no
3253 effect music that appears inside a @code{\transpose}.
3254
3255 @c .  {Multi measure rests}
3256 @node  Multi measure rests
3257 @subsection Multi measure rests
3258 @cindex Multi measure rests
3259
3260 @cindex @code{R}
3261
3262 Multi measure rests are entered using `@code{R}'. It is specifically
3263 meant for full bar rests and for entering parts: the rest can expand to
3264 fill a score with 
3265 rests, or it can be printed as a single multimeasure rest This expansion
3266 is controlled by the property @code{Score.skipBars}. If this is set to true,
3267 Lily will not expand empty measures, and the appropriate number is added
3268 automatically.
3269
3270 @lilypond[fragment,verbatim]
3271  \time 3/4 r2. | R2. | R2.*2
3272  \property Score.skipBars = ##t R2.*17  R2.*4
3273 @end lilypond
3274
3275 Notice that the @code{R2.} is printed as a whole rest, centered in the
3276 measure. 
3277
3278 @cindex whole rests for a full measure 
3279
3280 The grob for this object is @internalsref{MultiMeasureRest}.
3281
3282 @refbugs
3283
3284 Currently, there is no way to automatically condense multiple rests
3285 into a single multimeasure rest. Multi measure rests do not take part
3286 in rest collisions.
3287
3288 @cindex condensing rests
3289
3290 @node Automatic part combining
3291 @subsection Automatic part combining
3292 @cindex automatic part combining
3293 @cindex part combiner
3294
3295
3296 Automatic part combining is used to merge two parts of music onto a
3297 staff in an intelligent way.  It is aimed primarily at typesetting
3298 orchestral scores.  When the two parts are identical for a period of
3299 time, only one is shown.  In places where the two parts differ, they
3300 are typeset as separate voices, and stem directions are set
3301 automatically.  Also, solo and @emph{a due} parts can be identified
3302 and marked.
3303
3304 The syntax for part combining is
3305
3306 @example
3307   \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3308 @end example
3309 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3310 combined into one context of type @var{context}.  The music expressions
3311 must be interpreted by contexts whose names should start with @code{one}
3312 and @code{two}.
3313
3314 The most useful function of the part combiner is to combine parts into
3315 one voice, as common for wind parts in orchestral scores:
3316
3317 @lilypond[verbatim,singleline,fragment]
3318   \context Staff <
3319     \context Voice=one \partcombine Voice
3320       \context Thread=one \relative c'' {
3321         g a () b r
3322       }
3323       \context Thread=two \relative c'' {
3324         g r4 r f
3325       }
3326   >
3327 @end lilypond
3328
3329 Notice that the first @code{g} appears only once, although it was
3330 specified twice (once in each part).  Stem, slur and tie directions are
3331 set automatically, depending whether there is a solo or unisono. The
3332 first part (with context called @code{one}) always gets up stems, and
3333 `solo', while the second (called @code{two}) always gets down stems and
3334 `Solo II'.
3335
3336 If you just want the merging parts, and not the textual markings, you
3337 may set the property @var{soloADue} to false.
3338
3339 @lilypond[verbatim,singleline,fragment]
3340   \context Staff <
3341     \property Staff.soloADue = ##f
3342     \context Voice=one \partcombine Voice
3343       \context Thread=one \relative c'' {
3344         b4 a c g
3345       }
3346       \context Thread=two \relative c'' {
3347         d,2 a4 g'
3348       }
3349   >
3350 @end lilypond
3351
3352 There are a number of other properties that you can use to tweak the
3353 behavior of part combining, refer to the automatically generated
3354 documentation of @reng{Thread_devnull_engraver} and
3355 @reng{Voice_devnull_engraver}. Look at the documentation of the
3356 responsible engravers, @code{Thread_devnull_engraver},
3357 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3358
3359 @refbugs
3360
3361 In @code{soloADue} mode, when the two voices play the same notes on and
3362 off, the part combiner may typeset @code{a2} more than once in a
3363 measure.
3364
3365 @lilypond[fragment,singleline]
3366   \context Staff <
3367     \context Voice=one \partcombine Voice
3368       \context Thread=one \relative c'' {
3369         c b c b c a c a
3370       }
3371       \context Thread=two \relative c'' {
3372         b b b b f a f a
3373       }
3374   >
3375 @end lilypond
3376
3377 @cindex @code{Thread_devnull_engraver}
3378 @cindex @code{Voice_engraver}
3379 @cindex @code{A2_engraver}
3380
3381 @node Hara kiri staves
3382 @subsection Hara kiri staves
3383
3384 In orchestral scores, staff lines that only have rests are usually removed.
3385 This saves some space.  LilyPond also supports this through the hara
3386 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3387 the Japanese Samourai warriors.} staff. This staff commits suicide when
3388 it finds itself to be empty after the line-breaking process.  It will
3389 not disappear when it contains normal rests, you must use multi measure
3390 rests.
3391
3392 The hara kiri staff is specialized version of the @internalsref{Staff}
3393 context. It is available as the context identifier
3394 @code{\HaraKiriStaffContext}.  Observe how the second staff in this
3395 example disappears in the second line.
3396
3397 @lilypond[verbatim]
3398 \score  {
3399   \notes \relative c' <
3400     \context Staff = SA { e4 f g a \break c1 }
3401     \context Staff = SB { c4 d e f \break R1 }
3402   >
3403   \paper {
3404     linewidth = 6.\cm 
3405     \translator { \HaraKiriStaffContext }
3406   }
3407 }
3408 @end lilypond
3409
3410
3411 @node Sound output for transposing instruments
3412 @subsection Sound output for transposing instruments
3413
3414 When you want to make a MIDI file from a score containing transposed
3415 and untransposed instruments, you have to instruct LilyPond the pitch
3416 offset (in semitones) for the transposed instruments. This is done
3417 using the @code{transposing} property. It does not affect printed
3418 output.
3419
3420 @cindex @code{transposing}
3421
3422 @example
3423         \property Staff.instrument = #"Cl. in B-flat"
3424         \property Staff.transposing = #-2
3425 @end example
3426
3427
3428
3429 @c . {Custodes}
3430 @node Ancient notation 
3431 @section Ancient notation
3432
3433 @menu
3434 * Ancient note heads::          
3435 * Custodes::                    
3436 * Ancient clefs ::              
3437 * Figured bass::                
3438 @end menu
3439
3440
3441 @node Ancient note heads
3442 @subsection Ancient note heads
3443
3444  To get a longa note head, you have to use mensural note heads. This
3445 is accomplished by setting the @code{style} property of the
3446 NoteHead grob to @code{mensural}. There is also a note head style
3447 @code{baroque} which gives mensural note heads for @code{\longa} and
3448 @code{\breve} but standard note heads for shorter notes.
3449
3450 @lilypond[fragment,singleline,verbatim]
3451  \property Voice.NoteHead \set #'style = #'mensural
3452  \property Voice.NoteHead \set #'font-family = #'ancient
3453  a'\longa
3454 @end lilypond
3455
3456 @node Custodes
3457 @subsection Custodes
3458
3459 @cindex Custos
3460 @cindex Custodes
3461
3462 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
3463 staff context symbol that appears at the end of a staff line.  It
3464 anticipates the pitch of the first note(s) of the following line and
3465 thus helps the player or singer to manage line breaks during
3466 performance, thus enhancing readability of a score.
3467
3468 @lilypond[verbatim]
3469 \score {
3470   \notes { c'1 \break
3471         \property Staff.Custos \set #'style = #'mensural
3472         d' }
3473   \paper {
3474     \translator {
3475       \StaffContext
3476       \consists Custos_engraver
3477     }
3478   }
3479 }
3480 @end lilypond
3481
3482 Custodes were frequently used in music notation until the 17th century.
3483 There were different appearances for different notation styles.
3484 Nowadays, they have survived only in special forms of musical notation
3485 such as via the @emph{editio vaticana} dating back to the beginning of
3486 the 20th century.
3487
3488 For typesetting custodes, just put a @code{Custos_engraver} into the
3489 @internalsref{Staff} context when declaring the @code{\paper} block.  In this
3490 block, you can also globally control the appearance of the custos symbol
3491 by setting the custos @code{style} property.  Currently supported styles
3492 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
3493 @code{mensural}.
3494
3495 @example
3496 \paper @{
3497   \translator @{
3498       \StaffContext
3499       \consists Custos_engraver
3500       Custos \override #'style = #'mensural
3501   @}
3502 @}
3503 @end example
3504
3505 The property can also be set locally, for example in a @code{\notes}
3506 block:
3507
3508 @example
3509 \notes @{
3510   \property Staff.Custos \override #'style = #'vaticana
3511   c'1 d' e' d' \break c' d' e' d'
3512 @}
3513 @end example
3514
3515 @node Ancient clefs 
3516 @subsection Ancient clefs
3517
3518 LilyPond supports a variety of clefs, many of them ancient. These can
3519 be selected from the @code{ancient} font family, by setting
3520 @code{Staff.clefGlyph}) to one of the following values
3521
3522 @table @code
3523 @item clefs-C
3524  modern style C clef
3525 @item clefs-F
3526  modern style F clef
3527 @item clefs-G
3528  modern style G clef
3529 @item clefs-vaticana_do
3530  Editio Vaticana style do clef
3531 @item clefs-vaticana_fa
3532  Editio Vaticana style fa clef
3533 @item clefs-medicaea_do
3534  Editio Medicaea style do clef
3535 @item clefs-medicaea_fa
3536  Editio Medicaea style fa clef
3537 @item clefs-mensural1_c
3538  modern style mensural C clef
3539 @item clefs-mensural2_c
3540  historic style small mensural C clef
3541 @item clefs-mensural3_c
3542  historic style big mensural C clef
3543 @item clefs-mensural1_f
3544  historic style traditional mensural F clef
3545 @item clefs-mensural2_f
3546  historic style new mensural F clef
3547 @item clefs-mensural_g
3548  historic style mensural G clef
3549 @item clefs-hufnagel_do
3550  historic style hufnagel do clef
3551 @item clefs-hufnagel_fa
3552  historic style hufnagel fa clef
3553 @item clefs-hufnagel_do_fa
3554  historic style hufnagel combined do/fa clef
3555 @item clefs-percussion
3556  modern style percussion clef
3557 @end table
3558
3559 @emph{Modern style} means ``as is typeset in current editions.''
3560 @emph{Historic style} means ``as was typeset or written in contemporary
3561 historic editions''.  @emph{Editio XXX style} means ``as is/was printed in
3562 Editio XXX.''
3563
3564 @cindex Vaticana, Editio
3565 @cindex Medicaea, Editio
3566 @cindex hufnagel clefs
3567
3568
3569 @node Figured bass
3570 @subsection Figured bass
3571
3572 @cindex Basso continuo
3573
3574 LilyPond has limited support for figured bass:
3575
3576 @lilypond[verbatim,fragment]
3577 <
3578  \context FiguredBass
3579    \figures {
3580         <_! 3+ 5- >4
3581         < [4 6] 8 >
3582    }
3583  \context Voice { c4 g8 }
3584 >
3585 @end lilypond
3586
3587 The support for figured bass consists of two parts: there is an input
3588 mode, introduced by @code{\figures}, where you can enter bass figures
3589 as numbers, and there is a context called @internalsref{FiguredBass}
3590 that takes care of making @internalsref{BassFigure} grobs.
3591
3592 In figures input mode, a group of bass figures is delimited by
3593 @code{<} and @code{>}. The duration is entered after the @code{>}.
3594 @example
3595         <4 6>
3596 @end example
3597 @lilypond[fragment]
3598 \context FiguredBass
3599 \figures { <4 6> }
3600 @end lilypond
3601
3602 Accidentals are added to the numbers if you alterate them by
3603 appending @code{-}, @code{!}  and @code{+}.
3604
3605 @example
3606   <4- 6+ 7!>
3607 @end example
3608 @lilypond[fragment]
3609   \context FiguredBass
3610 \figures { <4- 6+ 7!> }
3611 @end lilypond
3612
3613 Spaces or dashes may be inserted by using @code{_}. Brackets are
3614 introduced with @code{[} and @code{]}.
3615
3616 @example
3617         < [4 6] 8 [_ 12]>
3618 @end example
3619 @lilypond[fragment]
3620  \context FiguredBass
3621 \figures { < [4 6] 8 [_ 12]> }
3622 @end lilypond
3623
3624 Although the support for figured bass may superficially resemble chord
3625 support, it works much simpler: in figured bass simply stores the
3626 numbers, and then prints the numbers you entered. There is no
3627 conversion to pitches, and no realizations of the bass are played in
3628 the MIDI file.
3629
3630
3631 @c . {Tuning output}
3632 @node Tuning output
3633 @section Tuning output
3634
3635 LilyPond tries to take as much formatting as possible out of your
3636 hands. Nevertheless, there are situations where it needs some help, or
3637 where you want to override its decisions. In this section we discuss
3638 ways to do just that.
3639
3640 Formatting is internally done by manipulating so called grobs (graphic
3641 objects). Each grob carries with it a set of properties (grob
3642 properties) specific to that object.  For example, a stem grob has
3643 properties that specify its direction, length and thickness.
3644
3645 The most direct way of tuning the output is by altering the values of
3646 these properties. There are two ways of doing that: first, you can
3647 temporarily change the definition of a certain type of grob, thus
3648 affecting a whole set of objects.  Second, you can select one specific
3649 object, and set a grob property in that object.
3650
3651 @menu
3652 * Tuning groups of grobs ::     
3653 * Tuning per grob ::            
3654 * Font selection::              
3655 * Text markup::                 
3656 @end menu
3657
3658 @node Tuning groups of grobs 
3659 @subsection Tuning groups of grobs 
3660
3661 @cindex grob description
3662
3663
3664
3665 A grob definition is a Scheme association list, that is stored in a
3666 context property.  By assigning to that property (using plain
3667 @code{\property}), you can change the resulting grobs.
3668
3669 @lilypond[verbatim, fragment]
3670 c'4 \property Voice.Stem  = #'()
3671 @end lilypond
3672
3673 The @code{\property} assignment effectively empties the definition of
3674 the Stem object. One of the effects is that the recipe of how it should be
3675 printed is erased, with the effect of rendering it invisible.  The above
3676 assignment is available as a standard identifier, for the case that you
3677 find this useful:
3678
3679 @example
3680   \property Voice.Stem = \turnOff
3681 @end example
3682
3683 @cindex \override
3684 @cindex \revert
3685 @cindex \set
3686
3687 This mechanism is fairly crude, since you can only set, but not modify,
3688 the definition of a grob. For this reason, there is a more advanced
3689 mechanism.
3690
3691 The definition of a grob is actually a list of default grob
3692 properties. For example, the definition of the Stem grob (available in
3693 @file{scm/grob-description.scm}), defines the following values for
3694 @internalsref{Stem}
3695
3696 @example
3697         (thickness . 0.8)
3698         (beamed-lengths . (0.0 2.5 2.0 1.5))
3699         (Y-extent-callback . ,Stem::height)
3700         @var{...}
3701 @end example
3702
3703 You can add a property on top of the existing definition, or remove a
3704 property, thus overriding the system defaults:
3705 @lilypond[verbatim]
3706 c'4 \property Voice.Stem \override #'thickness = #4.0
3707 c'4 \property Voice.Stem \revert #'thickness
3708 c'4
3709 @end lilypond
3710 You should balance @code{\override} and @code{\revert}. If that's too
3711 much work, you can use the @code{\set} shorthand. It performs a revert
3712 followed by an override. The following example gives exactly the same
3713 result as the previous one. 
3714 @lilypond[verbatim]
3715 c'4 \property Voice.Stem \set #'thickness = #4.0
3716 c'4 \property Voice.Stem \set #'thickness = #0.8
3717 c'4
3718 @end lilypond
3719 If you use @code{\set}, you must explicitly restore the default.
3720
3721
3722 Formally the syntax for these constructions is
3723 @example
3724 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
3725 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
3726 \property @var{context}.@var{grobname} \revert @var{symbol}
3727 @end example
3728 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
3729 and @var{grobname} are strings and @var{value} is a Scheme expression.
3730
3731
3732 If you revert a setting which was not set in the first place, then it
3733 has no effect. However, if the setting was set as a system default, it
3734 may remove the default value, and this may give surprising results,
3735 including crashes.  In other words, @code{\override} and @code{\revert},
3736 must be carefully balanced.
3737
3738 These are examples of correct nesting of @code{\override}, @code{\set},
3739 @code{\revert}. 
3740
3741 A clumsy but correct form:
3742 @example
3743   \override \revert \override \revert \override \revert
3744 @end example
3745
3746 Shorter version of the same:
3747 @example 
3748   \override \set \set  \revert
3749 @end example
3750
3751 A short form, using only @code{\set}. This requires you to know the
3752 default value:
3753 @example
3754   \set \set \set \set @var{to default value}
3755 @end example
3756
3757 If there is no default (i.e. by default, the grob property is unset),
3758 then you can use
3759 @example
3760   \set \set \set \revert
3761 @end example
3762
3763 For the digirati, the grob description is an Scheme association
3764 list. Since a Scheme list is a singly linked list, we can treat it as a
3765 stack, and @code{\override} and @code{\revert} are just push and pop
3766 operations. This pushing and popping is also used for overriding
3767 automatic beaming settings.
3768
3769 @refbugs
3770
3771 LilyPond will hang or crash if @var{value} contains cyclic references.
3772 The backend is not very strict in type-checking grob properties. If you
3773 @code{\revert} properties that are expected to be set by default,
3774 LilyPond may crash.
3775
3776
3777 @cindex adjusting staff symbol
3778 @cindex StaffSymbol, using \property
3779 @cindex staff lines, setting number of
3780
3781 Some grobs are created at the moment that their context is created. An
3782 example of such a grob is the staff itself (i.e. the horizontal lines).
3783 You can not change the appearance of the staff symbol by manipulating
3784 @code{\property Staff.StaffSymbol}.  At the moment that @code{\property
3785 Staff} is interpreted, a Staff context is made, and the StaffSymbol is
3786 created before any @code{\override} is effective. You can deal with this
3787 either overriding properties in a @code{\translator} definition, or by
3788 using @code{\outputproperty}.
3789
3790
3791
3792
3793 @node Tuning per grob 
3794 @subsection Tuning per grob 
3795
3796 @cindex \outputproperty
3797
3798 A second way of tuning grobs is the more arcane @code{\outputproperty}
3799 feature.  The syntax is as follows:
3800 @example
3801 \outputproperty @var{predicate} @var{symbol} = @var{value}
3802 @end example
3803 Here @code{predicate} is a Scheme function taking a grob argument, and
3804 returning a boolean.  This statement is processed by the
3805 @code{Output_property_engraver}.  It instructs the engraver to feed all
3806 grobs that it sees to @var{predicate}. Whenever the predicate returns
3807 true, the grob property @var{symbol} will be set to @var{value}.
3808
3809 You will need to combine this statement with @code{\context} to select
3810 the appropriate context to apply this to.
3811
3812 Here are some random examples. 
3813
3814
3815 In the following example, all note heads occurring at current staff
3816 level, are shifted up and right by setting their @code{extra-offset}
3817 property.
3818
3819 @lilypond[fragment,verbatim,singleline]
3820 \relative c'' { c4
3821   \context Staff \outputproperty
3822   #(make-type-checker 'note-head-interface)
3823   #'extra-offset = #'(0.5 . 0.75)
3824   <c8 e g> }
3825 @end lilypond
3826
3827 @cindex @code{extra-offset}
3828
3829 In this example, the predicate checks the @code{text} grob property, to
3830 shift only the `m.d.' text,  but not the fingering instruction "2".
3831 @lilypond[verbatim,singleline]
3832 #(define (make-text-checker text)
3833    (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
3834
3835 \score {    
3836   \notes\relative c''' {
3837     \property Voice.Stem \set #'direction = #1
3838     \outputproperty #(make-text-checker "m.d.")
3839       #'extra-offset = #'(-3.5 . -4.5)
3840     a^2^"m.d."    
3841   }
3842 }
3843 @end lilypond
3844
3845 @refbugs
3846
3847 If possible, avoid this feature: the semantics are not very clean, and
3848 the syntax and semantics are up for rewrite.
3849
3850
3851
3852
3853 @node Font selection
3854 @subsection Font selection
3855
3856 The most common thing to change about the appearance of fonts is
3857 their size. The font size of a @internalsref{Voice},
3858 @internalsref{Staff} or @internalsref{Thread} context, can be easily
3859 changed by setting the @code{fontSize} property for that context:
3860 @lilypond[fragment,relative=1]
3861   c4 c4 \property Voice.fontSize = #-1
3862   f4 g4
3863 @end lilypond
3864  This command will not change the size of variable symbols, such as
3865 beams or slurs.  You can use this command to get smaller symbol for
3866 cue notes, but that involves some more subtleties. An elaborate
3867 example of those is in @file{input/test/cue-notes.ly}.
3868
3869 @cindex cue notes
3870 @cindex font size
3871 @cindex size
3872
3873 The font used for printing a grob can be selected by setting
3874 @code{font-name}, e.g.
3875 @example
3876   \property Staff.TimeSignature
3877     \set #'font-name = #"cmr17"
3878 @end example
3879 You may use any font which is available to @TeX{}, such as foreign
3880 fonts or fonts that do not belong to the Computer Modern font family.
3881 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
3882 can also be adjusted with a more fine-grained mechanism.  By setting
3883 the grob properties described below, you can select a different font.
3884 All three mechanisms work for every grob that supports
3885 @code{font-interface}.
3886
3887 @table @code
3888 @item font-family
3889  A symbol indicating the general class of the typeface.  Supported are
3890 @code{roman} (Computer Modern), @code{braces} (for piano staff
3891 braces), @code{music} (the standard music font), @code{ancient} (the
3892 ancient notation font) @code{dynamic} (font for dynamic signs) and
3893 @code{typewriter}. 
3894   
3895 @item font-shape
3896   A symbol indicating the shape of the font, there are typically several
3897   font shapes available for each font family. Choices are @code{italic},
3898   @code{caps} and @code{upright} 
3899
3900 @item font-series
3901 A  symbol indicating the series of the font. There are typically several
3902 font series for each font family and shape. Choices are @code{medium}
3903 and @code{bold}. 
3904
3905 @item font-relative-size
3906   A number indicating the size relative the standard size.  For example,
3907   with 20pt staff height, relative size -1  corresponds to 16pt staff
3908   height, and relative size +1 corresponds to 23 pt staff height.
3909
3910 @item font-design-size
3911 A number indicating  the design size of the font. 
3912
3913 This is a feature of the Computer Modern Font: each point size has a
3914 slightly different design. Smaller design sizes are relatively wider,
3915 which enhances readability.
3916 @end table
3917
3918 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
3919 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
3920 to override default setting, which are always present. For example:
3921 @example
3922   \property Lyrics . LyricText \override #'font-series = #'bold
3923   \property Lyrics . LyricText \override #'font-family = #'typewriter
3924   \property Lyrics . LyricText \override #'font-shape = #'*
3925 @end example
3926
3927 @cindex @code{font-style}
3928
3929 There are also pre-cooked font selection qualifiers. These are
3930 selected through the grob property @code{font-style}.  For example,
3931 the style @code{finger} selects family @code{number} and relative size
3932 @code{-3}.  Styles available include @code{volta}, @code{finger},
3933 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
3934 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
3935 tables for selecting fonts are located in @file{scm/font.scm}. Refer
3936 to this file for more information.
3937
3938 @cindex magnification
3939
3940 The size of the font may be scaled with the grob property
3941 @code{font-magnification}.  For example, @code{2.0} blows up all
3942 letters by a factor 2 in both directions.
3943
3944 @refbugs
3945
3946 Relative size is not linked to any real size.
3947
3948 There is no style sheet provided for other fonts besides the @TeX{}
3949 family, and the style sheet can not be modified easiyl.
3950
3951 @cindex font selection
3952 @cindex font magnification
3953 @cindex @code{font-interface}
3954
3955
3956 @node Text markup
3957 @subsection Text markup
3958 @cindex text markup
3959 @cindex markup text
3960
3961 LilyPond has an internal mechanism to typeset texts. You can
3962 form text markup expressions by composing scheme expressions
3963 in the following way.
3964
3965 @lilypond[verbatim, singleline]
3966  \relative c' {
3967     \fatText
3968     a^#"upright"
3969     b_#'(bold "bold")
3970     c^#'(italic "italic")
3971     d_#'((bold italic) "ff")
3972     e^#'(dynamic "ff")
3973     f_#'(lines "one" (bold "two"))
3974     g^#'(music "noteheads-2" ((raise . 2.4) "flags-u3"))
3975   }
3976 @end lilypond
3977
3978 Normally, the Scheme markup text is stored in the @code{text} property
3979 of a grob.  Formally, it is defined as follows:
3980
3981 @example
3982 text: string | (head? text+)
3983 head: markup | (markup+)
3984 markup-item: property | abbrev
3985 property: (@var{key} . @var{value})
3986 abbrev: @code{columns lines roman music bold italic named super sub}
3987         @code{overstrike text finger volta timesig mmrest mark script}
3988         @code{large Large dynamic}
3989 @end example
3990
3991 The markup is broken down and converted into a list of grob properties,
3992 which are prepended to the property list.  The @var{key}-@var{value}
3993 pair is a grob property. A list of properties available is included in
3994 the generated documentation for @rint{Text_interface}.
3995
3996 The following abbreviations are defined:
3997 @table @code
3998 @item columns
3999  horizontal mode: set all text on one line (default)
4000 @item lines
4001  vertical mode: set every text on a new line
4002 @item roman
4003  select roman font
4004 @item music
4005  selects the Feta font (the standard font for music notation glyphs),
4006 and uses named lookup
4007
4008 @item bold
4009  select bold series
4010 @item italic
4011  select italic shape
4012 @item named
4013  lookup by character name
4014 @item text
4015  plain text lookup (by character value)
4016 @item super
4017  superscript
4018 @item sub
4019  subscript
4020 @item overstrike
4021  the next text or character overstrikes this one
4022 @item finger
4023  select fingering number fontstyle
4024 @item volta
4025  select volta number fontstyle
4026 @item timesig
4027  select time signature number fontstyle
4028 @item mmrest
4029  select multi measure rest number fontstyle
4030 @item mark
4031  select mark number fontstyle
4032 @item script
4033  select scriptsize roman fontstyle
4034 @item large
4035  select large roman fontstyle
4036 @item Large
4037  select Large roman fontstyle
4038 @item dynamic
4039  select dynamics fontstyle
4040 @end table
4041
4042
4043 @cindex metronome mark
4044
4045 One practical application of complicated markup is to fake a metronome
4046 marking:
4047
4048 @lilypond[verbatim]
4049 #(define note '(columns
4050   (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
4051 #(define eight-note `(columns ,note ((kern . -0.1)
4052   (music ((raise . 3.5) "flags-u3")))))
4053 #(define dotted-eight-note
4054   `(columns ,eight-note (music "dots-dot")))
4055
4056 \score {
4057   \notes\relative c'' {
4058     a1^#`((columns (font-relative-size . -1)) ,dotted-eight-note " = 64")
4059   }
4060   \paper {
4061     linewidth = -1.
4062     \translator{
4063       \ScoreContext
4064       TextScript \override #'font-shape = #'upright
4065     }
4066   }
4067 }
4068 @end lilypond
4069
4070 @refbugs
4071
4072 The syntax and semantics of markup texts are not clean, and both
4073 syntax and semantics are slated for a rewrite.
4074
4075 @node Global layout
4076 @section Global layout
4077
4078 The global layout determined by three factors: the page layout, the
4079 line breaks and the spacing. These all influence each other: The
4080 choice of spacing determines how densely each system of music is set,
4081 whree line breaks breaks are chosen, and thus ultimately how many
4082 pages a piece of music takes. In this section we will explain how the
4083 lilypond spacing engine works, and how you can tune its results.
4084
4085 Globally spoken, this procedure happens in three steps: first,
4086 flexible distances (``springs'') are chosen, based on durations. All
4087 possible line breaking combination are tried, and the one with the
4088 best results---a layout that has uniform density and requires as
4089 little stretching or cramping as possible---is chosen. When the score
4090 is processed by @TeX{}, page are filled with systems, and page breaks
4091 are chosen whenever the page gets full.
4092
4093 @menu
4094 * Spacing::                     
4095 * Font Size::                   
4096 * Line breaking::               
4097 * Page layout::                 
4098 @end menu
4099
4100 @node Spacing
4101 @subsection Spacing
4102
4103 The spacing engine translates differences in durations into
4104 stretchable distances (``springs'') of differing lengths. Longer
4105 durations get more space, shorter durations get less.  The basis for
4106 assigning spaces to durations, is that the shortest durations get a
4107 fixed amount of space, and the longer durations get more: doubling a
4108 duration adds a fixed amount of space to the note.
4109
4110 For example, the following piece contains lots of half, quarter and
4111 8th notes, the eighth note is followed by 1 note head width. The The
4112 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
4113 @lilypond[fragment, verbatim, relative=1]
4114  c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
4115 @end lilypond
4116
4117 These two amounts of space are @code{shortest-duration-space}
4118 @code{spacing-increment}, grob properties of
4119 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
4120 set to 1.2, which is the width of a note head, and
4121 @code{shortest-duration-space} is set to 2.0, meaning that the
4122 shortest note gets 2 noteheads of space. For normal notes, this space
4123 is always counted from the left edge of the symbol, so the short notes
4124 in a score is generally followed by one note head width of space.
4125
4126 If one would follow the above procedure exactly, then adding a single
4127 32th note to a score that uses 8th and 16th notes, would widen up the
4128 entire score a lot. The shortest note is no longer a 16th, but a 64th,
4129 thus adding 2 noteheads of space to every note. To prevent this, the
4130 shortest duration for spacing is not the shortest note in the score,
4131 but the most commonly found shortest note.  Notes that are even
4132 shorter this are followed by a space that is proportonial to their
4133 duration relative to the common shortest note.  So if we were to add
4134 only a few 16th notes to the example above, they would be followed by
4135 half a NHW:
4136
4137 @lilypond[fragment, verbatim, relative=1]
4138  c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
4139 @end lilypond
4140
4141 The most common shortest duration is determined as follows: in every
4142 measure, the shortest duration is determined. The most common short
4143 duration, is taken as the basis for the spacing, with the stipulation
4144 that this shortest duration should always be equal to or shorter than
4145 1/8th note. The shortest duration is printed when you run lilypond
4146 with @code{--verbose}.  These durations may also be customized. If you
4147 set the @code{common-shortest-duration} in
4148 @internalsref{SpacingSpanner}, then this sets the base duration for
4149 spacing. The maximum duration for this base (normally 1/8th), is set
4150 through @code{base-shortest-duration}.
4151
4152 @cindex @code{common-shortest-duration}
4153 @cindex @code{base-shortest-duration}
4154 @cindex @code{stem-spacing-correction}
4155 @cindex @code{spacing}
4156
4157 In the introduction it was explained that stem directions influence
4158 spacing. This is controlled with @code{stem-spacing-correction} in
4159 @internalsref{NoteSpacing}. The @code{StaffSpacing} grob contains the
4160 same property for controlling the stem/barline spacing. In the
4161 following example shows these corrections, once with default settings,
4162 and once with exaggerated corrections.  
4163
4164 @lilypond
4165     \score { \notes {
4166       c'4 e''4 e'4 b'4 |
4167       b'4 e''4 b'4 e''4|
4168       \property Staff.NoteSpacing \override #'stem-spacing-correction
4169       = #1.5
4170       \property Staff.StaffSpacing \override #'stem-spacing-correction
4171       = #1.5
4172       c'4 e''4 e'4 b'4 |
4173       b'4 e''4 b'4 e''4|      
4174     }
4175     \paper { linewidth = -1. } }
4176 @end lilypond
4177
4178
4179
4180 @refbugs
4181
4182 Spacing is determined on a score wide basis. If you have a score that
4183 changes its character (measured in durations) half way during the
4184 score, the part containing the longer durations will be spaced too
4185 widely.
4186
4187 Generating optically pleasing spacing is black magic. LilyPond tries
4188 to deal with a number of frequent cases. Here is an example that is
4189 not handled correctly, due to the combination of chord collisions and
4190 kneed stems.
4191
4192 @lilypond
4193 \score {
4194      \context PianoStaff \notes \transpose c''' <
4195      \context Staff = up { s1 }
4196      \context Staff = down { [c8 c \translator Staff=up <c d> c 
4197 \translator Staff=down c c c] }
4198      >
4199      \paper { linewidth = -1 }
4200 }
4201 @end lilypond
4202
4203
4204 @c .  {Font size}
4205 @node Font Size
4206 @subsection Font size
4207 @cindex font size, setting
4208 @cindex staff size, setting
4209 @cindex @code{paper} file
4210
4211 The Feta font provides musical symbols at seven different sizes.
4212 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
4213 point, and 26 point.  The point size of a font is the height of the
4214 five lines in a staff when displayed in the font.
4215
4216 Definitions for these sizes are the files @file{paperSZ.ly}, where
4217 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26.  If you include any
4218 of these files, the identifiers @code{paperEleven},
4219 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
4220 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
4221 are defined respectively.  The default @code{\paper} block is also
4222 set. These files should be imported at toplevel, i.e.
4223 @example
4224         \include "paper26.ly"
4225         \score @{  ... @}
4226 @end example
4227
4228 The font definitions are generated using a Scheme function. For more
4229 details, see the file @file{scm/font.scm}.
4230
4231
4232 @c .  {Line break}
4233 @node Line breaking
4234 @subsection Line breaking
4235
4236 @cindex line breaks
4237 @cindex breaking lines
4238
4239 Line breaks are normally computed automatically. They are chosen such
4240 that it looks neither cramped nor loose, and that consecutive lines have
4241 similar density.
4242
4243 Occasionally you might want to override the automatic breaks; you can
4244 do this by specifying @code{\break}. This will force a line break at
4245 this point.  Line breaks can only occur at places where there are bar
4246 lines.  If you want to have a line break where there is no bar line,
4247 you can force an invisible bar line by entering @code{\bar
4248 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
4249 point.
4250
4251 If you want linebreaks at regular intervals, you can use the following:
4252 @example
4253 <  \repeat 7 unfold @{ s1 * 4 \break  @}
4254    @emph{real music}
4255
4256 @end  example
4257 This makes the following 28 measures (assuming 4/4 time) be broken every
4258 4 measures.
4259
4260 @node Page layout
4261 @subsection Page layout
4262
4263 @cindex page breaks
4264 @cindex breaking pages
4265
4266 @cindex @code{indent}
4267 @cindex @code{linewidth}
4268
4269 The most basic settings influencing the spacing are @code{linewidth}
4270 and @code{indent}, both set in the @code{\paper} block.  They control
4271 the indentation of the first line of music, and the lengths of the
4272 lines.  If @code{linewidth} set to a negative value, a single
4273 unjustified line is produced.  A similar effect for scores that are
4274 longer than one line, can be produced by setting @code{raggedright} to
4275 true in the @code{\paper} block.
4276
4277 @cindex page layout
4278
4279 The page layout process happens outside lilypond. Ly2dvi sets page
4280 layout instructions. Ly2dvi responds to the following variables in the
4281 @code{\paper} block.  The variable @code{textheight} sets the total
4282 height of the music on each page.  The spacing between systems is
4283 controlled with @code{interscoreline}, its default is 16pt.
4284 The distance between the score lines will stretch in order to fill the
4285 full page @code{interscorelinefill} is set to a positive number.  In
4286 that case @code{interscoreline} specifies the minimum spacing.
4287
4288 @cindex @code{textheight}
4289 @cindex @code{interscoreline}
4290 @cindex @code{interscorelinefill}
4291
4292 Page breaks are normally computed by @TeX{}, so they are not under
4293 direct control of LilyPond.  However, you can insert a commands into
4294 the @file{.tex} output to instruct @TeX{} where to break pages. You
4295 can insert a @code{\newpage} from within lilypond. This is done by
4296 setting the @code{between-systems-strings} on the
4297 @internalsref{NonMusicalPaperColumn} where the system is broken.
4298
4299 @cindex paper size
4300 @cindex page size
4301 @cindex @code{papersize}
4302
4303 To change the paper size, you must first set the
4304 @code{papersize} paper variable variable.  Set it to
4305 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
4306 specification, you must set the font as described above.  If you want
4307 the default font, then use the 20 point font.
4308
4309 @example
4310         \paper@{ papersize = "a4" @}
4311         \include "paper16.ly"
4312 @end example
4313
4314 The file @code{paper16.ly}  will now include a file named @file{a4.ly}, which
4315 will set the paper variables @code{hsize} and @code{vsize} (used by
4316 Lilypond and @code{ly2dvi})
4317
4318
4319
4320
4321 @c . {Sound}
4322 @node Sound
4323 @section Sound
4324 @cindex Sound
4325
4326 LilyPond can produce MIDI output.  The performance lacks lots of
4327 interesting effects, such as swing, articulation, slurring, etc., but it
4328 is good enough for proof-hearing the music you have entered.  Ties,
4329 dynamics and tempo changes are interpreted.
4330
4331 Dynamic marks, crescendi and decrescendi translate into MIDI volume
4332 levels.  Dynamic marks translate to a fixed fraction of the available
4333 MIDI volume range, crescendi and decrescendi make the the volume vary
4334 linearly between their two extremities.  The fractions be adjusted by
4335 overriding the @code{absolute-volume-alist} defined in
4336 @file{scm/midi.scm}.
4337
4338 For each type of musical instrument (that MIDI supports), a volume range
4339 can be defined.  This gives you basic equalizer control, which can
4340 enhance the quality of the MIDI output remarkably.  You can add
4341 instruments and ranges or change the default settings by overriding the
4342 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
4343
4344 Both loudness controls are combined to produce the final  MIDI volume. 
4345
4346
4347
4348 @menu
4349 * MIDI block::                  
4350 * MIDI instrument names::       
4351 @end menu
4352
4353 @c .  {MIDI block}
4354 @node MIDI block
4355 @subsection MIDI block
4356 @cindex MIDI block
4357
4358
4359 The MIDI block is analogous to the paper block, but it is somewhat
4360 simpler.  The @code{\midi} block can contain:
4361 @cindex MIDI block
4362
4363 @itemize @bullet
4364   @item  a @code{\tempo} definition
4365   @item  context definitions
4366 @end itemize
4367
4368 Assignments in the @code{\midi} block are not allowed.
4369
4370
4371
4372 @cindex context definition
4373
4374 Context definitions follow precisely the same syntax as within the
4375 \paper block.  Translation modules for sound are called performers.
4376 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
4377
4378
4379 @node MIDI instrument names
4380 @subsection MIDI instrument names
4381
4382 @cindex instrument names
4383 @cindex @code{Staff.midiInstrument}
4384 @cindex @code{Staff.instrument}
4385
4386 The MIDI instrument name is set by the @code{Staff.midiInstrument}
4387 property or, if that property is not set, the @code{Staff.instrument}
4388 property.  The instrument name should be chosen from the list in
4389 @ref{MIDI instruments}.
4390
4391 @refbugs
4392
4393 If the selected string does not exactly match, then LilyPond uses the
4394 default (Grand Piano). It is not possible to select an instrument by
4395 number.
4396
4397