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