]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
Jurgen's patches, measure grouping stuff.
[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 #(ly: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 = #(ly: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 #(ly: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 #(ly: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 = #(ly: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 = #(ly: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 * * * *) = #(ly: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{(ly: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 * * * *) = #(ly: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 * * * *) = #(ly: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  \startTextSpan
1778  \stopTextSpan
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\startTextSpan b c a \stopTextSpan }
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 scripts
1924 @cindex superscript
1925 @cindex subscript
1926
1927 See also @seeinternals{Script} and @seeinternals{Fingering}.
1928
1929 @refbugs
1930
1931 All of these note ornaments appear in the printed output but have no
1932 effect on the MIDI rendering of the music.
1933
1934 Unfortunately, there is no support for adding fingering instructions or 
1935 ornaments to individual note heads. Some hacks exist, though. See
1936 @file{input/test/script-horizontal.ly}.
1937
1938
1939 @c .  {Text scripts}
1940 @node Text scripts
1941 @subsection Text scripts
1942 @cindex Text scripts
1943
1944 In addition, it is possible to place arbitrary strings of text or markup
1945 text (see @ref{Text markup}) above or below notes by using a string:
1946 @code{c^"text"}. 
1947
1948 By default, these indications do not influence the note spacing, but
1949 by using the command @code{\fatText}, the widths will be taken into
1950 account.
1951 @c
1952 @lilypond[fragment,singleline,verbatim] \relative c' {
1953 c4^"longtext" \fatText c4_"longlongtext" c4 }
1954 @end lilypond
1955
1956 It is possible to use @TeX{} commands in the strings, but this should be
1957 avoided because it makes it impossible for LilyPond to compute the
1958 exact length of the string, which may lead to collisions.  Also, @TeX{}
1959 commands won't work with direct PostScript output.
1960 @c (see @ref{PostScript output}).
1961
1962 Text scripts are created in form of @internalsref{TextScript} objects, in
1963 @internalsref{Voice} context. 
1964
1965 @ref{Text markup} describes how to change the font or access
1966 special symbols in text scripts.
1967
1968
1969 @c .   {Grace notes}
1970 @node Grace notes
1971 @subsection Grace notes
1972
1973
1974
1975 @cindex @code{\grace}
1976 @cindex ornaments
1977 @cindex grace notes
1978
1979 Grace notes are ornaments that are written out
1980 @lilypond[relative=2,verbatim,ifragment] c4 \grace c16 c4 \grace {
1981 [c16 d16] } c4
1982 @end lilypond
1983
1984 In normal notation, grace notes are supposed to take up no logical
1985 time in a measure. Such an idea is practical for normal notation, but
1986 is not strict enough to put it into a program. The model that LilyPond
1987 uses for grace notes internally is that all timing is done in two
1988 steps:
1989
1990 Every point in musical time consists of two rational numbers: one
1991 denotes the logical time, one denotes the grace timing. The above
1992 example is shown here with timing tuples.
1993
1994 @lilypond[]
1995 \score { \notes \relative c''{ 
1996   c4^"(0,0)"  \grace c16_" "_"(1/4,-1/16)"  c4^"(1/4,0)"  \grace {
1997   [c16_"(2/4,-1/8)"  d16^"(2/4,-1/16)" ] } c4_" "_"(2/4,0)"
1998   }
1999 \paper {  linewidth = 8.\cm }
2000 }
2001 @end lilypond
2002
2003 The advantage of this approach is that you can use almost any lilypond
2004 construction together with grace notes, for example slurs and clef
2005 changes may appear halfway in between grace notes:
2006
2007 @lilypond[relative=2,verbatim,fragment] 
2008   c4  \grace { [ c16 c, \clef bass c, b(] }  )c4 
2009 @end lilypond
2010
2011 The placement of these grace notes is synchronized between different
2012 staves, using this grace timing.
2013
2014 @lilypond[relative=2,verbatim,fragment] 
2015 < \context Staff = SA { e4 \grace { c16 d e f } e4 }
2016   \context Staff = SB { c4 \grace { g8 b } c4 } >
2017 @end lilypond
2018
2019
2020 Unbeamed eighth notes and shorter by default have a slash through the
2021 stem. This can be controlled with object property @code{stroke-style} of
2022 @internalsref{Stem}. The change in formatting is accomplished by
2023 inserting @code{\startGraceMusic} before handling the grace notes, and
2024 @code{\stopGraceMusic} after finishing the grace notes.
2025 You can add to these definitions to globally change grace note
2026 formatting. The standard definitions are in @file{ly/grace-init.ly}.
2027
2028 [TODO discuss Scheme functionality.]
2029
2030
2031 Notice how the @code{\override} is carefully matched with a @code{\revert}.
2032
2033 @cindex slash
2034 @cindex grace slash
2035
2036 @lilypond[fragment,verbatim]
2037 \relative c'' \context Voice {
2038   \grace c8 c4 \grace { [c16 c16] } c4
2039   \grace { 
2040     \property Voice.Stem \override #'stroke-style = #'() 
2041     c16 
2042     \property Voice.Stem \revert #'stroke-style
2043   } c4
2044 }
2045 @end lilypond
2046
2047
2048
2049 If you want to end a note with a grace note, then the standard trick
2050 is to put the grace notes before a phantom ``space note'', e.g.
2051 @lilypond[fragment,verbatim, relative=2]
2052 \context Voice {
2053     < { d1^\trill ( }
2054      { s2 \grace { [c16 d] } } >
2055    )c4
2056 }
2057 @end lilypond
2058
2059 A @code{\grace} section has some default values, and LilyPond will
2060 use those default values unless you specify otherwise inside the
2061 @code{\grace} section.  For example, if you specify \slurUp
2062 @emph{before} your @code{\grace} section, a slur which starts inside
2063 the @code{\grace} won't be forced up, even if the slur ends outside
2064 of the @code{\grace}.  Note the difference between the first and
2065 second bars in this example:
2066
2067 @lilypond[fragment,verbatim]
2068 \relative c'' \context Voice {
2069     \slurUp
2070     \grace {
2071         a4 ( }
2072     ) a4 a4 () a2
2073     \slurBoth
2074
2075     \grace {
2076         \slurUp
2077         a4 ( }
2078     ) a4 a4 () a2
2079     \slurBoth
2080
2081 }
2082 @end lilypond
2083
2084
2085 @refbugs
2086
2087 Grace notes can not be used in the smallest size (@file{paper11.ly}).
2088
2089 Grace note synchronization can also lead to surprises. Staff notation,
2090 such as key signatures, barlines, etc. are also synchronized. Take
2091 care when you mix staves with grace notes and staves without.
2092
2093 @lilypond[relative=2,verbatim,fragment]
2094 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
2095   \context Staff = SB { c4 \bar "|:"  d4 } >
2096 @end lilypond
2097
2098 Grace sections should only be used within sequential music
2099 expressions.  Nesting, juxtaposing, or ending sequential music with a
2100 grace section is not supported, and might produce crashes or other
2101 errors.
2102
2103
2104 @node Glissando 
2105 @subsection Glissando
2106 @cindex Glissando 
2107
2108 @cindex @code{\glissando}
2109
2110 A glissando line can be requested by attaching a @code{\glissando} to
2111 a note:
2112
2113 @lilypond[fragment,relative,verbatim]
2114   c'-\glissando c'
2115 @end lilypond
2116
2117 @refbugs
2118
2119 Printing of an additional text (such as @emph{gliss.}) must be done
2120 manually. See also @seeinternals{Glissando}.
2121
2122
2123
2124 @c .   {Dynamics}
2125 @node Dynamics
2126 @subsection Dynamics
2127 @cindex Dynamics
2128
2129
2130
2131 @cindex @code{\ppp}
2132 @cindex @code{\pp}
2133 @cindex @code{\p}
2134 @cindex @code{\mp}
2135 @cindex @code{\mf}
2136 @cindex @code{\f}
2137 @cindex @code{\ff}
2138 @cindex @code{\fff}
2139 @cindex @code{\ffff}
2140 @cindex @code{\fp}
2141 @cindex @code{\sf}
2142 @cindex @code{\sff}
2143 @cindex @code{\sp}
2144 @cindex @code{\spp}
2145 @cindex @code{\sfz}
2146 @cindex @code{\rfz}
2147
2148
2149 Absolute dynamic marks are specified using an identifier after a
2150 note: @code{c4-\ff}.  The available dynamic marks are: @code{\ppp},
2151 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
2152 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
2153 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
2154
2155 @lilypond[verbatim,singleline,fragment,relative]
2156   c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
2157   c2\sf c\rfz
2158 @end lilypond
2159
2160 @cindex @code{\cr}
2161 @cindex @code{\rc}
2162 @cindex @code{\decr}
2163 @cindex @code{\rced}
2164 @cindex @code{\<}
2165 @cindex @code{\>}
2166 @cindex @code{\"!}
2167
2168
2169 A crescendo mark is started with @code{\cr} and terminated with
2170 @code{\rc} (the textual reverse of @code{cr}).  A decrescendo mark is
2171 started with @code{\decr} and terminated with @code{\rced}.  There are
2172 also shorthands for these marks.  A crescendo can be started with
2173 @code{\<} and a decrescendo can be started with @code{\>}.  Either one
2174 can be terminated with @code{\!}.  Note that @code{\!}  must go before
2175 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
2176 after the last note.  Because these marks are bound to notes, if you
2177 want several marks during one note, you have to use spacer notes.
2178
2179 @lilypond[fragment,verbatim,center]
2180   c'' \< \! c''   d'' \decr e'' \rced 
2181   < f''1 { s4 s4 \< \! s4 \> \! s4 } >
2182 @end lilypond
2183
2184 You can also use a text saying @emph{cresc.} instead of hairpins. Here
2185 is an example how to do it:
2186
2187 @lilypond[fragment,relative=2,verbatim]
2188   c4 \cresc c4 \endcresc c4
2189 @end lilypond
2190
2191
2192 @cindex crescendo
2193 @cindex decrescendo
2194
2195 You can also supply your own texts:
2196 @lilypond[fragment,relative,verbatim]
2197   \context Voice {
2198     \property Voice.crescendoText = "cresc. poco"
2199     \property Voice.crescendoSpanner = #'dashed-line
2200     a'2\mf\< a a \!a 
2201   }
2202 @end lilypond
2203
2204 @cindex diminuendo
2205
2206 Dynamics are objects of @internalsref{DynamicText} and
2207 @internalsref{Hairpin}. Vertical positioning of these symbols is
2208 handled by the @internalsref{DynamicLineSpanner} object.  If you want to
2209 adjust padding or vertical direction of the dynamics, you must set
2210 properties for the @internalsref{DynamicLineSpanner} object. Predefined
2211 identifiers to set the vertical direction are \dynamicUp and
2212 \dynamicDown.
2213
2214 @cindex direction, of dynamics
2215 @cindex @code{\dynamicDown}
2216 @cindex @code{\dynamicUp}
2217
2218 @c .  {Repeats}
2219 @node Repeats
2220 @section Repeats
2221
2222
2223 @cindex repeats
2224 @cindex @code{\repeat}
2225
2226 To specify repeats, use the @code{\repeat} keyword.  Since repeats
2227 should work differently when played or printed, there are a few
2228 different variants of repeats.
2229
2230 @table @code
2231 @item unfold
2232 Repeated music is fully written (played) out.  Useful for MIDI
2233 output, and entering repetitive music.
2234
2235 @item volta
2236 This is the normal notation: Repeats are not written out, but
2237 alternative endings (voltas) are printed, left to right.
2238
2239 @item fold
2240 Alternative endings are written stacked. This has limited use but may be
2241 used to typeset two lines of lyrics in songs with repeats, see
2242 @file{input/star-spangled-banner.ly}.
2243
2244 @item tremolo
2245 Make tremolo beams.
2246
2247 @item percent
2248 Make beat or measure repeats. These look like percent signs.
2249
2250 @end table  
2251
2252 @menu
2253 * Repeat syntax::               
2254 * Repeats and MIDI::            
2255 * Manual repeat commands::      
2256 * Tremolo repeats::             
2257 * Tremolo subdivisions::        
2258 * Measure repeats::             
2259 @end menu
2260
2261 @node Repeat syntax
2262 @subsection Repeat syntax
2263
2264 The syntax for repeats is
2265
2266 @example
2267   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2268 @end example
2269
2270 If you have alternative endings, you may add
2271 @cindex @code{\alternative}
2272 @example
2273  \alternative @code{@{} @var{alternative1}
2274             @var{alternative2}
2275             @var{alternative3} @dots{} @code{@}}
2276 @end example
2277 where each @var{alternative} is a music expression.
2278
2279 Normal notation repeats are used like this:
2280 @lilypond[fragment,verbatim]
2281   c'1
2282   \repeat volta 2 { c'4 d' e' f' }
2283   \repeat volta 2 { f' e' d' c' }
2284 @end lilypond
2285
2286 With alternative endings:
2287 @lilypond[fragment,verbatim]
2288   c'1
2289   \repeat volta 2 {c'4 d' e' f'} 
2290   \alternative { {d'2 d'} {f' f} }
2291 @end lilypond
2292
2293 Folded repeats look like this:
2294
2295
2296 @lilypond[fragment,verbatim]
2297   c'1
2298   \repeat fold 2 {c'4 d' e' f'} 
2299   \alternative { {d'2 d'} {f' f} }
2300
2301 @end lilypond
2302
2303 If you don't give enough alternatives for all of the repeats, then
2304 the first alternative is assumed to be repeated often enough to equal
2305 the specified number of repeats.
2306
2307 @lilypond[fragment,verbatim]
2308 \context Staff {
2309   \relative c' {
2310     \partial 4
2311     \repeat volta 4 { e | c2 d2 | e2 f2 | }
2312     \alternative { { g4 g g } { a | a a a a | b2. } }
2313   }
2314 }
2315 @end lilypond
2316
2317 @node Repeats and MIDI
2318 @subsection Repeats and MIDI
2319
2320 @cindex expanding repeats
2321
2322 For instructions on how to unfoldi repeats for MIDI output, see
2323 the example file @file{input/test/unfold-all-repeats.ly}.
2324
2325
2326 @refbugs
2327
2328 Notice that timing information is not remembered at the start of an
2329 alternative, so you have to reset timing information after a repeat,
2330 e.g. using a bar-check (See @ref{Bar check}), setting
2331 @code{Score.measurePosition} or entering @code{\partial}.  Slurs or ties
2332 are also not repeated.
2333
2334 It is possible to nest @code{\repeat}s, although this probably is only
2335 meaningful for unfolded repeats.
2336
2337 Folded repeats offer little more over simultaneous music.
2338
2339 @node Manual repeat commands
2340 @subsection Manual repeat commands
2341
2342 @cindex @code{repeatCommands}
2343
2344 The property @code{repeatCommands} can be used to control the layout of
2345 repeats. Its value is a Scheme list of repeat commands, where each repeat
2346 command can be
2347
2348 @table @code
2349 @item 'start-repeat
2350  Print a |: bar line
2351 @item 'end-repeat
2352  Print a :| bar line
2353 @item (volta . @var{text})
2354  Print a volta bracket saying @var{text}.
2355 @item (volta . #f)
2356  Stop a running volta bracket
2357 @end table
2358
2359 @lilypond[verbatim, fragment]
2360  c''4
2361     \property Score.repeatCommands = #'((volta "93") end-repeat)
2362  c''4 c''4
2363     \property Score.repeatCommands = #'((volta #f))
2364  c''4 c''4
2365 @end lilypond
2366
2367
2368 Repeats brackets are @internalsref{VoltaBracket} objects.
2369
2370 @node Tremolo repeats
2371 @subsection Tremolo repeats
2372 @cindex tremolo beams
2373
2374 To place tremolo marks between notes, use @code{\repeat} with tremolo
2375 style.  
2376 @lilypond[verbatim,center,singleline]
2377 \score { 
2378   \context Voice \notes\relative c' {
2379     \repeat "tremolo" 8 { c16 d16 }
2380     \repeat "tremolo" 4 { c16 d16 }    
2381     \repeat "tremolo" 2 { c16 d16 }
2382     \repeat "tremolo" 4 c16
2383   }
2384 }
2385 @end lilypond
2386
2387 Tremolo beams are @internalsref{Beam} objects. Single stem tremolos are
2388 @internalsref{StemTremolo}. The single stem tremolo @emph{must} be
2389 entered without @code{@{} and @code{@}}.  
2390
2391 @refbugs
2392
2393 Only powers of two and undotted notes are supported repeat counts.
2394
2395 @node Tremolo subdivisions
2396 @subsection Tremolo subdivisions
2397 @cindex tremolo marks
2398 @cindex @code{tremoloFlags}
2399
2400 Tremolo marks can be printed on a single note by adding
2401 `@code{:}[@var{length}]' after the note.  The length must be at least 8.
2402 A @var{length} value of 8 gives one line across the note stem.  If the
2403 length is omitted, then then the last value (stored in
2404 @code{Voice.tremoloFlags}) is used.
2405
2406 @lilypond[verbatim,fragment,center]
2407   c'2:8 c':32 | c': c': |
2408 @end lilypond
2409
2410 @refbugs
2411
2412
2413 Tremolos in this style do not carry over into the MIDI output.
2414
2415
2416 @node Measure repeats
2417 @subsection Measure repeats
2418
2419 @cindex percent repeats
2420 @cindex measure repeats
2421
2422 In the @code{percent} style, a note pattern can be repeated. It is
2423 printed once, and then the pattern is replaced with a special sign.
2424 Patterns of a one and two measures are replaced by percent-like signs,
2425 patterns that divide the measure length are replaced by slashes.
2426
2427 @lilypond[verbatim,singleline]
2428  \context Voice { \repeat  "percent" 4  { c'4 }
2429     \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2430 }
2431 @end lilypond   
2432
2433 The signs are represented by these objects: @internalsref{RepeatSlash} and
2434 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2435
2436 @refbugs
2437
2438 You can not nest percent repeats, e.g. by filling in the first measure
2439 with slashes, and repeating that measure with percents.
2440
2441 @node Rhythmic music
2442 @section Rhythmic music
2443
2444 Sometimes you might want to show only the rhythm of a melody.  This can
2445 be done with the rhythmic staff. All pitches of notes on such a staff
2446 are squashed, and the  staff itself  looks has  a single staff line:
2447
2448 @lilypond[fragment,relative,verbatim]
2449   \context RhythmicStaff {
2450       \time 4/4
2451       c4 e8 f  g2 | r4 g r2 | g1:32 | r1 |
2452   }
2453 @end lilypond
2454
2455 @menu
2456 * Percussion staves::           
2457 @end menu
2458
2459 @node Percussion staves
2460 @subsection Percussion staves
2461 @cindex percussion
2462 @cindex drums
2463 To typeset more than one piece of percussion to be played by the same
2464 musician one typically uses a multiline staff where each staff
2465 position refers to a specific piece of percussion.
2466
2467 LilyPond is shipped with a bunch of scheme functions which allows you
2468 to do this fairly easily.
2469
2470 The system is based on the general midi drum-pitches.
2471 In order to use the drum pitches you include
2472 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2473 variable @code{drum-pitch-names} - which definition can be read in
2474 @file{scm/drums.scm}. You see that each piece of percussion has a full
2475 name and an abbreviated name - and you may freely select whether to
2476 refer to the full name or the abbreviation in your music definition.
2477
2478 To typeset the music on a staff you apply the scheme function
2479 @code{drums->paper} to the percussion music. This function takes a
2480 list of percussion instrument names, notehead scripts and staff
2481 positions (that is: pitches relative to the C-clef) and uses this to
2482 transform the input music by moving the pitch, changing the notehead
2483 and (optionally) adding a script:
2484 @lilypond[singleline,verbatim]
2485 \include "drumpitch-init.ly"
2486 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2487 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2488 \score {
2489     \apply #(drums->paper 'drums) \context Staff <
2490         \clef percussion
2491         \context Voice = up { \voiceOne \up }
2492         \context Voice = down { \voiceTwo \down }
2493     >
2494 }
2495
2496 @end lilypond
2497 In the above example the music was transformed using the list @code{'drums}.
2498 Currently the following lists are defined in @file{scm/drums.scm}:
2499 @table @code
2500 @item 'drums
2501 To typeset a typical drum kit on a five-line staff.
2502
2503 @lilypond[noindent]
2504 \include "drumpitch-init.ly"
2505 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2506     bd sn ss tomh tommh tomml toml tomfh tomfl }
2507 mus = \notes  { cymc cyms cymr hh hhc hho hhho hhp cb hc
2508     bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2509 \score {
2510     <
2511         \apply #(drums->paper 'drums) \context Staff <
2512             \clef percussion
2513             \mus
2514         >
2515         \context Lyrics \nam 
2516     >
2517     \paper {
2518         linewidth = 100.0\mm
2519         \translator {
2520             \StaffContext
2521             \remove Bar_engraver
2522             \remove Time_signature_engraver
2523             minimumVerticalExtent = #'(-4.0 . 5.0)
2524         }
2525         \translator {
2526             \VoiceContext
2527             \remove Stem_engraver
2528         }
2529    }   
2530 }
2531 @end lilypond
2532
2533 Notice that the scheme supports six different toms.
2534 If you are using fewer toms then you simply select the toms that produce
2535 the desired result - i.e. to get toms on the three middle lines you
2536 use @code{tommh}, @code{tomml} and @code{tomfh}.
2537
2538 Because the general midi contain no rimshots we use the sidestick for
2539 this purpose instead.
2540 @item 'timbales
2541 To typeset timbales on a two line staff.
2542 @lilypond[singleline]
2543 \include "drumpitch-init.ly"
2544 nam = \lyrics { timh ssh timl ssl cb }
2545 mus = \notes  { timh ssh timl ssl cb s16 }
2546 \score {
2547     <
2548         \apply #(drums->paper 'timbales) \context Staff <
2549             \clef percussion
2550             \mus
2551         >
2552         \context Lyrics \nam 
2553     >
2554     \paper {
2555         \translator {
2556             \StaffContext
2557             \remove Bar_engraver
2558             \remove Time_signature_engraver
2559             StaffSymbol \override #'line-count = #2
2560             StaffSymbol \override #'staff-space = #2
2561             minimumVerticalExtent = #'(-3.0 . 4.0)
2562         }
2563         \translator {
2564             \VoiceContext
2565             \remove Stem_engraver
2566         }
2567
2568     }   
2569 }
2570 @end lilypond
2571 @item 'congas
2572 To typeset congas on a two line staff.
2573 @lilypond[singleline]
2574 \include "drumpitch-init.ly"
2575 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2576 mus = \notes  { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2577 \score {
2578     <
2579         \apply #(drums->paper 'congas) \context Staff <
2580             \clef percussion
2581             \mus
2582         >
2583         \context Lyrics \nam 
2584     >
2585     \paper {
2586         \translator {
2587             \StaffContext
2588             \remove Bar_engraver
2589             \remove Time_signature_engraver
2590             StaffSymbol \override #'line-count = #2
2591             StaffSymbol \override #'staff-space = #2
2592             minimumVerticalExtent = #'(-3.0 . 4.0)
2593         }
2594         \translator {
2595             \VoiceContext
2596             \remove Stem_engraver
2597         }
2598     }   
2599 }
2600 @end lilypond
2601 @item 'bongos
2602 To typeset bongos on a two line staff.
2603 @lilypond[singleline]
2604 \include "drumpitch-init.ly"
2605 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2606 mus = \notes  { boh boho bohm ssh bol bolo bolm ssl s16 }
2607 \score {
2608     <
2609         \apply #(drums->paper 'bongos) \context Staff <
2610             \clef percussion
2611             \mus
2612         >
2613         \context Lyrics \nam 
2614     >
2615     \paper {
2616         \translator {
2617             \StaffContext
2618             \remove Bar_engraver
2619             \remove Time_signature_engraver
2620             StaffSymbol \override #'line-count = #2
2621             StaffSymbol \override #'staff-space = #2
2622             minimumVerticalExtent = #'(-3.0 . 4.0)
2623         }
2624         \translator {
2625             \VoiceContext
2626             \remove Stem_engraver
2627         }
2628     }   
2629 }
2630 @end lilypond
2631 @item 'percussion
2632 To typeset all kinds of simple percussion on one line staves.
2633 @lilypond[singleline]
2634 \include "drumpitch-init.ly"
2635 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2636 mus = \notes  { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2637 \score {
2638     <
2639         \apply #(drums->paper 'percussion) \context Staff <
2640             \clef percussion
2641             \mus
2642         >
2643         \context Lyrics \nam 
2644     >
2645     \paper {
2646         \translator {
2647             \StaffContext
2648             \remove Bar_engraver
2649             \remove Time_signature_engraver
2650             StaffSymbol \override #'line-count = #1
2651             minimumVerticalExtent = #'(-2.0 . 3.0)
2652         }
2653         \translator {
2654             \VoiceContext
2655             \remove Stem_engraver
2656         }
2657     }   
2658 }
2659 @end lilypond
2660 @end table
2661
2662 If you don't like any of the predefined lists you can define your own
2663 list at the top of your file:
2664
2665 @lilypond[singleline, verbatim]
2666 #(define mydrums `(
2667         (bassdrum     default   #f        ,(ly:make-pitch -1 2 0))
2668         (snare        default   #f        ,(ly:make-pitch 0 1 0))
2669         (hihat        cross     #f        ,(ly:make-pitch 0 5 0))
2670         (pedalhihat   xcircle   "stopped" ,(ly:make-pitch 0 5 0))
2671         (lowtom       diamond   #f        ,(ly:make-pitch -1 6 0))
2672 ))
2673 \include "drumpitch-init.ly"
2674 up = \notes { hh8 hh hh hh hhp4 hhp }
2675 down = \notes { bd4 sn bd toml8 toml }
2676 \score {    
2677     \apply #(drums->paper 'mydrums) \context Staff <
2678         \clef percussion
2679         \context Voice = up { \voiceOne \up }
2680         \context Voice = down { \voiceTwo \down }
2681     >
2682 }
2683 @end lilypond
2684
2685 To use a modified existing list instead of building your own from
2686 scratch you can append your modifications to the start of the existing
2687 list:
2688
2689 @example
2690 #(define mydrums (append `(
2691    (bassdrum default #f ,(ly:make-pitch -1 2 0))
2692    (lowtom   diamond #f ,(ly:make-pitch -1 6 0))
2693 ) drums ))
2694 @end example
2695
2696 @c FIXME: Too many levels of headers when using subsubsections.
2697 @c Perhaps junk subsection ``Percussion staves''
2698 @subsubsection Percussion staves with normal staves
2699 When you include @file{drumpitch-init.ly} then the default pitches
2700 are overridden so that you after the inclusion cannot use the common
2701 dutch pitch names anymore. Hence you might wan't to reinclude
2702 @file{nederlands.ly} after the drum-pattern-definitions:
2703 @lilypond[singleline,verbatim]
2704 \include "drumpitch-init.ly"
2705 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2706 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2707 \include "nederlands.ly"
2708 bass = \notes \transpose c c,, { a4. e8 r e g e }
2709 \score {
2710     <
2711         \apply #(drums->paper 'drums) \context Staff = drums <
2712             \clef percussion
2713             \context Voice = up { \voiceOne \up }
2714             \context Voice = down { \voiceTwo \down }
2715         >
2716         \context Staff = bass { \clef "F_8" \bass }
2717     >
2718 }
2719 @end lilypond
2720
2721 @subsubsection Percussion midi output
2722 In order to produce correct midi output you need to produce two score
2723 blocks - one for the paper and one for the midi.
2724 To use the percussion channel you set the property @code{instrument}
2725 to @code{'drums}. Because the drum-pitches themself are similar to the
2726 general midi pitches all you have to do is to insert the voices with
2727 none of the scheme functions to get the correct midi output:
2728
2729 @example
2730 \score @{    
2731     \apply #(drums->paper 'mydrums) \context Staff <
2732         \clef percussion
2733         \context Voice = up @{ \voiceOne \up @}
2734         \context Voice = down @{ \voiceTwo \down @}
2735     >
2736     \paper@{@}
2737 @}
2738 \score @{    
2739     \context Staff <
2740         \property Staff.instrument = #'drums
2741         \up \down
2742     >
2743     \midi@{@}
2744 @}
2745 @end example
2746
2747 @refbugs
2748
2749 This scheme is to be considered a temporary implementation. Even
2750 though the scheme will probably keep on working then the future might
2751 bring some other way of typesetting drums, and probably
2752 there will be made no great efforts in keeping things downwards
2753 compatible.
2754
2755 @c . {Piano music}
2756 @node Piano music
2757 @section Piano music
2758
2759 Piano music is an odd type of notation. Piano staves are two normal
2760 staves coupled with a brace.  The staves are largely independent, but
2761 sometimes voices can cross between the two staves.  The
2762 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2763 behavior.  In this section we discuss the @internalsref{PianoStaff} and some
2764 other pianistic peculiarities.
2765
2766
2767 @menu
2768 * Automatic staff changes::     
2769 * Manual staff switches::       
2770 * Pedals::                      
2771 * Arpeggio::                    
2772 * Voice follower lines::        
2773 @end menu 
2774
2775 @refbugs
2776
2777 There is no support for putting chords across staves.  You can get
2778 this result by increasing the length of the stem in the lower stave so
2779 it reaches the stem in the upper stave, or vice versa. An example is
2780 included with the distribution as @file{input/test/stem-cross-staff.ly}.
2781
2782 @cindex cross staff stem
2783 @cindex stem, cross staff
2784
2785
2786 @c fixme: should have hyperlinks as well.
2787
2788
2789
2790
2791 @c .   {Automatic staff changes}
2792 @node Automatic staff changes
2793 @subsection Automatic staff changes
2794 @cindex Automatic staff changes
2795
2796 Voices can switch automatically between the top and the bottom
2797 staff. The syntax for this is
2798 @example
2799         \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2800 @end example        
2801 The autochanger switches on basis of pitch (central C is the turning
2802 point), and it looks ahead skipping over rests to switch rests in
2803 advance. Here is a practical example:
2804         
2805 @lilypond[verbatim,singleline]
2806 \score { \notes \context PianoStaff <
2807   \context Staff = "up" {
2808     \autochange Staff \context Voice = VA < \relative c' {
2809        g4 a  b c d r4 a g } > }
2810   \context Staff = "down" {
2811        \clef bass
2812        s1*2
2813 } > }
2814 @end lilypond
2815 Spacer rests are used to prevent the bottom staff from
2816 terminating too soon.
2817
2818
2819 @node Manual staff switches
2820 @subsection Manual staff switches
2821
2822 @cindex manual staff switches
2823 @cindex staff switch, manual
2824
2825 Voices can be switched between staves manually, using the following command:
2826 @example
2827   \translator Staff = @var{staffname} @var{music}
2828 @end example
2829 The string @var{staffname} is the name of the staff. It switches the
2830 current voice from its current staff to the Staff called
2831 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2832 @code{"down"}.
2833
2834 @c .   {Pedals}
2835 @node Pedals
2836 @subsection Pedals
2837 @cindex Pedals
2838
2839 Piano pedal instruction can be expressed using 
2840 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2841 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2842
2843 The symbols that are printed can be modified by setting
2844 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2845 Sustain, Sostenuto or UnaCorda.  Refer to the generated documentation of
2846 @rgrob{SustainPedal}, for example, for more information.
2847
2848 Pedals can also be indicated by a sequence of brackets, by setting the 
2849 @code{pedal-type} property of SustainPedal objects: 
2850
2851 @lilypond[fragment,verbatim]
2852 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2853 c''4 \sustainDown d''4 e''4 a'4
2854 \sustainUp \sustainDown
2855  f'4 g'4 a'4 \sustainUp
2856 @end lilypond
2857
2858 A third style of pedal notation is a mixture of text and brackets,
2859 obtained by setting @code{pedal-type} to @code{mixed}:
2860
2861 @lilypond[fragment,verbatim]
2862 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2863 c''4 \sustainDown d''4 e''4 c'4
2864 \sustainUp \sustainDown
2865  f'4 g'4 a'4 \sustainUp
2866 @end lilypond
2867
2868 The default '*Ped' style for sustain and damper pedals corresponds to
2869 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2870 for a sostenuto pedal:
2871
2872 @lilypond[fragment,verbatim]
2873 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2874 @end lilypond
2875
2876 For fine-tuning of the appearance of a pedal bracket, the properties
2877 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2878 @code{PianoPedalBracket} objects (see the detailed documentation of
2879 @rgrob{PianoPedalBracket}) can be modified.  For example, the bracket
2880 may be extended to the end of the note head.
2881
2882 @lilypond[fragment,verbatim]
2883 \property Staff.PianoPedalBracket \override
2884    #'shorten-pair = #'(0 . -1.0)
2885 c''4 \sostenutoDown d''4 e''4 c'4
2886 f'4 g'4 a'4 \sostenutoUp
2887 @end lilypond
2888
2889 @node Arpeggio
2890 @subsection Arpeggio
2891 @cindex Arpeggio
2892
2893 @cindex broken arpeggio
2894 @cindex @code{\arpeggio}
2895
2896 You can specify an arpeggio sign on a chord by attaching an
2897 @code{\arpeggio} to a note of the chord.
2898
2899
2900 @lilypond[fragment,relative,verbatim]
2901   \context Voice <c\arpeggio e g c>
2902 @end lilypond
2903
2904 When an arpeggio crosses staves in piano music, you attach an arpeggio
2905 to the chords in both staves, and set
2906 @code{PianoStaff.connectArpeggios}.
2907
2908 @lilypond[fragment,relative,verbatim]
2909   \context PianoStaff <
2910     \property PianoStaff.connectArpeggios = ##t
2911     \context Voice = one  { <c'\arpeggio e g c> }
2912     \context Voice = other { \clef bass  <c,,\arpeggio e g>}
2913   >  
2914 @end lilypond
2915
2916 This command creates @internalsref{Arpeggio} objects.  Cross staff arpeggios
2917 are @code{PianoStaff.Arpeggio}.
2918
2919 To add an arrow head to explicitly specify the direction of the
2920 arpeggio, you should set the arpeggio object property
2921 @code{arpeggio-direction}.
2922
2923 @lilypond[fragment,relative,verbatim]
2924   \context Voice {
2925      \property Voice.Arpeggio \set #'arpeggio-direction = #1
2926      <c\arpeggio e g c>
2927      \property Voice.Arpeggio \set #'arpeggio-direction = #-1
2928      <c\arpeggio e g c>
2929   }
2930 @end lilypond
2931
2932 A square bracket on the left indicates that the player should not
2933 arpeggiate the chord. To draw these brackets, set the
2934 @code{molecule-callback} property of @code{Arpeggio} or
2935 @code{PianoStaff.Arpeggio} objects to @code{\arpeggioBracket}, and use
2936 @code{\arpeggio} statements within the chords as before.
2937
2938 @lilypond[fragment,relative,verbatim]
2939   \context PianoStaff <
2940     \property PianoStaff.connectArpeggios = ##t
2941     \property PianoStaff.Arpeggio \override
2942         #'molecule-callback = \arpeggioBracket
2943     \context Voice = one  { <c'\arpeggio e g c> }
2944     \context Voice = other { \clef bass  <c,,\arpeggio e g>}
2945   >  
2946 @end lilypond
2947
2948
2949 @refbugs
2950
2951 It is not possible to mix connected arpeggios and unconnected
2952 arpeggios in one PianoStaff at the same time.
2953
2954
2955
2956 @node  Voice follower lines
2957 @subsection Voice follower lines
2958
2959 @cindex follow voice
2960 @cindex staff switching
2961 @cindex cross staff
2962
2963 @cindex @code{followVoice}
2964
2965 Whenever a voice switches to another staff a line connecting the notes
2966 can be printed automatically. This is enabled if the property
2967 @code{PianoStaff.followVoice} is set to true:
2968
2969 @lilypond[fragment,relative,verbatim]
2970   \context PianoStaff <
2971     \property PianoStaff.followVoice = ##t
2972     \context Staff \context Voice {
2973       c1
2974       \translator Staff=two
2975       b2 a
2976     }
2977     \context Staff=two {\clef bass \skip 1*2 }
2978   >  
2979 @end lilypond
2980
2981 The associated object is @internalsref{VoiceFollower}.
2982
2983
2984 @node Tablatures
2985 @section Tablatures
2986
2987 Tablature notation is used for notating music for plucked string
2988 instruments.  It notates pitches not by using note heads, but by
2989 indicating on which string and fret a note must be played.  LilyPond
2990 offers limited support for tablature.
2991
2992 @menu
2993 * Tablatures basic::            
2994 * Non-guitar tablatures::       
2995 * Tablature in addition to normal staff::  
2996 @end menu
2997
2998 @node Tablatures basic
2999 @subsection Tablatures basic
3000 @cindex Tablatures basic
3001
3002 Tablature can be typeset with Lilypond by using the
3003 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
3004 tablature is a recent feature in Lilypond, most of the guitar special
3005 effects such as bend are not yet supported.
3006
3007 With the @internalsref{TabStaff}, the string number associated to a note
3008 is given as a backslash followed by the string number, e.g. @code{c4\3} for a C
3009 quarter on the third string. By default, string 1 is the highest one, and the
3010 tuning defaults to the standard guitar tuning (with 6 strings).
3011
3012 @lilypond[fragment,verbatim]
3013   \context TabStaff <
3014     \notes {
3015       a,4\5 c'\2 a\3 e'\1
3016       e\4 c'\2 a\3 e'\1
3017     }
3018   >  
3019 @end lilypond
3020
3021 If you do not specify a string number then lilypond automatically selects one.
3022 The selection is controlled by the translator property @code{minimumFret}. -- LilyPond
3023 simply selects the first string that does not give a fret number less than
3024 @code{minimumFret}. Default is 0.
3025
3026 Notice that LilyPond does not handle chords in any special way, and hence
3027 the automatic string selector may easily select the same string to two notes in a chord.
3028
3029 @example
3030 e8 fis gis a b cis' dis' e'
3031 \property TabStaff.minimumFret = #8
3032 e8 fis gis a b cis' dis' e'
3033 @end example
3034 @lilypond[noindent,noquote]
3035 frag = \notes {
3036     \key e \major
3037     e8 fis gis a b cis' dis' e'
3038     \property TabStaff.minimumFret = #8
3039     e8 fis gis a b cis' dis' e'
3040 }
3041 \score {
3042   \context StaffGroup <
3043     \context Staff { \clef "G_8" \frag }
3044     \context TabStaff { \frag }
3045   >
3046 }
3047 @end lilypond
3048
3049 @node Non-guitar tablatures
3050 @subsection Non-guitar tablatures
3051 @cindex Non-guitar tablatures
3052
3053 There are many ways to customize Lilypond tablatures.
3054
3055 First you can change the number of strings, by setting the number of
3056 lines in the @internalsref{TabStaff} (the @code{line-count} property
3057 of TabStaff can only be changed using @code{\outputproperty}, for more
3058 information, see @ref{Tuning per object}.  You can change the strings
3059 tuning. A string tuning is given as a Scheme list with one integer
3060 number for each string, the number being the pitch of an open string.
3061
3062 (The numbers specified for stringTuning are the numbers of semitons
3063 to subtract --- or add --- starting the specified pitch by default
3064 middle C, in string order: thus the notes are e, a, d & g)
3065
3066 @lilypond[fragment,verbatim]
3067   \context TabStaff <
3068
3069     \outputproperty #(make-type-checker 'staff-symbol-interface)
3070                     #'line-count = #4
3071     \property TabStaff.stringTunings =  #'(-5 -10 -15 -20)
3072     
3073     \notes {
3074       a,4 c' a e' e c' a e'
3075     }
3076
3077   > 
3078 @end lilypond
3079
3080 Finally, it is possible to change the Scheme function to format the
3081 tablature note text. The default is @var{fret-number-tablature-format},
3082 which uses the fret number, but for some instruments that may not use
3083 this notation, just create your own tablature-format function. This
3084 function takes three argument: the string number, the string tuning and
3085 the note pitch.
3086
3087
3088 @node Tablature in addition to normal staff
3089 @subsection Tablature in addition to normal staff
3090 @cindex Tablature in addition to normal staff
3091
3092 It is possible to typeset both tablature and a "normal" staff, as
3093 commonly done in many parts.
3094
3095 A common trick for that is to put the notes in a variables, and to hide
3096 the fingering information (which correspond to the string number) for
3097 the standard staff.
3098
3099 @c FIXME
3100 @c @lily pond[verbatim]
3101 @example
3102   part = \notes @{
3103     a,4-2 c'-5 a-4 e'-6
3104     e-3 c'-5 a-4 e'-6
3105   @}
3106   \score @{
3107     \context StaffGroup <
3108       \context Staff <
3109         % Hide fingering number
3110         \property Staff.Fingering \override #'transparent = ##t
3111
3112         \part
3113       >
3114       \context TabStaff <
3115         \property Staff.Stem \override #'direction = #1
3116
3117         \part
3118       >
3119     >
3120   @}
3121 @end example
3122 @c @end lilypond
3123
3124 @c . {Chords}
3125 @node Chords
3126 @section Chords
3127 @cindex Chords
3128
3129 LilyPond has support for both entering and printing chords. 
3130 @lilypond[verbatim,singleline]
3131 twoWays = \notes \transpose c c' {
3132   \chords {
3133     c1 f:sus4 bes/f
3134   }
3135   <c e g>
3136   <f bes c'>
3137   <f bes d'>
3138   }
3139
3140 \score {
3141    < \context ChordNames \twoWays
3142      \context Voice \twoWays > }
3143 @end lilypond
3144
3145 This example also shows that the chord printing routines do not try to
3146 be intelligent. If you enter @code{f bes d}, it does not interpret
3147 this as an inversion.
3148
3149 As you can see chords really are a set of pitches. They are internally
3150 stored as simultaneous music expressions. This means you can enter
3151 chords by name and print them as notes, enter them as notes and print
3152 them as chord names, or (the most common case) enter them by name, and
3153 print them as name.
3154
3155 @menu
3156 * Chords mode::                 
3157 * Printing named chords::       
3158 @end menu
3159
3160 @c .  {Chords mode}
3161 @node Chords mode
3162 @subsection Chords mode
3163 @cindex Chords mode
3164
3165 Chord mode is a mode where you can input sets of pitches using common
3166 names.  It is introduced by the keyword @code{\chords}.  It is similar
3167 to note mode, but words are also looked up in a chord modifier table
3168 (containing @code{maj}, @code{dim}, etc). Dashes and carets are used
3169 to indicate chord additions and subtractions, so articulation scripts
3170 can not be entered in Chord mode.
3171
3172 Throughout these examples, chords have been shifted around the staff
3173 using @code{\transpose}.
3174
3175 @lilypond[fragment,verbatim]
3176 \transpose c c' {
3177   \chords {
3178     c1  c:3-       c:7     c:8
3179     c:9 c:9-.5+.7+ c:3-.5- 
3180   }
3181 }
3182 @end lilypond
3183
3184 @cindex @code{aug}
3185 @cindex @code{dim}
3186 @cindex @code{maj}
3187 @cindex @code{sus}
3188
3189 The second type of modifier that may appear after the @code{:} is a
3190 named modifier.  Named modifiers are listed in the file
3191 @file{chord-modifiers.ly}.  The available modifiers are @code{m} and
3192 @code{min} which lower the 3rd half a step, `@code{aug}' which
3193 raises the 5th, `@code{dim}' which lowers the 5th,
3194 `@code{maj}' which adds a raised 7th, and `@code{sus}'
3195 which replaces the 5th with a 4th.
3196
3197 @lilypond[fragment,verbatim]
3198 \transpose c c' {
3199   \chords {
3200     c1:m c:min7 c:maj c:aug c:dim c:sus
3201   }
3202 }
3203 @end lilypond
3204  
3205
3206 Chord subtractions are used to eliminate notes from a chord.  The
3207 notes to be subtracted are listed after a @code{^} character,
3208 separated by dots.
3209
3210 @lilypond[fragment,verbatim,center]
3211   \transpose c c' {
3212     \chords {
3213       c1^3 c:7^5.3 c:8^7
3214     }
3215   }
3216 @end lilypond 
3217 @cindex @code{/}
3218
3219 Chord inversions can be specified by appending `@code{/}' and the name
3220 of a single note to a chord.  In a chord inversion, the inverted note is
3221 transposed down until it is the lowest note in the chord.  If the note
3222 is not in the chord, a warning will be printed.
3223
3224 @lilypond[fragment,verbatim,center]
3225   \transpose c c'' {
3226     \chords {
3227       c1 c/e c/g c:7/e
3228     }
3229   }
3230
3231 @end lilypond 
3232 @cindex @code{/+}
3233
3234 Bass notes can be added by `@code{/+}' and
3235 the name of a single note to a chord.  This has the effect of
3236 adding the specified note to the chord, lowered by an octave,
3237 so it becomes the lowest note in the chord.
3238
3239 @lilypond[fragment,verbatim,center]
3240   \transpose c c'' {
3241     \chords {
3242       c1 c/+c c/+g c:7/+b
3243     }
3244   }
3245
3246 @end lilypond 
3247
3248 The formal syntax for named chords is as follows:
3249 @example
3250   @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
3251 @end example
3252
3253 @var{tonic} should be the tonic note of the chord, and @var{duration} is
3254 the chord duration in the usual notation.  There are two kinds of
3255 modifiers.  One type is formed by @emph{chord additions}. Additions are
3256 obtained by listing intervals separated by dots.  An interval is written
3257 by its number with an optional @code{+} or @code{-} to indicate raising
3258 or lowering by half a step.  Chord additions have two effects: they adds
3259 the specified interval and all lower odd numbered intervals to the
3260 chord, and they may lower or raise the specified interval.
3261
3262
3263 @refbugs
3264
3265 Implementation details are gory. For example @code{c:4} not only adds
3266 a fourth, but also removes the third.
3267
3268
3269 @c .  {Printing named chords}
3270 @node Printing named chords
3271 @subsection Printing named chords
3272
3273 @cindex printing chord names
3274 @cindex chord names
3275 @cindex chords
3276
3277 For displaying printed chord names, use the @internalsref{ChordNames} context.
3278 The chords may be entered either using the notation described above, or
3279 directly using simultaneous music.
3280
3281 @lilypond[verbatim,singleline]
3282 scheme = \notes {
3283   \chords {a1 b c} <d f g>  <e g b>
3284 }
3285 \score {
3286   \notes<
3287     \context ChordNames \scheme
3288     \context Staff \transpose c c' \scheme
3289   >
3290 }
3291 @end lilypond
3292
3293 You can make the chord changes stand out by setting
3294 @code{ChordNames.chordChanges} to true.  This will only display chord
3295 names when there's a change in the chords scheme and at the start of a
3296 new line.
3297
3298 @lilypond[verbatim]
3299 scheme = \chords {
3300   c1:m c:m \break c:m c:m d
3301 }
3302 \score {
3303   \notes <
3304     \context ChordNames {
3305         \property ChordNames.chordChanges = ##t
3306         \scheme }
3307     \context Staff \transpose c c' \scheme
3308   >
3309 \paper{linewidth= 9.\cm}
3310 }
3311 @end lilypond
3312
3313 LilyPond examines chords specified as lists of notes to determine a name
3314 to give the chord. LilyPond will not try to identify chord inversions or
3315 an added bass note, which may result in strange chord names when chords
3316 are entered as a list of pitches:
3317
3318 @lilypond[verbatim,center,singleline]
3319 scheme = \notes {
3320   <c'1 e' g'>
3321   <e' g' c''>
3322   <e e' g' c''>
3323 }
3324
3325 \score {
3326   <
3327     \context ChordNames \scheme
3328     \context Staff \scheme
3329   >
3330 }
3331 @end lilypond
3332
3333
3334 By default, a chord name system proposed by Harald Banter (See
3335 @ref{Literature}) is used. The system is very regular and predictable.
3336 Typical American style chord names may be selected by setting the
3337 @code{style} property of the @code{ChordNames.ChordName} object to
3338 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
3339
3340 Routines that determine the names to be printed are written in Scheme,
3341 and may be customized by the user.  The code can be found in
3342 @file{scm/chord-name.scm}.  Here's an example showing the differences in
3343 chord name styles:
3344
3345 @c too long?
3346 @c maybe just junk verbatim option?
3347 @lilypond[verbatim,singleline,noquote]
3348 scheme = \chords {
3349   c1 c:5^3 c:4^3 c:5+
3350   c:m7+ c:m5-.7
3351   c:5-.7 c:5+.7
3352   c:9^7
3353 }
3354
3355 \score {
3356   \notes <
3357     \context ChordNames = banter \scheme
3358     \context ChordNames = american {
3359       \property ChordNames.ChordName \override
3360         #'style = #'american \scheme }
3361     \context ChordNames = jazz {
3362       \property ChordNames.ChordName \override
3363         #'style = #'jazz \scheme }
3364     \context Staff \transpose c c' \scheme
3365   >
3366 }
3367 @end lilypond
3368
3369
3370 @node Writing parts
3371 @section Writing parts
3372
3373 Orchestral music involves some special notation, both in the full score,
3374 as in the individual parts. This section explains how to tackle common
3375 problems in orchestral music.
3376
3377
3378 @c .  {Transpose}
3379 @menu
3380 * Rehearsal marks::             
3381 * Bar numbers::                 
3382 * Instrument names::            
3383 * Transpose::                   
3384 * Multi measure rests::         
3385 * Automatic part combining::    
3386 * Hara kiri staves::            
3387 * Sound output for transposing instruments::  
3388 @end menu
3389
3390 @c .   {Rehearsal marks}
3391 @node Rehearsal marks
3392 @subsection Rehearsal marks
3393 @cindex Rehearsal marks
3394 @cindex mark
3395 @cindex @code{\mark}
3396
3397 To print a  rehearsal mark, use the @code{\mark} command. 
3398 @lilypond[fragment,verbatim]
3399 \relative c'' {
3400   c1 \mark "A"
3401   c1 \mark \default
3402   c1 \mark \default 
3403   c1 \mark "12"
3404   c1 \mark \default
3405   c1
3406 }
3407 @end lilypond
3408
3409 As you can see, the mark is incremented automatically if you use
3410 @code{\mark \default}. The value to use is stored in the property
3411 @code{rehearsalMark} is used and automatically incremented.  The object
3412 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3413 @code{input/test/boxed-molecule.ly} if you need boxes around the
3414 marks.
3415
3416 The @code{\mark} command can also be used to put signs like coda,
3417 segno and fermatas on a barline.  The trick is to use the text markup
3418 mechanism to access the fermata symbol.
3419 @lilypond[fragment,verbatim,relative=1]
3420   c1 \mark #'(music "scripts-ufermata") 
3421   c1
3422 @end lilypond
3423
3424 The problem is that marks that occur at a line break are typeset only
3425 at the beginning of the next line, opposite to what you want for the
3426 fermata. This can be corrected by the following property setting
3427 @example
3428 \property Score.RehearsalMark \override
3429   #'visibility-lambda = #begin-of-line-invisible
3430 @end example
3431
3432 @cindex fermatas
3433 @cindex coda
3434 @cindex segno
3435 @cindex barlines, putting symbols on 
3436
3437
3438 @node Bar numbers
3439 @subsection Bar numbers
3440
3441
3442 @cindex bar numbers
3443 @cindex measure numbers
3444 @cindex currentBarNumber
3445
3446 Bar numbers are printed by default at the start of the line.  The
3447 number itself is a property that can be set by modifying the
3448 @code{currentBarNumber} property, although that is usually not
3449 necessary, i.e.
3450 @example
3451   \property Score.currentBarNumber = #217
3452 @end example
3453
3454 To typeset Bar Numbers at regular intervals instead of at the beginning of each line,
3455 you need to change the grob property @code{break-visibility} as well as the translator
3456 property @code{barNumberVisibility}, as illustrated in the following example which also
3457 adds a box around the bar numbers:
3458 @example
3459 \property Score.BarNumber \override #'break-visibility =
3460   #end-of-line-invisible
3461 \property Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
3462 \property Score.BarNumber \override #'molecule-callback =
3463   #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule)
3464 \property Score.BarNumber \override #'font-relative-size = #0
3465 @end example
3466 @lilypond[noindent,noquote]
3467 \score {
3468     \context Staff \notes \transpose c c'' {
3469         \property Score.BarNumber \override #'break-visibility = #end-of-line-invisible
3470         \property Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
3471         \property Score.BarNumber \override #'molecule-callback =
3472         #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule)
3473         \property Score.BarNumber \override #'font-relative-size = #0
3474         
3475         \repeat unfold 16 c1 \bar "|."
3476     }
3477 }
3478 @end lilypond
3479
3480 See also @seeinternals{BarNumber}.
3481
3482 @refbugs
3483
3484 Barnumbers can collide with the StaffGroup, if there is one at the
3485 top. To solve this, You have to twiddle with the
3486 @internalsref{padding} property of @internalsref{BarNumber} if your
3487 score starts with a @internalsref{StaffGroup}.
3488
3489 @node Instrument names
3490 @subsection Instrument names
3491
3492 In scores, the instrument name is printed before the staff. This can
3493 be done by setting @code{Staff.instrument} and
3494 @code{Staff.instr}. This will print a string before the start of the
3495 staff. For the first start, @code{instrument} is used, for the next
3496 ones @code{instr} is used.
3497
3498 @lilypond[verbatim,singleline]
3499   \property Staff.instrument = "ploink " { c''4 }  
3500 @end lilypond
3501
3502 You can also use markup texts to construct more complicated instrument
3503 names:
3504
3505
3506 @lilypond[verbatim,singleline]
3507 #(define text-flat
3508   '((font-relative-size . -2 ) (music "accidentals--1")))
3509
3510 \score { \notes {
3511   \property Staff.instrument = #`((kern . 0.5) (lines
3512     "2 Clarinetti" (columns "     (B" ,text-flat ")")))
3513     c'' 4 }
3514 }
3515 @end lilypond
3516
3517
3518 @refbugs
3519
3520 When you put a name on a grand staff or piano staff the width of the
3521 brace is not taken into account. You must add extra spaces to the end of
3522 the name to avoid a collision.
3523
3524 @node Transpose
3525 @subsection Transpose
3526 @cindex Transpose
3527 @cindex transposition of pitches
3528 @cindex @code{\transpose}
3529
3530 A music expression can be transposed with @code{\transpose}.  The syntax
3531 is
3532 @example
3533   \transpose @var{from} @var{to} @var{musicexpr}
3534 @end example
3535
3536 This means that @var{musicexpr} is transposed to by the interval
3537 between @var{from} is @var{to}.
3538
3539 @code{\transpose} distinguishes between enharmonic pitches: both
3540 @code{\transpose c cis} or @code{\transpose c des} will transpose up
3541 half a tone.  The first version will print sharps and the second
3542 version will print flats.
3543
3544 @lilypond[singleline, verbatim]
3545 mus =\notes { \key d \major cis d fis g }
3546 \score { \notes \context Staff {
3547   \clef "F" \mus
3548   \clef "G"
3549   \transpose c g' \mus
3550   \transpose c f' \mus
3551 }}
3552 @end lilypond
3553
3554 If you want to use both @code{\transpose} and @code{\relative}, then
3555 you must use @code{\transpose} first.  @code{\relative} will have no
3556 effect music that appears inside a @code{\transpose}.
3557
3558 @c .  {Multi measure rests}
3559 @node  Multi measure rests
3560 @subsection Multi measure rests
3561 @cindex Multi measure rests
3562
3563 @cindex @code{R}
3564
3565 Multi measure rests are entered using `@code{R}'. It is specifically
3566 meant for full bar rests and for entering parts: the rest can expand to
3567 fill a score with 
3568 rests, or it can be printed as a single multimeasure rest This expansion
3569 is controlled by the property @code{Score.skipBars}. If this is set to true,
3570 Lily will not expand empty measures, and the appropriate number is added
3571 automatically.
3572
3573 @lilypond[fragment,verbatim]
3574  \time 4/4 r1 | R1 | R1*2
3575  \property Score.skipBars = ##t R1*17  R1*4
3576 @end lilypond
3577
3578 The @code{1} in @code{R1} is similar to the duration notation used for
3579 notes. Hence, for time signatures other than 4/4, you must enter other
3580 durations.  This can be done with augmentation dots, or with
3581 fractions:
3582
3583 @lilypond[fragment,verbatim]
3584  \property Score.skipBars = ##t
3585  \time 3/4
3586   R2. | R2.*2
3587  \time 13/8
3588  R1*13/8
3589  R1*13/8*12
3590 @end lilypond
3591 Notice that a @code{R} spanning a single measure is printed as a whole
3592 rest centered in the measure, regardless of the time signature.
3593
3594 [ add note about breves.]
3595  
3596
3597 @cindex whole rests for a full measure 
3598
3599 The object for this object is @internalsref{MultiMeasureRest}.
3600
3601 @refbugs
3602
3603 Currently, there is no way to automatically condense multiple rests
3604 into a single multimeasure rest. Multi measure rests do not take part
3605 in rest collisions. There is no way to put texts centered on
3606 multi-measure rests.
3607
3608 @cindex condensing rests
3609
3610 @node Automatic part combining
3611 @subsection Automatic part combining
3612 @cindex automatic part combining
3613 @cindex part combiner
3614
3615
3616 Automatic part combining is used to merge two parts of music onto a
3617 staff in an intelligent way.  It is aimed primarily at typesetting
3618 orchestral scores.  When the two parts are identical for a period of
3619 time, only one is shown.  In places where the two parts differ, they
3620 are typeset as separate voices, and stem directions are set
3621 automatically.  Also, solo and @emph{a due} parts can be identified
3622 and marked.
3623
3624 The syntax for part combining is
3625
3626 @example
3627   \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3628 @end example
3629 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3630 combined into one context of type @var{context}.  The music expressions
3631 must be interpreted by contexts whose names should start with @code{one}
3632 and @code{two}.
3633
3634 The most useful function of the part combiner is to combine parts into
3635 one voice, as common for wind parts in orchestral scores:
3636
3637 @lilypond[verbatim,singleline,fragment]
3638   \context Staff <
3639     \context Voice=one \partcombine Voice
3640       \context Thread=one \relative c'' {
3641         g a () b r
3642       }
3643       \context Thread=two \relative c'' {
3644         g r4 r f
3645       }
3646   >
3647 @end lilypond
3648
3649 Notice that the first @code{g} appears only once, although it was
3650 specified twice (once in each part).  Stem, slur and tie directions are
3651 set automatically, depending whether there is a solo or unisono. The
3652 first part (with context called @code{one}) always gets up stems, and
3653 `solo', while the second (called @code{two}) always gets down stems and
3654 `Solo II'.
3655
3656 If you just want the merging parts, and not the textual markings, you
3657 may set the property @var{soloADue} to false.
3658
3659 @lilypond[verbatim,singleline,fragment]
3660   \context Staff <
3661     \property Staff.soloADue = ##f
3662     \context Voice=one \partcombine Voice
3663       \context Thread=one \relative c'' {
3664         b4 a c g
3665       }
3666       \context Thread=two \relative c'' {
3667         d,2 a4 g'
3668       }
3669   >
3670 @end lilypond
3671
3672 There are a number of other properties that you can use to tweak the
3673 behavior of part combining, refer to the automatically generated
3674 documentation of @reng{Thread_devnull_engraver} and
3675 @reng{Voice_devnull_engraver}. Look at the documentation of the
3676 responsible engravers, @code{Thread_devnull_engraver},
3677 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3678
3679 @refbugs
3680
3681 In @code{soloADue} mode, when the two voices play the same notes on and
3682 off, the part combiner may typeset @code{a2} more than once in a
3683 measure.
3684
3685 @lilypond[fragment,singleline]
3686   \context Staff <
3687     \context Voice=one \partcombine Voice
3688       \context Thread=one \relative c'' {
3689         c b c b c a c a
3690       }
3691       \context Thread=two \relative c'' {
3692         b b b b f a f a
3693       }
3694   >
3695 @end lilypond
3696
3697 @cindex @code{Thread_devnull_engraver}
3698 @cindex @code{Voice_engraver}
3699 @cindex @code{A2_engraver}
3700
3701 @node Hara kiri staves
3702 @subsection Hara kiri staves
3703
3704 In orchestral scores, staff lines that only have rests are usually removed.
3705 This saves some space.  LilyPond also supports this through the hara
3706 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3707 the Japanese Samourai warriors.} staff. This staff commits suicide when
3708 it finds itself to be empty after the line-breaking process.  It will
3709 not disappear when it contains normal rests, you must use multi measure
3710 rests.
3711
3712 The hara kiri staff is specialized version of the @internalsref{Staff}
3713 context. It is available as the context identifier
3714 @code{\HaraKiriStaffContext}.  Observe how the second staff in this
3715 example disappears in the second line.
3716
3717 @lilypond[verbatim]
3718 \score  {
3719   \notes \relative c' <
3720     \context Staff = SA { e4 f g a \break c1 }
3721     \context Staff = SB { c4 d e f \break R1 }
3722   >
3723   \paper {
3724     linewidth = 6.\cm 
3725     \translator { \HaraKiriStaffContext }
3726   }
3727 }
3728 @end lilypond
3729
3730
3731 @node Sound output for transposing instruments
3732 @subsection Sound output for transposing instruments
3733
3734 When you want to make a MIDI file from a score containing transposed
3735 and untransposed instruments, you have to instruct LilyPond the pitch
3736 offset (in semitones) for the transposed instruments. This is done
3737 using the @code{transposing} property. It does not affect printed
3738 output.
3739
3740 @cindex @code{transposing}
3741
3742 @example
3743         \property Staff.instrument = #"Cl. in B-flat"
3744         \property Staff.transposing = #-2
3745 @end example
3746
3747
3748
3749 @c . {Custodes}
3750 @node Ancient notation 
3751 @section Ancient notation
3752
3753 @cindex Vaticana, Editio
3754 @cindex Medicaea, Editio
3755 @cindex hufnagel
3756 @cindex Petrucci
3757 @cindex mensural
3758
3759 @menu
3760 * Ancient note heads::          
3761 * Ancient clefs ::              
3762 * Custodes::                    
3763 * Ligatures::                   
3764 * Figured bass::                
3765 @end menu
3766
3767
3768 @node Ancient note heads
3769 @subsection Ancient note heads
3770
3771 To get a longa note head, you have to use mensural note heads. This
3772 is accomplished by setting the @code{style} property of the
3773 NoteHead object to @code{mensural}. There is also a note head style
3774 @code{baroque} which gives mensural note heads for @code{\longa} and
3775 @code{\breve} but standard note heads for shorter notes.
3776
3777 @lilypond[fragment,singleline,verbatim]
3778  \property Voice.NoteHead \set #'style = #'mensural
3779  a'\longa
3780 @end lilypond
3781
3782 @node Ancient clefs 
3783 @subsection Ancient clefs
3784
3785 LilyPond supports a variety of clefs, many of them ancient.
3786
3787 For modern clefs, see section @ref{Clef}.  For the percussion clef, see
3788 section @ref{Percussion staves}.  For the @code{TAB} clef, see section
3789 @ref{Tablatures}.
3790
3791 The following table shows all ancient clefs that are supported via the
3792 @code{\clef} command.  Some of the clefs use the same glyph, but differ
3793 only with respect to the line they are printed on.  In such cases, a
3794 trailing number in the name is used to enumerate these clefs.  Still,
3795 you can manually force a clef glyph to be typeset on an arbitrary line,
3796 as described in section @ref{Clef}.  The note printed to the right side
3797 of each clef denotes the @code{c'} with respect to the clef.
3798
3799 @table @code
3800
3801 @c --- This should go somewhere else: ---
3802 @c @item modern style G clef (glyph: @code{clefs-G})
3803 @c
3804 @c Supported clefs:
3805 @c @code{treble}, @code{violin}, @code{G}, @code{G2}, @code{french}
3806 @c
3807 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "G" c'}
3808 @c
3809 @c @item modern style F clef (glyph: @code{clefs-F})
3810 @c
3811 @c Supported clefs:
3812 @c @code{varbaritone}, @code{bass}, @code{F}, @code{subbass}
3813 @c
3814 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "F" c'}
3815 @c
3816 @c @item modern style C clef (glyph: @code{clefs-C})
3817 @c
3818 @c Supported clefs:
3819 @c @code{soprano}, @code{mezzosoprano}, @code{alto}, @code{C},
3820 @c @code{tenor}, @code{baritone}
3821 @c
3822 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "C" c'}
3823
3824 @item modern style mensural C clef (glyph: @code{clefs-neo_mensural_c'})
3825
3826 Supported clefs:
3827 @code{neo_mensural_c1}, @code{neo_mensural_c2},
3828 @code{neo_mensural_c3}, @code{neo_mensural_c4}
3829
3830 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "neo_mensural_c2" c'}
3831
3832 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c1})
3833
3834 Supported clefs:
3835 @code{petrucci_c1}
3836 for 1st staffline
3837
3838 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c1" c'}
3839
3840 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c2})
3841
3842 Supported clefs:
3843 @code{petrucci_c2}
3844 for 2nd staffline
3845
3846 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c2" c'}
3847
3848 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c3})
3849
3850 Supported clefs:
3851 @code{petrucci_c3}
3852 for 3rd staffline
3853
3854 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c3" c'}
3855
3856 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c4})
3857
3858 Supported clefs:
3859 @code{petrucci_c4}
3860 for 4th staffline
3861
3862 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c4" c'}
3863
3864 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c5})
3865
3866 Supported clefs:
3867 @code{petrucci_c5}
3868 for 5th staffline
3869
3870 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c5" c'}
3871
3872 @item petrucci style mensural F clef (glyph: @code{clefs-petrucci_f})
3873
3874 Supported clefs:
3875 @code{petrucci_f}
3876
3877 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_f" c'}
3878
3879 @item petrucci style mensural G clef (glyph: @code{clefs-petrucci_g})
3880
3881 Supported clefs:
3882 @code{petrucci_g}
3883
3884 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_g" c'}
3885
3886 @item historic style mensural C clef (glyph: @code{clefs-mensural_c'})
3887
3888 Supported clefs:
3889 @code{mensural_c1}, @code{mensural_c2}, @code{mensural_c3},
3890 @code{mensural_c4}
3891
3892 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_c2" c'}
3893
3894 @item historic style mensural F clef (glyph: @code{clefs-mensural_f})
3895
3896 Supported clefs:
3897 @code{mensural_f}
3898
3899 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_f" c'}
3900
3901 @item historic style mensural G clef (glyph: @code{clefs-mensural_g})
3902
3903 Supported clefs:
3904 @code{mensural_g}
3905
3906 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_g" c'}
3907
3908 @item Editio Vaticana style do clef (glyph: @code{clefs-vaticana_do})
3909
3910 Supported clefs:
3911 @code{vaticana_do1}, @code{vaticana_do2}, @code{vaticana_do3}
3912
3913 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_do2" c'}
3914
3915 @item Editio Vaticana style fa clef (glyph: @code{clefs-vaticana_fa})
3916
3917 Supported clefs:
3918 @code{vaticana_fa1}, @code{vaticana_fa2}
3919
3920 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_fa2" c'}
3921
3922 @item Editio Medicaea style do clef (glyph: @code{clefs-medicaea_do})
3923
3924 Supported clefs:
3925 @code{medicaea_do1}, @code{medicaea_do2}, @code{medicaea_do3}
3926
3927 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_do2" c'}
3928
3929 @item Editio Medicaea style fa clef (glyph: @code{clefs-medicaea_fa})
3930
3931 Supported clefs:
3932 @code{medicaea_fa1}, @code{medicaea_fa2}
3933
3934 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_fa2" c'}
3935
3936 @item historic style hufnagel do clef (glyph: @code{clefs-hufnagel_do})
3937
3938 Supported clefs:
3939 @code{hufnagel_do1}, @code{hufnagel_do2}, @code{hufnagel_do3}
3940
3941 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do2" c'}
3942
3943 @item historic style hufnagel fa clef (glyph: @code{clefs-hufnagel_fa})
3944
3945 Supported clefs:
3946 @code{hufnagel_fa1}, @code{hufnagel_fa2}
3947
3948 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_fa2" c'}
3949
3950 @item historic style hufnagel combined do/fa clef (glyph: @code{clefs-hufnagel_do_fa})
3951
3952 Supported clefs:
3953 @code{hufnagel_do_fa}
3954
3955 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do_fa" c'}
3956
3957 @c --- This should go somewhere else: ---
3958 @c @item modern style percussion clef (glyph: @code{clefs-percussion})
3959 @c
3960 @c Supported clefs:
3961 @c @code{percussion}
3962 @c
3963 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "percussion" c'}
3964 @c
3965 @c @item modern style tab clef (glyph: @code{clefs-tab})
3966 @c
3967 @c Supported clefs:
3968 @c @code{tab}
3969 @c
3970 @c @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #6 \property Staff.TimeSignature \set #'transparent = ##t \clef "tab" c'}
3971
3972 @end table
3973
3974 @emph{Modern style} means ``as is typeset in current editions of
3975 transcribed mensural music''.
3976
3977 @emph{Petrucci style} means ``inspired by printings published by the
3978 famous engraver Petrucci (1466-1539)''.
3979
3980 @emph{Historic style} means ``as was typeset or written in contemporary
3981 historic editions (other than those of Petrucci)''.
3982
3983 @emph{Editio XXX style} means ``as is/was printed in Editio XXX''.
3984
3985 Petrucci used C clefs with differently balanced left-side vertical
3986 beams, depending on which staffline it was printed.
3987
3988 @node Custodes
3989 @subsection Custodes
3990
3991 @cindex Custos
3992 @cindex Custodes
3993
3994 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
3995 staff context symbol that appears at the end of a staff line.  It
3996 anticipates the pitch of the first note(s) of the following line and
3997 thus helps the player or singer to manage line breaks during
3998 performance, thus enhancing readability of a score.
3999
4000 @lilypond[verbatim,noquote]
4001 \score {
4002   \notes { c'1 \break
4003         \property Staff.Custos \set #'style = #'mensural
4004         d' }
4005   \paper {
4006     \translator {
4007       \StaffContext
4008       \consists Custos_engraver
4009     }
4010   }
4011 }
4012 @end lilypond
4013
4014 Custodes were frequently used in music notation until the 17th century.
4015 There were different appearances for different notation styles.
4016 Nowadays, they have survived only in special forms of musical notation
4017 such as via the @emph{editio vaticana} dating back to the beginning of
4018 the 20th century.
4019
4020 For typesetting custodes, just put a @code{Custos_engraver} into the
4021 @internalsref{Staff} context when declaring the @code{\paper} block.  In this
4022 block, you can also globally control the appearance of the custos symbol
4023 by setting the custos @code{style} property.  Currently supported styles
4024 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
4025 @code{mensural}.
4026
4027 @example
4028 \paper @{
4029   \translator @{
4030       \StaffContext
4031       \consists Custos_engraver
4032       Custos \override #'style = #'mensural
4033   @}
4034 @}
4035 @end example
4036
4037 The property can also be set locally, for example in a @code{\notes}
4038 block:
4039
4040 @example
4041 \notes @{
4042   \property Staff.Custos \override #'style = #'vaticana
4043   c'1 d' e' d' \break c' d' e' d'
4044 @}
4045 @end example
4046
4047 @node Ligatures
4048 @subsection Ligatures
4049
4050 @cindex Ligatures
4051
4052 @c TODO: Should double check if I recalled things correctly when I wrote
4053 @c down the following paragraph by heart.
4054 In musical terminology, a ligature is a coherent graphical symbol that
4055 represents at least two different notes.  Ligatures originally appeared
4056 in the manuscripts of Gregorian chant notation roughly since the 9th
4057 century as an allusion to the accent symbols of greek lyric poetry to
4058 denote ascending or descending sequences of notes.  Both, the shape and
4059 the exact meaning of ligatures changed tremendously during the following
4060 centuries: In early notation, ligatures where used for monophonic tunes
4061 (Gregorian chant) and very soon denoted also the way of performance in
4062 the sense of articulation.  With upcoming multiphony, the need for a
4063 metric system arised, since multiple voices of a piece have to be
4064 synchronized some way.  New notation systems were invented, that used
4065 the manifold shapes of ligatures to now denote rhythmical patterns
4066 (e.g. black mensural notation, mannered notation, ars nova).  With the
4067 invention of the metric system of the white mensural notation, the need
4068 for ligatures to denote such patterns disappeared.  Nevertheless,
4069 ligatures were still in use in the mensural system for a couple of
4070 decades until they finally disappeared during the late 16th / early 17th
4071 century.  Still, ligatures have survived in contemporary editions of
4072 Gregorian chant such as the Editio Vaticana from 1905/08.
4073
4074 Syntactically, ligatures are simply enclosed by @code{\[} and @code{\]}.
4075 Some ligature styles (such as Editio Vaticana) may need additional input
4076 syntax specific for this particular type of ligature.  By default, the
4077 @internalsref{LigatureBracket} engraver just marks the start and end of
4078 a ligature by small square angles:
4079
4080 @lilypond[singleline,verbatim]
4081 \score {
4082     \notes \transpose c c' {
4083         \[ g c a f d' \]
4084         a g f
4085         \[ e f a g \]
4086     }
4087 }
4088 @end lilypond
4089
4090 To select a specific style of ligatures, a proper ligature engraver has
4091 to be added to the @internalsref{Voice} context, as explained in the
4092 following subsections.  Currently, Lilypond only supports white mensural
4093 ligatures with certain limitations.  Support for Editio Vaticana will be
4094 added in the future.
4095
4096 @menu
4097 * White mensural ligatures::    
4098 @end menu
4099
4100 @node White mensural ligatures
4101 @subsubsection White mensural ligatures
4102
4103 @cindex Mensural ligatures
4104 @cindex White mensural ligatures
4105
4106 Lilypond has limited support for white mensural ligatures.  The
4107 implementation is still experimental; it currently may output strange
4108 warnings or even crash in some cases or produce weird results on more
4109 complex ligatures.  To engrave white mensural ligatures, in the paper
4110 block the @internalsref{MensuralLigature} engraver has to be put into
4111 the @internalsref{Voice} context (and you probably want to remove the
4112 @internalsref{LigatureBracket} engraver).  There is no additional input
4113 language to describe the shape of a white mensural ligature.  The shape
4114 is rather determined solely from the pitch and duration of the enclosed
4115 notes.  While this approach may take a new user quite a while to get
4116 accustomed, it has a great advantage: this way, lily has full musical
4117 information about the ligature.  This is not only required for correct
4118 MIDI output, but also allows for automatic transcription of the
4119 ligatures.
4120
4121 Example:
4122
4123 @lilypond[singleline,verbatim]
4124 \score {
4125     \notes \transpose c c' {
4126         \property Score.timing = ##f
4127         \property Score.defaultBarType = "empty"
4128         \property Voice.NoteHead \set #'style = #'neo_mensural
4129         \property Staff.TimeSignature \set #'style = #'neo_mensural
4130         \clef "petrucci_g"
4131         \[ g\longa c\breve a\breve f\breve d'\longa \]
4132         s4
4133         \[ e1 f1 a\breve g\longa \]
4134     }
4135     \paper {
4136         \translator {
4137             \VoiceContext
4138             \remove Ligature_bracket_engraver
4139             \consists Mensural_ligature_engraver
4140         }
4141     }
4142 }
4143 @end lilypond
4144
4145 Without replacing @code{Ligature_bracket_engraver} with
4146 @code{Mensural_ligature_engraver}, the same music transcribes to the
4147 following:
4148
4149 @lilypond[singleline,verbatim]
4150 \score {
4151     \notes \transpose c c' {
4152         \property Score.timing = ##f
4153         \property Score.defaultBarType = "empty"
4154         \property Voice.NoteHead \set #'style = #'neo_mensural
4155         \property Staff.TimeSignature \set #'style = #'neo_mensural
4156         \clef "petrucci_g"
4157         \[ g\longa c\breve a\breve f\breve d'\longa \]
4158         s4
4159         \[ e1 f1 a\breve g\longa \]
4160     }
4161 }
4162 @end lilypond
4163
4164 @node Figured bass
4165 @subsection Figured bass
4166
4167 @cindex Basso continuo
4168
4169 LilyPond has limited support for figured bass:
4170
4171 @lilypond[verbatim,fragment]
4172 <
4173  \context FiguredBass
4174    \figures {
4175         <_! 3+ 5- >4
4176         < [4 6] 8 >
4177    }
4178  \context Voice { c4 g8 }
4179 >
4180 @end lilypond
4181
4182 The support for figured bass consists of two parts: there is an input
4183 mode, introduced by @code{\figures}, where you can enter bass figures
4184 as numbers, and there is a context called @internalsref{FiguredBass}
4185 that takes care of making @internalsref{BassFigure} objects.
4186
4187 In figures input mode, a group of bass figures is delimited by
4188 @code{<} and @code{>}. The duration is entered after the @code{>}.
4189 @example
4190         <4 6>
4191 @end example
4192 @lilypond[fragment]
4193 \context FiguredBass
4194 \figures { <4 6> }
4195 @end lilypond
4196
4197 Accidentals are added to the numbers if you alterate them by
4198 appending @code{-}, @code{!}  and @code{+}.
4199
4200 @example
4201   <4- 6+ 7!>
4202 @end example
4203 @lilypond[fragment]
4204   \context FiguredBass
4205 \figures { <4- 6+ 7!> }
4206 @end lilypond
4207
4208 Spaces or dashes may be inserted by using @code{_}. Brackets are
4209 introduced with @code{[} and @code{]}.
4210
4211 @example
4212         < [4 6] 8 [_ 12]>
4213 @end example
4214 @lilypond[fragment]
4215  \context FiguredBass
4216 \figures { < [4 6] 8 [_ 12]> }
4217 @end lilypond
4218
4219 Although the support for figured bass may superficially resemble chord
4220 support, it works much simpler: in figured bass simply stores the
4221 numbers, and then prints the numbers you entered. There is no
4222 conversion to pitches, and no realizations of the bass are played in
4223 the MIDI file.
4224
4225
4226 @c . {Tuning output}
4227 @node Tuning output
4228 @section Tuning output
4229
4230 LilyPond tries to take as much formatting as possible out of your
4231 hands. Nevertheless, there are situations where it needs some help, or
4232 where you want to override its decisions. In this section we discuss
4233 ways to do just that.
4234
4235 Formatting is internally done by manipulating so called objects (graphic
4236 objects). Each object carries with it a set of properties (object
4237 properties) specific to that object.  For example, a stem object has
4238 properties that specify its direction, length and thickness.
4239
4240 The most direct way of tuning the output is by altering the values of
4241 these properties. There are two ways of doing that: first, you can
4242 temporarily change the definition of a certain type of object, thus
4243 affecting a whole set of objects.  Second, you can select one specific
4244 object, and set a object property in that object.
4245
4246 @menu
4247 * Tuning groups of objects ::   
4248 * Tuning per object ::          
4249 * Font selection::              
4250 * Text markup::                 
4251 @end menu
4252
4253 @node Tuning groups of objects 
4254 @subsection Tuning groups of objects 
4255
4256 @cindex object description
4257
4258 A object definition is a Scheme association list, that is stored in a
4259 context property.  By assigning to that property (using plain
4260 @code{\property}), you can change the resulting objects.
4261
4262 @lilypond[verbatim, fragment]
4263 c'4 \property Voice.Stem  = #'()
4264 @end lilypond
4265
4266 The @code{\property} assignment effectively empties the definition of
4267 the Stem object. One of the effects is that the recipe of how it should be
4268 printed is erased, with the effect of rendering it invisible.  The above
4269 assignment is available as a standard identifier, for the case that you
4270 find this useful:
4271
4272 @example
4273   \property Voice.Stem = \turnOff
4274 @end example
4275
4276 @cindex \override
4277 @cindex \revert
4278 @cindex \set
4279
4280 This mechanism is fairly crude, since you can only set, but not modify,
4281 the definition of a object. For this reason, there is a more advanced
4282 mechanism.
4283
4284 The definition of a object is actually a list of default object
4285 properties. For example, the definition of the Stem object (available in
4286 @file{scm/grob-description.scm}), defines the following values for
4287 @internalsref{Stem}
4288
4289 @example
4290         (thickness . 0.8)
4291         (beamed-lengths . (0.0 2.5 2.0 1.5))
4292         (Y-extent-callback . ,Stem::height)
4293         @var{...}
4294 @end example
4295
4296 You can add a property on top of the existing definition, or remove a
4297 property, thus overriding the system defaults:
4298 @lilypond[verbatim]
4299 c'4 \property Voice.Stem \override #'thickness = #4.0
4300 c'4 \property Voice.Stem \revert #'thickness
4301 c'4
4302 @end lilypond
4303 You should balance @code{\override} and @code{\revert}. If that's too
4304 much work, you can use the @code{\set} shorthand. It performs a revert
4305 followed by an override. The following example gives exactly the same
4306 result as the previous one. 
4307 @lilypond[verbatim]
4308 c'4 \property Voice.Stem \set #'thickness = #4.0
4309 c'4 \property Voice.Stem \set #'thickness = #0.8
4310 c'4
4311 @end lilypond
4312 If you use @code{\set}, you must explicitly restore the default.
4313
4314
4315 Formally the syntax for these constructions is
4316 @example
4317 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
4318 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
4319 \property @var{context}.@var{grobname} \revert @var{symbol}
4320 @end example
4321 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
4322 and @var{grobname} are strings and @var{value} is a Scheme expression.
4323
4324
4325 If you revert a setting which was not set in the first place, then it
4326 has no effect. However, if the setting was set as a system default, it
4327 may remove the default value, and this may give surprising results,
4328 including crashes.  In other words, @code{\override} and @code{\revert},
4329 must be carefully balanced.
4330
4331 These are examples of correct nesting of @code{\override}, @code{\set},
4332 @code{\revert}. 
4333
4334 A clumsy but correct form:
4335 @example
4336   \override \revert \override \revert \override \revert
4337 @end example
4338
4339 Shorter version of the same:
4340 @example 
4341   \override \set \set  \revert
4342 @end example
4343
4344 A short form, using only @code{\set}. This requires you to know the
4345 default value:
4346 @example
4347   \set \set \set \set @var{to default value}
4348 @end example
4349
4350 If there is no default (i.e. by default, the object property is unset),
4351 then you can use
4352 @example
4353   \set \set \set \revert
4354 @end example
4355
4356 For the digirati, the object description is an Scheme association
4357 list. Since a Scheme list is a singly linked list, we can treat it as a
4358 stack, and @code{\override} and @code{\revert} are just push and pop
4359 operations. This pushing and popping is also used for overriding
4360 automatic beaming settings.
4361
4362 @refbugs
4363
4364 LilyPond will hang or crash if @var{value} contains cyclic references.
4365 The backend is not very strict in type-checking object properties. If you
4366 @code{\revert} properties that are expected to be set by default,
4367 LilyPond may crash.
4368
4369
4370
4371
4372 @node Tuning per object 
4373 @subsection Tuning per object 
4374
4375 @cindex \once
4376 Tuning a single object is most often done with @code{\property}. The
4377 form,
4378 @example
4379         \once \property @dots{}
4380 @end example
4381 @c
4382 applies a setting only during one moment in the score: notice how the
4383 original setting for stem thickness is restored automatically in the
4384 following example
4385 @c
4386 @lilypond[verbatim, fragment, relative=1]
4387   c4 
4388   \once \property Voice.Stem \set #'thickness = #4
4389   c4
4390   c4
4391 @end lilypond
4392
4393 @cindex \once
4394 @cindex \outputproperty
4395
4396 A second way of tuning objects is the more arcane @code{\outputproperty}
4397 feature.  The syntax is as follows:
4398 @example
4399 \outputproperty @var{predicate} @var{symbol} = @var{value}
4400 @end example
4401 Here @code{predicate} is a Scheme function taking a object argument, and
4402 returning a boolean.  This statement is processed by the
4403 @code{Output_property_engraver}.  It instructs the engraver to feed all
4404 objects that it sees to @var{predicate}. Whenever the predicate returns
4405 true, the object property @var{symbol} will be set to @var{value}.
4406
4407 This command is only single shot, in contrast to @code{\override} and
4408 @code{\set}.
4409
4410 You will need to combine this statement with @code{\context} to select
4411 the appropriate context to apply this to.
4412
4413 In the following example, all note heads occurring at current staff
4414 level, are shifted up and right by setting their @code{extra-offset}
4415 property.
4416
4417 @lilypond[fragment,verbatim,singleline]
4418 \relative c'' { c4
4419   \context Staff \outputproperty
4420   #(make-type-checker 'note-head-interface)
4421   #'extra-offset = #'(0.5 . 0.75)
4422   <c8 e g> }
4423 @end lilypond
4424
4425 @cindex @code{extra-offset}
4426
4427 In this example, the predicate checks the @code{text} object property, to
4428 shift only the `m.d.' text,  but not the fingering instruction "2".
4429 @lilypond[verbatim,singleline]
4430 #(define (make-text-checker text)
4431    (lambda (grob) (equal? text (ly:get-grob-property grob 'text))))
4432
4433 \score {    
4434   \notes\relative c''' {
4435     \property Voice.Stem \set #'direction = #1
4436     \outputproperty #(make-text-checker "m.d.")
4437       #'extra-offset = #'(-3.5 . -4.5)
4438     a^2^"m.d."    
4439   }
4440 }
4441 @end lilypond
4442
4443 @refbugs
4444
4445 If possible, avoid this feature: the semantics are not very clean, and
4446 the syntax and semantics are up for rewrite.
4447
4448
4449
4450
4451 @node Font selection
4452 @subsection Font selection
4453
4454 The most common thing to change about the appearance of fonts is
4455 their size. The font size of a @internalsref{Voice},
4456 @internalsref{Staff} or @internalsref{Thread} context, can be easily
4457 changed by setting the @code{fontSize} property for that context:
4458 @lilypond[fragment,relative=1]
4459   c4 c4 \property Voice.fontSize = #-1
4460   f4 g4
4461 @end lilypond
4462  This command will not change the size of variable symbols, such as
4463 beams or slurs.  You can use this command to get smaller symbol for
4464 cue notes, but that involves some more subtleties. An elaborate
4465 example of those is in @file{input/test/cue-notes.ly}.
4466
4467 @cindex cue notes
4468 @cindex font size
4469 @cindex size
4470 @cindex symbol size
4471 @cindex glyph size
4472
4473 The font used for printing a object can be selected by setting
4474 @code{font-name}, e.g.
4475 @example
4476   \property Staff.TimeSignature
4477     \set #'font-name = #"cmr17"
4478 @end example
4479 You may use any font which is available to @TeX{}, such as foreign
4480 fonts or fonts that do not belong to the Computer Modern font family.
4481 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
4482 can also be adjusted with a more fine-grained mechanism.  By setting
4483 the object properties described below, you can select a different font.
4484 All three mechanisms work for every object that supports
4485 @code{font-interface}.
4486
4487 @table @code
4488 @item font-family
4489  A symbol indicating the general class of the typeface.  Supported are
4490 @code{roman} (Computer Modern), @code{braces} (for piano staff
4491 braces), @code{music} (the standard music font), @code{ancient} (the
4492 ancient notation font) @code{dynamic} (font for dynamic signs) and
4493 @code{typewriter}. 
4494   
4495 @item font-shape
4496   A symbol indicating the shape of the font, there are typically several
4497   font shapes available for each font family. Choices are @code{italic},
4498   @code{caps} and @code{upright} 
4499
4500 @item font-series
4501 A  symbol indicating the series of the font. There are typically several
4502 font series for each font family and shape. Choices are @code{medium}
4503 and @code{bold}. 
4504
4505 @item font-relative-size
4506   A number indicating the size relative the standard size.  For example,
4507   with 20pt staff height, relative size -1  corresponds to 16pt staff
4508   height, and relative size +1 corresponds to 23 pt staff height.
4509
4510 @item font-design-size
4511 A number indicating  the design size of the font. 
4512
4513 This is a feature of the Computer Modern Font: each point size has a
4514 slightly different design. Smaller design sizes are relatively wider,
4515 which enhances readability.
4516 @end table
4517
4518 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
4519 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
4520 to override default setting, which are always present. For example:
4521 @example
4522   \property Lyrics.LyricText \override #'font-series = #'bold
4523   \property Lyrics.LyricText \override #'font-family = #'typewriter
4524   \property Lyrics.LyricText \override #'font-shape  = #'*
4525 @end example
4526
4527 @cindex @code{font-style}
4528
4529 There are also pre-cooked font selection qualifiers. These are
4530 selected through the object property @code{font-style}.  For example,
4531 the style @code{finger} selects family @code{number} and relative size
4532 @code{-3}.  Styles available include @code{volta}, @code{finger},
4533 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
4534 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
4535 tables for selecting fonts are located in @file{scm/font.scm}. Refer
4536 to this file for more information.
4537
4538 @cindex magnification
4539
4540 The size of the font may be scaled with the object property
4541 @code{font-magnification}.  For example, @code{2.0} blows up all
4542 letters by a factor 2 in both directions.
4543
4544 @refbugs
4545
4546 Relative size is not linked to any real size.
4547
4548 There is no style sheet provided for other fonts besides the @TeX{}
4549 family, and the style sheet can not be modified easiyl.
4550
4551 @cindex font selection
4552 @cindex font magnification
4553 @cindex @code{font-interface}
4554
4555
4556 @node Text markup
4557 @subsection Text markup
4558 @cindex text markup
4559 @cindex markup text
4560
4561 LilyPond has an internal mechanism to typeset texts. You can
4562 form text markup expressions by composing scheme expressions
4563 in the following way.
4564
4565 @lilypond[verbatim, singleline]
4566  \relative c' {
4567     \fatText
4568     a^#"upright"
4569     b_#'(bold "bold")
4570     c^#'(italic "italic")
4571     d_#'((bold italic) "ff")
4572     e^#'(dynamic "ff")
4573     f_#'(lines "one" (bold "two"))
4574     g^#'(music "noteheads-2" ((raise . 2.4) "flags-u3"))
4575   }
4576 @end lilypond
4577
4578 Normally, the Scheme markup text is stored in the @code{text} property
4579 of a object.  Formally, it is defined as follows:
4580
4581 @example
4582 text: string | (head? text+)
4583 head: markup | (markup+)
4584 markup-item: property | abbrev
4585 property: (@var{key} . @var{value})
4586 abbrev: @code{columns lines roman music bold italic named super sub}
4587         @code{overstrike text finger volta timesig mmrest mark script}
4588         @code{large Large dynamic}
4589 @end example
4590
4591 The markup is broken down and converted into a list of object properties,
4592 which are prepended to the property list.  The @var{key}-@var{value}
4593 pair is a object property. A list of properties available is included in
4594 the generated documentation for @internalsref{text-interface}.
4595
4596 The following abbreviations are defined:
4597 @table @code
4598 @item columns
4599  horizontal mode: set all text on one line (default)
4600 @item lines
4601  vertical mode: set every text on a new line
4602 @item roman
4603  select roman font
4604 @item music
4605  selects the Feta font (the standard font for music notation glyphs),
4606 and uses named lookup
4607
4608 @item bold
4609  select bold series
4610 @item italic
4611  select italic shape
4612 @item named
4613  lookup by character name
4614 @item text
4615  plain text lookup (by character value)
4616 @item super
4617  superscript
4618 @item sub
4619  subscript
4620 @item overstrike
4621  the next text or character overstrikes this one
4622 @item finger
4623  select fingering number fontstyle
4624 @item volta
4625  select volta number fontstyle
4626 @item timesig
4627  select time signature number fontstyle
4628 @item mmrest
4629  select multi measure rest number fontstyle
4630 @item mark
4631  select mark number fontstyle
4632 @item script
4633  select scriptsize roman fontstyle
4634 @item large
4635  select large roman fontstyle
4636 @item Large
4637  select Large roman fontstyle
4638 @item dynamic
4639  select dynamics fontstyle
4640 @end table
4641
4642
4643 @cindex metronome mark
4644
4645 One practical application of complicated markup is to fake a metronome
4646 marking:
4647
4648 @lilypond[verbatim]
4649 #(define note '(columns
4650   (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
4651 #(define eight-note `(columns ,note ((kern . -0.1)
4652   (music ((raise . 3.5) "flags-u3")))))
4653 #(define dotted-eight-note
4654   `(columns ,eight-note (music "dots-dot")))
4655
4656 \score {
4657   \notes\relative c'' {
4658     a1^#`((columns (font-relative-size . -1))
4659            ,dotted-eight-note " = 64")
4660   }
4661   \paper {
4662     linewidth = -1.
4663     \translator{
4664       \ScoreContext
4665       TextScript \override #'font-shape = #'upright
4666     }
4667   }
4668 }
4669 @end lilypond
4670
4671 @refbugs
4672
4673 The syntax and semantics of markup texts are not clean, and both
4674 syntax and semantics are slated for a rewrite.
4675
4676 LilyPond does not do kerning, and there generally spaces texts
4677 slightly too wide.
4678
4679
4680
4681 @node Global layout
4682 @section Global layout
4683
4684 The global layout determined by three factors: the page layout, the
4685 line breaks and the spacing. These all influence each other: The
4686 choice of spacing determines how densely each system of music is set,
4687 where line breaks breaks are chosen, and thus ultimately how many
4688 pages a piece of music takes. In this section we will explain how the
4689 lilypond spacing engine works, and how you can tune its results.
4690
4691 Globally spoken, this procedure happens in three steps: first,
4692 flexible distances (``springs'') are chosen, based on durations. All
4693 possible line breaking combination are tried, and the one with the
4694 best results---a layout that has uniform density and requires as
4695 little stretching or cramping as possible---is chosen. When the score
4696 is processed by @TeX{}, page are filled with systems, and page breaks
4697 are chosen whenever the page gets full.
4698
4699 @menu
4700 * Vertical spacing::            
4701 * Horizontal spacing::          
4702 * Font Size::                   
4703 * Line breaking::               
4704 * Page layout::                 
4705 @end menu
4706
4707
4708 @node Vertical spacing
4709 @subsection Vertical spacing
4710
4711 @cindex vertical spacing
4712 @cindex distance between staves
4713 @cindex staff distance
4714 @cindex between staves, distance
4715 @cindex staffs per page
4716
4717
4718 The height of each system is determined automatically by lilypond, to
4719 keep systems from bumping into each other, some minimum distances are
4720 set.  By changing these, you can put staves closer together, and thus
4721 put more  systems onto one page.
4722
4723 Normally staves are stacked vertically. To make
4724 staves maintain a distance, their vertical size is padded. This is
4725 done with the property @code{minimumVerticalExtent}. It takes a pair
4726 of numbers, so if you want to make it smaller from its, then you could
4727 set
4728 @example
4729   \property Staff.minimumVerticalExtent = #'(-4 . 4)
4730 @end example
4731 This sets the vertical size of the current staff to 4 staff-space on
4732 either side of the center staff line.  The argument of
4733 @code{minimumVerticalExtent} is interpreted as an interval, where the
4734 center line is the 0, so the first number is generally negative.  you
4735 could also make the staff larger at the bottom by setting it to
4736 @code{(-6 . 4)}. The default value is @code{(-6 . 6)}.
4737
4738 Vertical aligment of staves is handled by the
4739 @internalsref{VerticalAlignment} object, which lives at
4740 @internalsref{Score} level.
4741
4742 The piano staves are handled a little differently: to make cross-staff
4743 beaming work correctly, it necessary that the distance between staves
4744 is fixed.  This is also done with a @internalsref{VerticalAlignment}
4745 object, created in @internalsref{PianoStaff}, but a forced distance is
4746 set. This is done with the object property #'forced-distance. If you
4747 want to override this, use a @code{\translator} block as follows:
4748 @example
4749   \translator @{
4750     \PianoStaffContext
4751     VerticalAlignment \override #'forced-distance = #9
4752   @}
4753 @end example
4754 This would bring the staves together at a distance of 9 staff spaces,
4755 and again this is measured from the center line of each staff.
4756
4757
4758
4759 @node Horizontal spacing
4760 @subsection Horizontal Spacing
4761
4762 The spacing engine translates differences in durations into
4763 stretchable distances (``springs'') of differing lengths. Longer
4764 durations get more space, shorter durations get less.  The basis for
4765 assigning spaces to durations, is that the shortest durations get a
4766 fixed amount of space, and the longer durations get more: doubling a
4767 duration adds a fixed amount of space to the note.
4768
4769 For example, the following piece contains lots of half, quarter and
4770 8th notes, the eighth note is followed by 1 note head width. The The
4771 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
4772 @lilypond[fragment, verbatim, relative=1]
4773  c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
4774 @end lilypond
4775
4776 These two amounts of space are @code{shortest-duration-space}
4777 @code{spacing-increment}, object properties of
4778 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
4779 set to 1.2, which is the width of a note head, and
4780 @code{shortest-duration-space} is set to 2.0, meaning that the
4781 shortest note gets 2 noteheads of space. For normal notes, this space
4782 is always counted from the left edge of the symbol, so the short notes
4783 in a score is generally followed by one note head width of space.
4784
4785 If one would follow the above procedure exactly, then adding a single
4786 32th note to a score that uses 8th and 16th notes, would widen up the
4787 entire score a lot. The shortest note is no longer a 16th, but a 64th,
4788 thus adding 2 noteheads of space to every note. To prevent this, the
4789 shortest duration for spacing is not the shortest note in the score,
4790 but the most commonly found shortest note.  Notes that are even
4791 shorter this are followed by a space that is proportonial to their
4792 duration relative to the common shortest note.  So if we were to add
4793 only a few 16th notes to the example above, they would be followed by
4794 half a NHW:
4795
4796 @lilypond[fragment, verbatim, relative=1]
4797  c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
4798 @end lilypond
4799
4800 The most common shortest duration is determined as follows: in every
4801 measure, the shortest duration is determined. The most common short
4802 duration, is taken as the basis for the spacing, with the stipulation
4803 that this shortest duration should always be equal to or shorter than
4804 1/8th note. The shortest duration is printed when you run lilypond
4805 with @code{--verbose}.  These durations may also be customized. If you
4806 set the @code{common-shortest-duration} in
4807 @internalsref{SpacingSpanner}, then this sets the base duration for
4808 spacing. The maximum duration for this base (normally 1/8th), is set
4809 through @code{base-shortest-duration}.
4810
4811 @cindex @code{common-shortest-duration}
4812 @cindex @code{base-shortest-duration}
4813 @cindex @code{stem-spacing-correction}
4814 @cindex @code{spacing}
4815
4816 In the introduction it was explained that stem directions influence
4817 spacing. This is controlled with @code{stem-spacing-correction} in
4818 @internalsref{NoteSpacing}. The @code{StaffSpacing} object contains the
4819 same property for controlling the stem/barline spacing. In the
4820 following example shows these corrections, once with default settings,
4821 and once with exaggerated corrections.  
4822
4823 @lilypond
4824     \score { \notes {
4825       c'4 e''4 e'4 b'4 |
4826       b'4 e''4 b'4 e''4|
4827       \property Staff.NoteSpacing \override #'stem-spacing-correction
4828       = #1.5
4829       \property Staff.StaffSpacing \override #'stem-spacing-correction
4830       = #1.5
4831       c'4 e''4 e'4 b'4 |
4832       b'4 e''4 b'4 e''4|      
4833     }
4834     \paper { linewidth = -1. } }
4835 @end lilypond
4836
4837
4838
4839 @refbugs
4840
4841 Spacing is determined on a score wide basis. If you have a score that
4842 changes its character (measured in durations) half way during the
4843 score, the part containing the longer durations will be spaced too
4844 widely.
4845
4846 Generating optically pleasing spacing is black magic. LilyPond tries
4847 to deal with a number of frequent cases. Here is an example that is
4848 not handled correctly, due to the combination of chord collisions and
4849 kneed stems.
4850
4851 @lilypond
4852 \score {
4853      \context PianoStaff \notes \transpose c c'' <
4854      \context Staff = up { s1 }
4855      \context Staff = down { [c8 c \translator Staff=up <c d> c 
4856 \translator Staff=down c c c] }
4857      >
4858      \paper { linewidth = -1 }
4859 }
4860 @end lilypond
4861
4862
4863 @c .  {Font size}
4864 @node Font Size
4865 @subsection Font size
4866 @cindex font size, setting
4867 @cindex staff size, setting
4868 @cindex @code{paper} file
4869
4870 The Feta font provides musical symbols at seven different sizes.
4871 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
4872 point, and 26 point.  The point size of a font is the height of the
4873 five lines in a staff when displayed in the font.
4874
4875 Definitions for these sizes are the files @file{paperSZ.ly}, where
4876 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26.  If you include any
4877 of these files, the identifiers @code{paperEleven},
4878 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
4879 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
4880 are defined respectively.  The default @code{\paper} block is also
4881 set. These files should be imported at toplevel, i.e.
4882 @example
4883         \include "paper26.ly"
4884         \score @{  ... @}
4885 @end example
4886
4887 The font definitions are generated using a Scheme function. For more
4888 details, see the file @file{scm/font.scm}.
4889
4890
4891 @c .  {Line break}
4892 @node Line breaking
4893 @subsection Line breaking
4894
4895 @cindex line breaks
4896 @cindex breaking lines
4897
4898 Line breaks are normally computed automatically. They are chosen such
4899 that it looks neither cramped nor loose, and that consecutive lines have
4900 similar density.
4901
4902 Occasionally you might want to override the automatic breaks; you can
4903 do this by specifying @code{\break}. This will force a line break at
4904 this point.  Line breaks can only occur at places where there are bar
4905 lines.  If you want to have a line break where there is no bar line,
4906 you can force an invisible bar line by entering @code{\bar
4907 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
4908 point.
4909
4910
4911 @cindex regular line breaks
4912 @cindex four bar music. 
4913
4914 If you want linebreaks at regular intervals, you can use the following:
4915 @example
4916 <  \repeat 7 unfold @{ s1 * 4 \break  @}
4917    @emph{real music}
4918
4919 @end  example
4920 This makes the following 28 measures (assuming 4/4 time) be broken every
4921 4 measures.
4922
4923 @node Page layout
4924 @subsection Page layout
4925
4926 @cindex page breaks
4927 @cindex breaking pages
4928
4929 @cindex @code{indent}
4930 @cindex @code{linewidth}
4931
4932 The most basic settings influencing the spacing are @code{indent} and
4933 @code{linewidth}. They are set in the @code{\paper} block. They
4934 control the indentation of the first line of music, and the lengths of
4935 the lines.  If @code{linewidth} set to a negative value, a single
4936 unjustified line is produced.  A similar effect for scores that are
4937 longer than one line, can be produced by setting @code{raggedright} to
4938 true in the @code{\paper} block.
4939
4940 @cindex page layout
4941
4942 The page layout process happens outside lilypond. Ly2dvi sets page
4943 layout instructions. Ly2dvi responds to the following variables in the
4944 @code{\paper} block.  The variable @code{textheight} sets the total
4945 height of the music on each page.  The spacing between systems is
4946 controlled with @code{interscoreline}, its default is 16pt.
4947 The distance between the score lines will stretch in order to fill the
4948 full page @code{interscorelinefill} is set to a positive number.  In
4949 that case @code{interscoreline} specifies the minimum spacing.
4950
4951 @cindex @code{textheight}
4952 @cindex @code{interscoreline}
4953 @cindex @code{interscorelinefill}
4954
4955 If the variable @code{lastpagefill} is defined (that is, it gets any
4956 value assigned in the @code{\paper} block), systems are evenly
4957 distributed vertically on the last page.  This might produce ugly
4958 results in case there are not enough systems on the last page.  Note
4959 that @command{lilypond-book} ignores @code{lastpagefill}.  See
4960 @ref{Integrating text and music with lilypond-book} for
4961 more information.
4962
4963 @cindex @code{lastpagefill}
4964
4965 Page breaks are normally computed by @TeX{}, so they are not under
4966 direct control of LilyPond.  However, you can insert a commands into
4967 the @file{.tex} output to instruct @TeX{} where to break pages. You
4968 can insert a @code{\newpage} from within lilypond. This is done by
4969 setting the @code{between-systems-strings} on the
4970 @internalsref{NonMusicalPaperColumn} where the system is broken.
4971
4972 @cindex paper size
4973 @cindex page size
4974 @cindex @code{papersize}
4975
4976 To change the paper size, you must first set the
4977 @code{papersize} paper variable variable.  Set it to
4978 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
4979 specification, you must set the font as described above.  If you want
4980 the default font, then use the 20 point font.
4981
4982 @example
4983         \paper@{ papersize = "a4" @}
4984         \include "paper16.ly"
4985 @end example
4986
4987 The file @code{paper16.ly}  will now include a file named @file{a4.ly}, which
4988 will set the paper variables @code{hsize} and @code{vsize} (used by
4989 Lilypond and @code{ly2dvi})
4990
4991
4992
4993
4994 @c . {Sound}
4995 @node Sound
4996 @section Sound
4997 @cindex Sound
4998
4999 LilyPond can produce MIDI output.  The performance lacks lots of
5000 interesting effects, such as swing, articulation, slurring, etc., but it
5001 is good enough for proof-hearing the music you have entered.  Ties,
5002 dynamics and tempo changes are interpreted.
5003
5004 Dynamic marks, crescendi and decrescendi translate into MIDI volume
5005 levels.  Dynamic marks translate to a fixed fraction of the available
5006 MIDI volume range, crescendi and decrescendi make the the volume vary
5007 linearly between their two extremities.  The fractions be adjusted by
5008 overriding the @code{absolute-volume-alist} defined in
5009 @file{scm/midi.scm}.
5010
5011 For each type of musical instrument (that MIDI supports), a volume range
5012 can be defined.  This gives you basic equalizer control, which can
5013 enhance the quality of the MIDI output remarkably.  You can add
5014 instruments and ranges or change the default settings by overriding the
5015 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
5016
5017 Both loudness controls are combined to produce the final  MIDI volume. 
5018
5019 @menu
5020 * MIDI block::                  
5021 * MIDI instrument names::       
5022 @end menu
5023
5024 @c .  {MIDI block}
5025 @node MIDI block
5026 @subsection MIDI block
5027 @cindex MIDI block
5028
5029
5030 The MIDI block is analogous to the paper block, but it is somewhat
5031 simpler.  The @code{\midi} block can contain:
5032 @cindex MIDI block
5033
5034 @itemize @bullet
5035   @item  a @code{\tempo} definition
5036   @item  context definitions
5037 @end itemize
5038
5039 Assignments in the @code{\midi} block are not allowed.
5040
5041
5042
5043 @cindex context definition
5044
5045 Context definitions follow precisely the same syntax as within the
5046 \paper block.  Translation modules for sound are called performers.
5047 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
5048
5049
5050 @node MIDI instrument names
5051 @subsection MIDI instrument names
5052
5053 @cindex instrument names
5054 @cindex @code{Staff.midiInstrument}
5055 @cindex @code{Staff.instrument}
5056
5057 The MIDI instrument name is set by the @code{Staff.midiInstrument}
5058 property or, if that property is not set, the @code{Staff.instrument}
5059 property.  The instrument name should be chosen from the list in
5060 @ref{MIDI instruments}.
5061
5062 @refbugs
5063
5064 If the selected string does not exactly match, then LilyPond uses the
5065 default (Grand Piano). It is not possible to select an instrument by
5066 number.
5067
5068