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