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