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