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