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