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