]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
6fa0bd454be655b87619e9a1c52489adad0616bb
[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
3075
3076 @menu
3077 * Ambitus::
3078 @end menu
3079
3080 @node Ambitus
3081 @subsection Ambitus
3082 @cindex ambitus
3083
3084 The term @emph{ambitus} denotes a range of pitches for a given voice in
3085 a part of music.  It also may denote the pitch range that a musical
3086 instrument is capable of playing.  Most musical instruments have their
3087 ambitus standardized (or at least there is agreement upon the minimal
3088 ambitus of a particular type of instrument), such that a composer or
3089 arranger of a piece of music can easily meet the ambitus constraints of
3090 the targeted instrument.  However, the ambitus of the human voice
3091 depends on individual physiological state, including education and
3092 training of the voice.  Therefore, a singer potentially has to check for
3093 each piece of music if the ambitus of that piece meets his individual
3094 capabilities.  This is why the ambitus of a piece may be of particular
3095 value to vocal performers.
3096
3097 The ambitus is typically notated on a per-voice basis at the very
3098 beginning of a piece, e.g. nearby the initial clef or time signature of
3099 each staff.  The range is graphically specified by two noteheads, that
3100 represent the minimum and maximum pitch.  Some publishers use a textual
3101 notation: they put the range in words in front of the corresponding
3102 staff.  Lilypond currently only supports the graphical ambitus notation.
3103
3104 To apply, simply add the @internalsref{Ambitus_engraver} to the
3105 @internalsref{Voice} context, as shown in the below example:
3106
3107 @lilypond[singleline,verbatim]
3108 upper = \notes \relative c {
3109   \clef "treble"
3110   \key c \minor
3111   as'' c e2 bes f cis d4 e f2 g
3112 }
3113 lower = \notes \relative c {
3114   \clef "treble"
3115   \key e \major
3116   e'4 b g a c es fis a cis b a g f e d2
3117 }
3118 \score {
3119   \context ChoirStaff {
3120     <
3121       \context Staff = one { \upper }
3122       \context Staff = three { \lower }
3123     >
3124   }
3125   \paper {
3126     \translator {
3127       \VoiceContext
3128       \consists Ambitus_engraver
3129     }
3130   }
3131 }
3132 @end lilypond
3133
3134 The shape of the note heads to use can be changed via the
3135 @code{note-head-style} property, which holds the glyph name of the note
3136 head (see also @ref{Ancient note heads}).  The vertical line between the
3137 upper and lower head can be switched on or off via the @code{join-heads}
3138 property.  Example:
3139
3140 @example
3141 \translator @{
3142   \VoiceContext
3143   \consists Ambitus_engraver
3144   Ambitus \set #'note-head-style = #'noteheads-2mensural
3145   Ambitus \set #'join-heads = ##f
3146 @}
3147 @end example
3148
3149 By default, the ambitus grob is put before the clef.  You can control
3150 this behaviour through the @code{breakAlignOrder} property of the score
3151 context by redefining the order, e.g. with the following addition to the
3152 paper block:
3153
3154 @example
3155 \translator @{
3156   \ScoreContext
3157   breakAlignOrder = #'(
3158     instrument-name
3159     left-edge
3160     span-bar
3161     breathing-sign
3162     clef
3163     ambitus
3164     key-signature
3165     staff-bar
3166     time-signature
3167     custos
3168   )
3169 @}
3170 @end example
3171
3172 @node Tablatures
3173 @section Tablatures
3174
3175 Tablature notation is used for notating music for plucked string
3176 instruments.  It notates pitches not by using note heads, but by
3177 indicating on which string and fret a note must be played.  LilyPond
3178 offers limited support for tablature.
3179
3180 @menu
3181 * Tablatures basic::            
3182 * Non-guitar tablatures::       
3183 * Tablature in addition to normal staff::  
3184 @end menu
3185
3186 @node Tablatures basic
3187 @subsection Tablatures basic
3188 @cindex Tablatures basic
3189
3190 Tablature can be typeset with Lilypond by using the
3191 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
3192 tablature is a recent feature in Lilypond, most of the guitar special
3193 effects such as bend are not yet supported.
3194
3195 With the @internalsref{TabStaff}, the string number associated to a note
3196 is given as a backslash followed by the string number, e.g. @code{c4\3} for a C
3197 quarter on the third string. By default, string 1 is the highest one, and the
3198 tuning defaults to the standard guitar tuning (with 6 strings).
3199
3200 @lilypond[fragment,verbatim]
3201   \context TabStaff <
3202     \notes {
3203       a,4\5 c'\2 a\3 e'\1
3204       e\4 c'\2 a\3 e'\1
3205     }
3206   >  
3207 @end lilypond
3208
3209 If you do not specify a string number then lilypond automatically selects one.
3210 The selection is controlled by the translator property @code{minimumFret}. -- LilyPond
3211 simply selects the first string that does not give a fret number less than
3212 @code{minimumFret}. Default is 0.
3213
3214 Notice that LilyPond does not handle chords in any special way, and hence
3215 the automatic string selector may easily select the same string to two notes in a chord.
3216
3217 @example
3218 e8 fis gis a b cis' dis' e'
3219 \property TabStaff.minimumFret = #8
3220 e8 fis gis a b cis' dis' e'
3221 @end example
3222 @lilypond[noindent,noquote]
3223 frag = \notes {
3224     \key e \major
3225     e8 fis gis a b cis' dis' e'
3226     \property TabStaff.minimumFret = #8
3227     e8 fis gis a b cis' dis' e'
3228 }
3229 \score {
3230   \context StaffGroup <
3231     \context Staff { \clef "G_8" \frag }
3232     \context TabStaff { \frag }
3233   >
3234 }
3235 @end lilypond
3236
3237 @node Non-guitar tablatures
3238 @subsection Non-guitar tablatures
3239 @cindex Non-guitar tablatures
3240
3241 There are many ways to customize Lilypond tablatures.
3242
3243 First you can change the number of strings, by setting the number of
3244 lines in the @internalsref{TabStaff} (the @code{line-count} property
3245 of TabStaff can only be changed using @code{\outputproperty}, for more
3246 information, see @ref{Tuning per object}.  You can change the strings
3247 tuning. A string tuning is given as a Scheme list with one integer
3248 number for each string, the number being the pitch of an open string.
3249
3250 (The numbers specified for stringTuning are the numbers of semitons
3251 to subtract --- or add --- starting the specified pitch by default
3252 middle C, in string order: thus the notes are e, a, d & g)
3253
3254 @lilypond[fragment,verbatim]
3255   \context TabStaff <
3256
3257     \outputproperty #(make-type-checker 'staff-symbol-interface)
3258                     #'line-count = #4
3259     \property TabStaff.stringTunings =  #'(-5 -10 -15 -20)
3260     
3261     \notes {
3262       a,4 c' a e' e c' a e'
3263     }
3264   > 
3265 @end lilypond
3266
3267 Finally, it is possible to change the Scheme function to format the
3268 tablature note text. The default is @var{fret-number-tablature-format},
3269 which uses the fret number, but for some instruments that may not use
3270 this notation, just create your own tablature-format function. This
3271 function takes three argument: the string number, the string tuning and
3272 the note pitch.
3273
3274
3275 @node Tablature in addition to normal staff
3276 @subsection Tablature in addition to normal staff
3277 @cindex Tablature in addition to normal staff
3278
3279 It is possible to typeset both tablature and a "normal" staff, as
3280 commonly done in many parts.
3281
3282 A common trick for that is to put the notes in a variables, and to hide
3283 the fingering information (which correspond to the string number) for
3284 the standard staff.
3285
3286 @c FIXME
3287 @c @lily pond[verbatim]
3288 @example
3289   part = \notes @{
3290     a,4-2 c'-5 a-4 e'-6
3291     e-3 c'-5 a-4 e'-6
3292   @}
3293   \score @{
3294     \context StaffGroup <
3295       \context Staff <
3296         % Hide fingering number
3297         \property Staff.Fingering \override #'transparent = ##t
3298
3299         \part
3300       >
3301       \context TabStaff <
3302         \property Staff.Stem \override #'direction = #1
3303
3304         \part
3305       >
3306     >
3307   @}
3308 @end example
3309 @c @end lilypond
3310
3311 @c . {Chords}
3312 @node Chords
3313 @section Chords
3314 @cindex Chords
3315
3316 LilyPond has support for both entering and printing chords. 
3317 @lilypond[verbatim,singleline]
3318 twoWays = \notes \transpose c c' {
3319   \chords {
3320     c1 f:sus4 bes/f
3321   }
3322   <<c e g>>
3323   <<f bes c'>>
3324   <<f bes d'>>
3325   }
3326
3327 \score {
3328    < \context ChordNames \twoWays
3329      \context Voice \twoWays > }
3330 @end lilypond
3331
3332 This example also shows that the chord printing routines do not try to
3333 be intelligent. If you enter @code{f bes d}, it does not interpret
3334 this as an inversion.
3335
3336 As you can see chords really are a set of pitches. They are internally
3337 stored as simultaneous music expressions. This means you can enter
3338 chords by name and print them as notes, enter them as notes and print
3339 them as chord names, or (the most common case) enter them by name, and
3340 print them as name.
3341
3342 @menu
3343 * Chords mode::                 
3344 * Printing named chords::       
3345 @end menu
3346
3347 @c .  {Chords mode}
3348 @node Chords mode
3349 @subsection Chords mode
3350 @cindex Chords mode
3351
3352 Chord mode is a mode where you can input sets of pitches using common
3353 names.  It is introduced by the keyword @code{\chords}.
3354 In chords mode,  a  chord is entered by the root, which is entered
3355 like a common pitch, for example,
3356 @lilypond[fragment,verbatim]
3357   es4.  d8 c2
3358 @end lilypond
3359 is the notation for an E-flat major chord.
3360
3361 @cindex chord entry
3362 @cindex chord mode
3363
3364 Other chords may be entered
3365 by suffixing a colon, and introducing a modifier, and optionally, a
3366 number, for example
3367 @lilypond[fragment,verbatim]
3368 \chords { e1:m e1:7 e1:m7  }
3369 @end lilypond
3370 The first number following the root is taken to be the `type' of the
3371 chord, thirds are added to the root until it reaches the specified
3372 number, for example.
3373 @lilypond[fragment,verbatim]
3374  \chords { c:3 c:5 c:6 c:7 c:8 c:9 c:10 c:11 }
3375 @end lilypond
3376
3377 @cindex root of chord
3378 @cindex additions, in chords
3379 @cindex removals, in  chords
3380
3381 More complex chords may also be constructed  adding separate steps
3382 to a chord. Additions are added after the  number following
3383 the colon, and are separated by dots. For example
3384 @c
3385 @lilypond[verbatim,fragment]
3386   \chords { c:5.6 c:3.7.8 c:3.6.13 }
3387 @end lilypond
3388 Chord steps can be  altered by suffixing a @code{-} or @code{+} sign
3389 to the number, for example:
3390 @lilypond[verbatim,fragment]
3391   \chords { c:7+ c:5+.3-  c:3-.5-.7- }
3392 @end lilypond
3393 Removals are specified similarly, and are introduced by a caret.  They
3394 must come after the additions.
3395 @lilypond[verbatim,fragment]
3396   \chords { c^3 c:7^5 c:9^3.5 }
3397 @end lilypond
3398
3399 Modifiers can be used to change pitches. The following modifiers are
3400 supported
3401 @table @code
3402 @item m
3403   Minor chord. Lowers the 3rd and (if present) the 7th step.
3404 @item dim
3405   Diminished chord. Lowers the 3rd, 5th and (if present) the 7th step
3406 @item aug
3407   Augmented chord. Raises the 5th step.
3408 @item maj
3409   Major 7th chord. Raises the 7th step, if present.  
3410 @item sus
3411   Suspended 4th or 2nd. This modifier removes the 3rd step. Append
3412   either @code{2} or @code{4} to add the 2nd or 4th step to the chord.
3413 @end table
3414 Modifiers can be mixed with additions. 
3415 @lilypond[verbatim,fragment]
3416   \chords { c:sus4 c:7sus4 c:dim7 c:m6 } 
3417 @end lilypond
3418
3419 @cindex modifiers, in chords. 
3420 @cindex @code{aug}
3421 @cindex @code{dim}
3422 @cindex @code{maj}
3423 @cindex @code{sus}
3424 @cindex @code{m}
3425
3426 Since the unaltered 11 does sound well when combined with the
3427 unaltered 3, the 11 is removed in this case, unless it is added
3428 explicitly). For example,
3429 @lilypond[fragment,verbatim]
3430   \chords { c:13 c:13.11 c:m13 }
3431 @end lilypond 
3432
3433 @cindex @code{/}
3434
3435 An inversion (putting one pitch of the chord on the bottom), as well
3436 as bass notes, can be specified by appending
3437 @code{/}@var{pitch} to the chord. 
3438 @lilypond[fragment,verbatim,center]
3439    \chords { c1 c/g c/f }
3440 @end lilypond 
3441 @cindex @code{/+}
3442 If you do not want to remove the bass note from the chord, but rather
3443 add the note, then you can use @code{/+}@var{pitch}.
3444
3445 @lilypond[fragment,verbatim,center]
3446    \chords { c1 c/+g c/+f }
3447 @end lilypond 
3448
3449
3450 @refbugs
3451
3452 Each step can only be present in a chord once.  The following
3453 simply produces the augmented chord, since @code{5+} is interpreted
3454 last.
3455 @cindex clusters
3456 @lilypond[verbatim,fragment]
3457   \chords { c:5.5-.5+ }
3458 @end lilypond
3459
3460 In chord mode, dashes and carets are used to indicate chord additions
3461 and subtractions, so articulation scripts can not be entered.
3462
3463
3464
3465
3466
3467 @c .  {Printing named chords}
3468 @node Printing named chords
3469 @subsection Printing named chords
3470
3471 @cindex printing chord names
3472 @cindex chord names
3473 @cindex chords
3474
3475 For displaying printed chord names, use the @internalsref{ChordNames} context.
3476 The chords may be entered either using the notation described above, or
3477 directly using simultaneous music.
3478
3479 @lilypond[verbatim,singleline]
3480 scheme = \notes {
3481   \chords {a1 b c} <<d f g>>  <<e g b>>
3482 }
3483 \score {
3484   \notes<
3485     \context ChordNames \scheme
3486     \context Staff \transpose c c' \scheme
3487   >
3488 }
3489 @end lilypond
3490
3491 You can make the chord changes stand out by setting
3492 @code{ChordNames.chordChanges} to true.  This will only display chord
3493 names when there's a change in the chords scheme and at the start of a
3494 new line.
3495
3496 @lilypond[verbatim]
3497 scheme = \chords {
3498   c1:m c:m \break c:m c:m d
3499 }
3500 \score {
3501   \notes <
3502     \context ChordNames {
3503         \property ChordNames.chordChanges = ##t
3504         \scheme }
3505     \context Staff \transpose c c' \scheme
3506   >
3507 \paper{linewidth= 9.\cm}
3508 }
3509 @end lilypond
3510
3511 LilyPond examines chords specified as lists of notes to determine a name
3512 to give the chord. LilyPond will not try to identify chord inversions or
3513 an added bass note, which may result in strange chord names when chords
3514 are entered as a list of pitches:
3515
3516 @lilypond[verbatim,center,singleline]
3517 scheme = \notes {
3518   <<c' e' g'>>1
3519   <<e' g' c''>>
3520   <<e e' g' c''>>
3521 }
3522
3523 \score {
3524   <
3525     \context ChordNames \scheme
3526     \context Staff \scheme
3527   >
3528 }
3529 @end lilypond
3530
3531 The default chord name layout is a system for Jazz music, proposed by
3532 Klaus Ignatzek (See @ref{Literature}).
3533
3534 [TODO: add description for banter other jazz.]
3535
3536 The Ignatzek chord name formatting can be tuned in a number of ways
3537 through the following properties:
3538 @table @code
3539 @item chordNameExceptions
3540 This is a list that contains the chords that have special formatting.
3541 For example.
3542 @lilypond[verbatim,singleline]
3543 chExceptionMusic = \notes { <<c f g bes>>1-\markup { \super "7" "wahh" }}
3544 chExceptions = #(append
3545   (sequential-music-to-chord-exceptions chExceptionMusic)
3546   ignatzekExceptions)
3547
3548 \score {   \context ChordNames
3549     \chords {
3550       c:7sus4 c:dim7
3551       \property ChordNames.chordNameExceptions = #chExceptions
3552       c:7sus4 c:dim7 } }
3553 @end lilypond
3554
3555 Putting the exceptions list encoded as
3556 @example
3557  \notes @{ <<c f g bes>>1-\markup @{ \super "7" "wahh" @} @}
3558 @end example
3559 into the property takes a little manoeuvring. The following code
3560 transforms  @code{chExceptionMusic} (which is a sequential music)
3561 into a list of exceptions.
3562 @example
3563   (sequential-music-to-chord-exceptions chExceptionMusic)
3564 @end example
3565 Then,
3566 @example
3567 #(append
3568   ... ignatzekExceptions)
3569 @end example
3570 adds the new exceptions to the default ones, which are defined in
3571 @file{ly/chord-modifier-init.ly}.
3572
3573 @item majorSevenSymbol
3574 This property contains the markup object used for the 7th step, when
3575 it is major. Predefined options are @code{whiteTriangleMarkup},
3576 @code{blackTriangleMarkup}. The following uses another popular shorthand. 
3577 @lilypond[fragment,verbatim]
3578 \context ChordNames \chords {
3579       c:7
3580       \property ChordNames.majorSevenSymbol = \markup { "j7" }
3581       c:7 } 
3582 @end lilypond
3583 @item chordNameSeparator
3584 Different parts of a chord name are normally separated by a
3585 slash. By setting @code{chordNameSeparator}, you can specify other
3586 separators, e.g.
3587 @lilypond[fragment,verbatim]
3588 \context ChordNames \chords {
3589       c:7sus4
3590       \property ChordNames.chordNameSeparator = \markup { "|" }
3591       c:7sus4 }
3592 @end lilypond
3593 @end table
3594
3595
3596
3597
3598
3599 @node Writing parts
3600 @section Writing parts
3601
3602 Orchestral music involves some special notation, both in the full score,
3603 as in the individual parts. This section explains how to tackle common
3604 problems in orchestral music.
3605
3606
3607 @c .  {Transpose}
3608 @menu
3609 * Rehearsal marks::             
3610 * Bar numbers::                 
3611 * Instrument names::            
3612 * Transpose::                   
3613 * Multi measure rests::         
3614 * Automatic part combining::    
3615 * Hara kiri staves::            
3616 * Sound output for transposing instruments::  
3617 @end menu
3618
3619 @c .   {Rehearsal marks}
3620 @node Rehearsal marks
3621 @subsection Rehearsal marks
3622 @cindex Rehearsal marks
3623 @cindex mark
3624 @cindex @code{\mark}
3625
3626 To print a  rehearsal mark, use the @code{\mark} command. 
3627 @lilypond[fragment,verbatim]
3628 \relative c'' {
3629   c1 \mark "A"
3630   c1 \mark \default
3631   c1 \mark \default 
3632   c1 \mark "12"
3633   c1 \mark \default
3634   c1
3635 }
3636 @end lilypond
3637
3638 As you can see, the mark is incremented automatically if you use
3639 @code{\mark \default}. The value to use is stored in the property
3640 @code{rehearsalMark} is used and automatically incremented.  The object
3641 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3642 @code{input/test/boxed-molecule.ly} if you need boxes around the
3643 marks.
3644
3645 The @code{\mark} command can also be used to put signs like coda,
3646 segno and fermatas on a barline.  The trick is to use the text markup
3647 mechanism to access the fermata symbol.
3648 @lilypond[fragment,verbatim,relative=1]
3649   c1 \mark \markup { \musicglyph #"scripts-ufermata" }
3650   c1
3651 @end lilypond
3652
3653
3654 The problem is that marks that occur at a line break are typeset only
3655 at the beginning of the next line, opposite to what you want for the
3656 fermata. This can be corrected by the following property setting
3657 @example
3658 \property Score.RehearsalMark \override
3659   #'break-visibility = #begin-of-line-invisible
3660 @end example
3661
3662 @cindex fermatas
3663 @cindex coda
3664 @cindex segno
3665 @cindex barlines, putting symbols on 
3666
3667
3668 @node Bar numbers
3669 @subsection Bar numbers
3670
3671
3672 @cindex bar numbers
3673 @cindex measure numbers
3674 @cindex currentBarNumber
3675
3676 Bar numbers are printed by default at the start of the line.  The
3677 number itself is a property that can be set by modifying the
3678 @code{currentBarNumber} property, although that is usually not
3679 necessary, i.e.
3680 @example
3681   \property Score.currentBarNumber = #217
3682 @end example
3683
3684 To typeset Bar Numbers at regular intervals instead of at the beginning of each line,
3685 you need to change the grob property @code{break-visibility} as well as the translator
3686 property @code{barNumberVisibility}, as illustrated in the following example which also
3687 adds a box around the bar numbers:
3688 @example
3689 \property Score.BarNumber \override #'break-visibility =
3690   #end-of-line-invisible
3691 \property Score.barNumberVisibility = #(every-nth-bar-number-visible 5)
3692 \property Score.BarNumber \override #'molecule-callback =
3693   #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule)
3694 \property Score.BarNumber \override #'font-relative-size = #0
3695 @end example
3696 @lilypond[noindent,noquote]
3697 \score {
3698     \context Staff \notes \transpose c c'' {
3699         \property Score.BarNumber \override #'break-visibility = #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         
3705         \repeat unfold 16 c1 \bar "|."
3706     }
3707 }
3708 @end lilypond
3709
3710 If you would like the bar numbers to appear at regular intervals, but
3711 not starting from measure zero, you can use the context function,
3712 @code{set-bar-number-visibility}, to automatically set
3713 @code{barNumberVisibility} so that the bar numbers appear at regular
3714 intervals, starting from the @code{\applycontext}:
3715
3716 @example
3717 resetBarnum = \context Score \applycontext
3718   #(set-bar-number-visibility 4)
3719 ...
3720 \property Score.BarNumber \override #'break-visibility =
3721   #end-of-line-invisible
3722 \mark "A" \resetBarnum
3723 \repeat unfold 10 c1
3724 \mark \default \resetBarnum
3725 \repeat unfold 8 c
3726 @end example
3727 @lilypond[noindent,noquote]
3728 resetBarnum = \context Score \applycontext
3729   #(set-bar-number-visibility 4)
3730 \score {
3731     <
3732         \notes \transpose c c'' {
3733             \property Score.BarNumber \override #'break-visibility =#end-of-line-invisible
3734             \property Score.RehearsalMark \override #'padding = #2.5
3735             \mark "A" \resetBarnum
3736             \repeat unfold 10 c1
3737             \mark \default \resetBarnum
3738             \repeat unfold 8 c
3739             \bar "|."
3740         }
3741     >
3742 }
3743 @end lilypond
3744
3745 See also @seeinternals{BarNumber}.
3746
3747 @refbugs
3748
3749 Barnumbers can collide with the StaffGroup, if there is one at the
3750 top. To solve this, You have to twiddle with the
3751 @internalsref{padding} property of @internalsref{BarNumber} if your
3752 score starts with a @internalsref{StaffGroup}.
3753
3754 @node Instrument names
3755 @subsection Instrument names
3756
3757 In scores, the instrument name is printed before the staff. This can
3758 be done by setting @code{Staff.instrument} and
3759 @code{Staff.instr}. This will print a string before the start of the
3760 staff. For the first start, @code{instrument} is used, for the next
3761 ones @code{instr} is used.
3762
3763 @lilypond[verbatim,singleline]
3764   \property Staff.instrument = "ploink " { c''4 }  
3765 @end lilypond
3766
3767 You can also use markup texts to construct more complicated instrument
3768 names:
3769
3770
3771 @lilypond[verbatim,singleline]
3772 \score {
3773   \notes \context Staff = treble {
3774     \property Staff.instrument
3775         = \markup { \column << "Clarinetti" { "in B" \smaller \musicglyph #"accidentals--1" } >> }
3776     { c''1 }
3777   }
3778   \paper { linewidth= 8.0\cm }
3779 }
3780 @end lilypond
3781
3782
3783 @refbugs
3784
3785 When you put a name on a grand staff or piano staff the width of the
3786 brace is not taken into account. You must add extra spaces to the end of
3787 the name to avoid a collision.
3788
3789 @node Transpose
3790 @subsection Transpose
3791 @cindex Transpose
3792 @cindex transposition of pitches
3793 @cindex @code{\transpose}
3794
3795 A music expression can be transposed with @code{\transpose}.  The syntax
3796 is
3797 @example
3798   \transpose @var{from} @var{to} @var{musicexpr}
3799 @end example
3800
3801 This means that @var{musicexpr} is transposed to by the interval
3802 between @var{from} is @var{to}.
3803
3804 @code{\transpose} distinguishes between enharmonic pitches: both
3805 @code{\transpose c cis} or @code{\transpose c des} will transpose up
3806 half a tone.  The first version will print sharps and the second
3807 version will print flats.
3808
3809 @lilypond[singleline, verbatim]
3810 mus =\notes { \key d \major cis d fis g }
3811 \score { \notes \context Staff {
3812   \clef "F" \mus
3813   \clef "G"
3814   \transpose c g' \mus
3815   \transpose c f' \mus
3816 }}
3817 @end lilypond
3818
3819 If you want to use both @code{\transpose} and @code{\relative}, then
3820 you must use @code{\transpose} first.  @code{\relative} will have no
3821 effect music that appears inside a @code{\transpose}.
3822
3823 @c .  {Multi measure rests}
3824 @node  Multi measure rests
3825 @subsection Multi measure rests
3826 @cindex Multi measure rests
3827
3828 @cindex @code{R}
3829
3830 Multi measure rests are entered using `@code{R}'. It is specifically
3831 meant for full bar rests and for entering parts: the rest can expand to
3832 fill a score with rests, or it can be printed as a single multimeasure
3833 rest This expansion is controlled by the property
3834 @code{Score.skipBars}. If this is set to true, Lily will not expand
3835 empty measures, and the appropriate number is added automatically.
3836
3837 @lilypond[fragment,verbatim]
3838  \time 4/4 r1 | R1 | R1*2
3839  \property Score.skipBars = ##t R1*17  R1*4
3840 @end lilypond
3841
3842 The @code{1} in @code{R1} is similar to the duration notation used for
3843 notes. Hence, for time signatures other than 4/4, you must enter other
3844 durations.  This can be done with augmentation dots, or with
3845 fractions:
3846
3847 @lilypond[fragment,verbatim]
3848  \property Score.skipBars = ##t
3849  \time 3/4
3850   R2. | R2.*2
3851  \time 13/8
3852  R1*13/8
3853  R1*13/8*12
3854 @end lilypond
3855 Notice that a @code{R} spanning a single measure is printed as a whole
3856 rest centered in the measure, regardless of the time signature.
3857
3858 [ add note about breves.]
3859  
3860
3861 @cindex text on multi-measure rest
3862 @cindex script on multi-measure rest
3863 @cindex fermata on multi-measure rest
3864
3865 Texts can be added to multi-measure rests by using the
3866 @var{note}-@code{markup} syntax.  An identifier
3867 is provided for a fermata. 
3868
3869 @lilypond[verbatim,fragment]
3870   \time 3/4
3871   R2._\markup { \roman "Ad lib" }
3872   R2.^\fermataMarkup
3873 @end lilypond
3874 By default, the multi-measure rest uses the number font, which does
3875 not contain any letters. This is the reason for the explicit
3876 @code{\roman} in the above example.
3877
3878 @cindex whole rests for a full measure 
3879
3880 The object for this object is @internalsref{MultiMeasureRest}, and
3881 @internalsref{MultiMeasureRestNumber}.
3882
3883 @refbugs
3884
3885 Only one text can be put on a multi-measure rest with
3886 @var{note}-@var{text} syntax, since this is internally converted to
3887 setting @code{#'text} in @internalsref{MultiMeasureRestNumber}. It is
3888 not possible to use fingerings (e.g. @code{R1-4}) to put numbers over
3889 multi-measure rests.
3890
3891
3892 @cindex condensing rests
3893
3894 Currently, there is no way to automatically condense multiple rests
3895 into a single multimeasure rest. Multi measure rests do not take part
3896 in rest collisions.
3897
3898
3899 @node Automatic part combining
3900 @subsection Automatic part combining
3901 @cindex automatic part combining
3902 @cindex part combiner
3903
3904
3905 Automatic part combining is used to merge two parts of music onto a
3906 staff in an intelligent way.  It is aimed primarily at typesetting
3907 orchestral scores.  When the two parts are identical for a period of
3908 time, only one is shown.  In places where the two parts differ, they
3909 are typeset as separate voices, and stem directions are set
3910 automatically.  Also, solo and @emph{a due} parts can be identified
3911 and marked.
3912
3913 The syntax for part combining is
3914
3915 @example
3916   \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3917 @end example
3918 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3919 combined into one context of type @var{context}.  The music expressions
3920 must be interpreted by contexts whose names should start with @code{one}
3921 and @code{two}.
3922
3923 The most useful function of the part combiner is to combine parts into
3924 one voice, as common for wind parts in orchestral scores:
3925
3926 @lilypond[verbatim,singleline,fragment]
3927   \context Staff <
3928     \context Voice=one \partcombine Voice
3929       \context Thread=one \relative c'' {
3930         g a () b r
3931       }
3932       \context Thread=two \relative c'' {
3933         g r4 r f
3934       }
3935   >
3936 @end lilypond
3937
3938 Notice that the first @code{g} appears only once, although it was
3939 specified twice (once in each part).  Stem, slur and tie directions are
3940 set automatically, depending whether there is a solo or unisono. The
3941 first part (with context called @code{one}) always gets up stems, and
3942 `solo', while the second (called @code{two}) always gets down stems and
3943 `Solo II'.
3944
3945 If you just want the merging parts, and not the textual markings, you
3946 may set the property @var{soloADue} to false.
3947
3948 @lilypond[verbatim,singleline,fragment]
3949   \context Staff <
3950     \property Staff.soloADue = ##f
3951     \context Voice=one \partcombine Voice
3952       \context Thread=one \relative c'' {
3953         b4 a c g
3954       }
3955       \context Thread=two \relative c'' {
3956         d,2 a4 g'
3957       }
3958   >
3959 @end lilypond
3960
3961 There are a number of other properties that you can use to tweak the
3962 behavior of part combining, refer to the automatically generated
3963 documentation of @reng{Thread_devnull_engraver} and
3964 @reng{Voice_devnull_engraver}. Look at the documentation of the
3965 responsible engravers, @code{Thread_devnull_engraver},
3966 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3967
3968 @refbugs
3969
3970 In @code{soloADue} mode, when the two voices play the same notes on and
3971 off, the part combiner may typeset @code{a2} more than once in a
3972 measure.
3973
3974 @lilypond[fragment,singleline]
3975   \context Staff <
3976     \context Voice=one \partcombine Voice
3977       \context Thread=one \relative c'' {
3978         c b c b c a c a
3979       }
3980       \context Thread=two \relative c'' {
3981         b b b b f a f a
3982       }
3983   >
3984 @end lilypond
3985
3986 @cindex @code{Thread_devnull_engraver}
3987 @cindex @code{Voice_engraver}
3988 @cindex @code{A2_engraver}
3989
3990 @node Hara kiri staves
3991 @subsection Hara kiri staves
3992
3993 In orchestral scores, staff lines that only have rests are usually removed.
3994 This saves some space.  LilyPond also supports this through the hara
3995 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3996 the Japanese Samourai warriors.} staff. This staff commits suicide when
3997 it finds itself to be empty after the line-breaking process.  It will
3998 not disappear when it contains normal rests, you must use multi measure
3999 rests.
4000
4001 The hara kiri staff is specialized version of the @internalsref{Staff}
4002 context. It is available as the context identifier
4003 @code{\HaraKiriStaffContext}.  Observe how the second staff in this
4004 example disappears in the second line.
4005
4006 @lilypond[verbatim]
4007 \score  {
4008   \notes \relative c' <
4009     \context Staff = SA { e4 f g a \break c1 }
4010     \context Staff = SB { c4 d e f \break R1 }
4011   >
4012   \paper {
4013     linewidth = 6.\cm 
4014     \translator { \HaraKiriStaffContext }
4015   }
4016 }
4017 @end lilypond
4018
4019
4020 @node Sound output for transposing instruments
4021 @subsection Sound output for transposing instruments
4022
4023 When you want to make a MIDI file from a score containing transposed
4024 and untransposed instruments, you have to instruct LilyPond the pitch
4025 offset (in semitones) for the transposed instruments. This is done
4026 using the @code{transposing} property. It does not affect printed
4027 output.
4028
4029 @cindex @code{transposing}
4030
4031 @example
4032         \property Staff.instrument = #"Cl. in B-flat"
4033         \property Staff.transposing = #-2
4034 @end example
4035
4036
4037
4038 @c . {Custodes}
4039 @node Ancient notation 
4040 @section Ancient notation
4041
4042 @cindex Vaticana, Editio
4043 @cindex Medicaea, Editio
4044 @cindex hufnagel
4045 @cindex Petrucci
4046 @cindex mensural
4047
4048 @menu
4049 * Ancient note heads::          
4050 * Ancient clefs ::              
4051 * Custodes::                    
4052 * Ligatures::                   
4053 * Figured bass::                
4054 @end menu
4055
4056
4057 @node Ancient note heads
4058 @subsection Ancient note heads
4059
4060 To get a longa note head, you have to use mensural note heads. This
4061 is accomplished by setting the @code{style} property of the
4062 NoteHead object to @code{mensural}. There is also a note head style
4063 @code{baroque} which gives mensural note heads for @code{\longa} and
4064 @code{\breve} but standard note heads for shorter notes.
4065
4066 @lilypond[fragment,singleline,verbatim]
4067  \property Voice.NoteHead \set #'style = #'mensural
4068  a'\longa
4069 @end lilypond
4070
4071 @node Ancient clefs 
4072 @subsection Ancient clefs
4073
4074 LilyPond supports a variety of clefs, many of them ancient.
4075
4076 For modern clefs, see section @ref{Clef}.  For the percussion clef, see
4077 section @ref{Percussion staves}.  For the @code{TAB} clef, see section
4078 @ref{Tablatures}.
4079
4080 The following table shows all ancient clefs that are supported via the
4081 @code{\clef} command.  Some of the clefs use the same glyph, but differ
4082 only with respect to the line they are printed on.  In such cases, a
4083 trailing number in the name is used to enumerate these clefs.  Still,
4084 you can manually force a clef glyph to be typeset on an arbitrary line,
4085 as described in section @ref{Clef}.  The note printed to the right side
4086 of each clef denotes the @code{c'} with respect to the clef.
4087
4088 @table @code
4089
4090 @c --- This should go somewhere else: ---
4091 @c @item modern style G clef (glyph: @code{clefs-G})
4092 @c
4093 @c Supported clefs:
4094 @c @code{treble}, @code{violin}, @code{G}, @code{G2}, @code{french}
4095 @c
4096 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "G" c'}
4097 @c
4098 @c @item modern style F clef (glyph: @code{clefs-F})
4099 @c
4100 @c Supported clefs:
4101 @c @code{varbaritone}, @code{bass}, @code{F}, @code{subbass}
4102 @c
4103 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "F" c'}
4104 @c
4105 @c @item modern style C clef (glyph: @code{clefs-C})
4106 @c
4107 @c Supported clefs:
4108 @c @code{soprano}, @code{mezzosoprano}, @code{alto}, @code{C},
4109 @c @code{tenor}, @code{baritone}
4110 @c
4111 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "C" c'}
4112
4113 @item modern style mensural C clef (glyph: @code{clefs-neo_mensural_c'})
4114
4115 Supported clefs:
4116 @code{neo_mensural_c1}, @code{neo_mensural_c2},
4117 @code{neo_mensural_c3}, @code{neo_mensural_c4}
4118
4119 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "neo_mensural_c2" c'}
4120
4121 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c1})
4122
4123 Supported clefs:
4124 @code{petrucci_c1}
4125 for 1st staffline
4126
4127 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c1" c'}
4128
4129 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c2})
4130
4131 Supported clefs:
4132 @code{petrucci_c2}
4133 for 2nd staffline
4134
4135 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c2" c'}
4136
4137 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c3})
4138
4139 Supported clefs:
4140 @code{petrucci_c3}
4141 for 3rd staffline
4142
4143 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c3" c'}
4144
4145 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c4})
4146
4147 Supported clefs:
4148 @code{petrucci_c4}
4149 for 4th staffline
4150
4151 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c4" c'}
4152
4153 @item petrucci style mensural C clef (glyph: @code{clefs-petrucci_c5})
4154
4155 Supported clefs:
4156 @code{petrucci_c5}
4157 for 5th staffline
4158
4159 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_c5" c'}
4160
4161 @item petrucci style mensural F clef (glyph: @code{clefs-petrucci_f})
4162
4163 Supported clefs:
4164 @code{petrucci_f}
4165
4166 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_f" c'}
4167
4168 @item petrucci style mensural G clef (glyph: @code{clefs-petrucci_g})
4169
4170 Supported clefs:
4171 @code{petrucci_g}
4172
4173 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "petrucci_g" c'}
4174
4175 @item historic style mensural C clef (glyph: @code{clefs-mensural_c'})
4176
4177 Supported clefs:
4178 @code{mensural_c1}, @code{mensural_c2}, @code{mensural_c3},
4179 @code{mensural_c4}
4180
4181 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_c2" c'}
4182
4183 @item historic style mensural F clef (glyph: @code{clefs-mensural_f})
4184
4185 Supported clefs:
4186 @code{mensural_f}
4187
4188 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_f" c'}
4189
4190 @item historic style mensural G clef (glyph: @code{clefs-mensural_g})
4191
4192 Supported clefs:
4193 @code{mensural_g}
4194
4195 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "mensural_g" c'}
4196
4197 @item Editio Vaticana style do clef (glyph: @code{clefs-vaticana_do})
4198
4199 Supported clefs:
4200 @code{vaticana_do1}, @code{vaticana_do2}, @code{vaticana_do3}
4201
4202 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_do2" c'}
4203
4204 @item Editio Vaticana style fa clef (glyph: @code{clefs-vaticana_fa})
4205
4206 Supported clefs:
4207 @code{vaticana_fa1}, @code{vaticana_fa2}
4208
4209 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "vaticana_fa2" c'}
4210
4211 @item Editio Medicaea style do clef (glyph: @code{clefs-medicaea_do})
4212
4213 Supported clefs:
4214 @code{medicaea_do1}, @code{medicaea_do2}, @code{medicaea_do3}
4215
4216 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_do2" c'}
4217
4218 @item Editio Medicaea style fa clef (glyph: @code{clefs-medicaea_fa})
4219
4220 Supported clefs:
4221 @code{medicaea_fa1}, @code{medicaea_fa2}
4222
4223 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "medicaea_fa2" c'}
4224
4225 @item historic style hufnagel do clef (glyph: @code{clefs-hufnagel_do})
4226
4227 Supported clefs:
4228 @code{hufnagel_do1}, @code{hufnagel_do2}, @code{hufnagel_do3}
4229
4230 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do2" c'}
4231
4232 @item historic style hufnagel fa clef (glyph: @code{clefs-hufnagel_fa})
4233
4234 Supported clefs:
4235 @code{hufnagel_fa1}, @code{hufnagel_fa2}
4236
4237 @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #4 \property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_fa2" c'}
4238
4239 @item historic style hufnagel combined do/fa clef (glyph: @code{clefs-hufnagel_do_fa})
4240
4241 Supported clefs:
4242 @code{hufnagel_do_fa}
4243
4244 @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "hufnagel_do_fa" c'}
4245
4246 @c --- This should go somewhere else: ---
4247 @c @item modern style percussion clef (glyph: @code{clefs-percussion})
4248 @c
4249 @c Supported clefs:
4250 @c @code{percussion}
4251 @c
4252 @c @lilypond[26pt]{\property Staff.TimeSignature \set #'transparent = ##t \clef "percussion" c'}
4253 @c
4254 @c @item modern style tab clef (glyph: @code{clefs-tab})
4255 @c
4256 @c Supported clefs:
4257 @c @code{tab}
4258 @c
4259 @c @lilypond[26pt]{\context Staff \outputproperty #(make-type-checker 'staff-symbol-interface) #'line-count = #6 \property Staff.TimeSignature \set #'transparent = ##t \clef "tab" c'}
4260
4261 @end table
4262
4263 @emph{Modern style} means ``as is typeset in current editions of
4264 transcribed mensural music''.
4265
4266 @emph{Petrucci style} means ``inspired by printings published by the
4267 famous engraver Petrucci (1466-1539)''.
4268
4269 @emph{Historic style} means ``as was typeset or written in contemporary
4270 historic editions (other than those of Petrucci)''.
4271
4272 @emph{Editio XXX style} means ``as is/was printed in Editio XXX''.
4273
4274 Petrucci used C clefs with differently balanced left-side vertical
4275 beams, depending on which staffline it was printed.
4276
4277 @node Custodes
4278 @subsection Custodes
4279
4280 @cindex Custos
4281 @cindex Custodes
4282
4283 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
4284 staff context symbol that appears at the end of a staff line.  It
4285 anticipates the pitch of the first note(s) of the following line and
4286 thus helps the player or singer to manage line breaks during
4287 performance, thus enhancing readability of a score.
4288
4289 @lilypond[verbatim,noquote]
4290 \score {
4291   \notes { c'1 \break
4292         \property Staff.Custos \set #'style = #'mensural
4293         d' }
4294   \paper {
4295     \translator {
4296       \StaffContext
4297       \consists Custos_engraver
4298     }
4299   }
4300 }
4301 @end lilypond
4302
4303 Custodes were frequently used in music notation until the 17th century.
4304 There were different appearances for different notation styles.
4305 Nowadays, they have survived only in special forms of musical notation
4306 such as via the @emph{editio vaticana} dating back to the beginning of
4307 the 20th century.
4308
4309 For typesetting custodes, just put a @code{Custos_engraver} into the
4310 @internalsref{Staff} context when declaring the @code{\paper} block.  In this
4311 block, you can also globally control the appearance of the custos symbol
4312 by setting the custos @code{style} property.  Currently supported styles
4313 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
4314 @code{mensural}.
4315
4316 @example
4317 \paper @{
4318   \translator @{
4319       \StaffContext
4320       \consists Custos_engraver
4321       Custos \override #'style = #'mensural
4322   @}
4323 @}
4324 @end example
4325
4326 The property can also be set locally, for example in a @code{\notes}
4327 block:
4328
4329 @example
4330 \notes @{
4331   \property Staff.Custos \override #'style = #'vaticana
4332   c'1 d' e' d' \break c' d' e' d'
4333 @}
4334 @end example
4335
4336 @node Ligatures
4337 @subsection Ligatures
4338
4339 @cindex Ligatures
4340
4341 @c TODO: Should double check if I recalled things correctly when I wrote
4342 @c down the following paragraph by heart.
4343 In musical terminology, a ligature is a coherent graphical symbol that
4344 represents at least two different notes.  Ligatures originally appeared
4345 in the manuscripts of Gregorian chant notation roughly since the 9th
4346 century as an allusion to the accent symbols of greek lyric poetry to
4347 denote ascending or descending sequences of notes.  Both, the shape and
4348 the exact meaning of ligatures changed tremendously during the following
4349 centuries: In early notation, ligatures where used for monophonic tunes
4350 (Gregorian chant) and very soon denoted also the way of performance in
4351 the sense of articulation.  With upcoming multiphony, the need for a
4352 metric system arised, since multiple voices of a piece have to be
4353 synchronized some way.  New notation systems were invented, that used
4354 the manifold shapes of ligatures to now denote rhythmical patterns
4355 (e.g. black mensural notation, mannered notation, ars nova).  With the
4356 invention of the metric system of the white mensural notation, the need
4357 for ligatures to denote such patterns disappeared.  Nevertheless,
4358 ligatures were still in use in the mensural system for a couple of
4359 decades until they finally disappeared during the late 16th / early 17th
4360 century.  Still, ligatures have survived in contemporary editions of
4361 Gregorian chant such as the Editio Vaticana from 1905/08.
4362
4363 Syntactically, ligatures are simply enclosed by @code{\[} and @code{\]}.
4364 Some ligature styles (such as Editio Vaticana) may need additional input
4365 syntax specific for this particular type of ligature.  By default, the
4366 @internalsref{LigatureBracket} engraver just marks the start and end of
4367 a ligature by small square angles:
4368
4369 @lilypond[singleline,verbatim]
4370 \score {
4371     \notes \transpose c c' {
4372         \[ g c a f d' \]
4373         a g f
4374         \[ e f a g \]
4375     }
4376 }
4377 @end lilypond
4378
4379 To select a specific style of ligatures, a proper ligature engraver has
4380 to be added to the @internalsref{Voice} context, as explained in the
4381 following subsections.  Currently, Lilypond only supports white mensural
4382 ligatures with certain limitations.  Support for Editio Vaticana will be
4383 added in the future.
4384
4385 @menu
4386 * White mensural ligatures::    
4387 @end menu
4388
4389 @node White mensural ligatures
4390 @subsubsection White mensural ligatures
4391
4392 @cindex Mensural ligatures
4393 @cindex White mensural ligatures
4394
4395 Lilypond has limited support for white mensural ligatures.  The
4396 implementation is still experimental; it currently may output strange
4397 warnings or even crash in some cases or produce weird results on more
4398 complex ligatures.  To engrave white mensural ligatures, in the paper
4399 block the @internalsref{MensuralLigature} engraver has to be put into
4400 the @internalsref{Voice} context (and you probably want to remove the
4401 @internalsref{LigatureBracket} engraver).  There is no additional input
4402 language to describe the shape of a white mensural ligature.  The shape
4403 is rather determined solely from the pitch and duration of the enclosed
4404 notes.  While this approach may take a new user quite a while to get
4405 accustomed, it has a great advantage: this way, lily has full musical
4406 information about the ligature.  This is not only required for correct
4407 MIDI output, but also allows for automatic transcription of the
4408 ligatures.
4409
4410 Example:
4411
4412 @lilypond[singleline,verbatim]
4413 \score {
4414     \notes \transpose c c' {
4415         \property Score.timing = ##f
4416         \property Score.defaultBarType = "empty"
4417         \property Voice.NoteHead \set #'style = #'neo_mensural
4418         \property Staff.TimeSignature \set #'style = #'neo_mensural
4419         \clef "petrucci_g"
4420         \[ g\longa c\breve a\breve f\breve d'\longa \]
4421         s4
4422         \[ e1 f1 a\breve g\longa \]
4423     }
4424     \paper {
4425         \translator {
4426             \VoiceContext
4427             \remove Ligature_bracket_engraver
4428             \consists Mensural_ligature_engraver
4429         }
4430     }
4431 }
4432 @end lilypond
4433
4434 Without replacing @code{Ligature_bracket_engraver} with
4435 @code{Mensural_ligature_engraver}, the same music transcribes to the
4436 following:
4437
4438 @lilypond[singleline,verbatim]
4439 \score {
4440     \notes \transpose c c' {
4441         \property Score.timing = ##f
4442         \property Score.defaultBarType = "empty"
4443         \property Voice.NoteHead \set #'style = #'neo_mensural
4444         \property Staff.TimeSignature \set #'style = #'neo_mensural
4445         \clef "petrucci_g"
4446         \[ g\longa c\breve a\breve f\breve d'\longa \]
4447         s4
4448         \[ e1 f1 a\breve g\longa \]
4449     }
4450 }
4451 @end lilypond
4452
4453 @node Figured bass
4454 @subsection Figured bass
4455
4456 @cindex Basso continuo
4457
4458 LilyPond has limited support for figured bass:
4459
4460 @lilypond[verbatim,fragment]
4461 <
4462  \context FiguredBass
4463    \figures {
4464         <_! 3+ 5- >4
4465         < [4 6] 8 >
4466    }
4467  \context Voice { c4 g8 }
4468 >
4469 @end lilypond
4470
4471 The support for figured bass consists of two parts: there is an input
4472 mode, introduced by @code{\figures}, where you can enter bass figures
4473 as numbers, and there is a context called @internalsref{FiguredBass}
4474 that takes care of making @internalsref{BassFigure} objects.
4475
4476 In figures input mode, a group of bass figures is delimited by
4477 @code{<} and @code{>}. The duration is entered after the @code{>}.
4478 @example
4479         <4 6>
4480 @end example
4481 @lilypond[fragment]
4482 \context FiguredBass
4483 \figures { <4 6> }
4484 @end lilypond
4485
4486 Accidentals are added to the numbers if you alterate them by
4487 appending @code{-}, @code{!}  and @code{+}.
4488
4489 @example
4490   <4- 6+ 7!>
4491 @end example
4492 @lilypond[fragment]
4493   \context FiguredBass
4494 \figures { <4- 6+ 7!> }
4495 @end lilypond
4496
4497 Spaces or dashes may be inserted by using @code{_}. Brackets are
4498 introduced with @code{[} and @code{]}.
4499
4500 @example
4501         < [4 6] 8 [_ 12]>
4502 @end example
4503 @lilypond[fragment]
4504  \context FiguredBass
4505 \figures { < [4 6] 8 [_ 12]> }
4506 @end lilypond
4507
4508 Although the support for figured bass may superficially resemble chord
4509 support, it works much simpler: in figured bass simply stores the
4510 numbers, and then prints the numbers you entered. There is no
4511 conversion to pitches, and no realizations of the bass are played in
4512 the MIDI file.
4513
4514
4515 @c . {Contemporary notation}
4516 @node Contemporary notation
4517 @section Contemporary notation
4518
4519 @menu
4520 * Clusters::
4521 @end menu
4522
4523 @node Clusters
4524 @subsection Clusters
4525
4526 @cindex cluster
4527
4528 In musical terminology, a @emph{cluster} denotes a range of
4529 simultaneously sounding pitches that may change over time.  The set of
4530 available pitches to apply usually depends on the accoustic source.
4531 Thus, in piano music, a cluster typically consists of a continous range
4532 of the semitones as provided by the piano's fixed set of a chromatic
4533 scale.  In choral music, each singer of the choir typically may sing an
4534 arbitrary pitch within the cluster's range that is not bound to any
4535 diatonic, chromatic or other scale.  In electronic music, a cluster
4536 (theoretically) may even cover a continuous range of pitches, thus
4537 resulting in coloured noise, such as pink noise.
4538
4539 Clusters can be notated in the context of ordinary staff notation by
4540 engraving simple geometrical shapes that replace ordinary notation of
4541 notes.  Ordinary notes as musical events specify starting time and
4542 duration of pitches; however, the duration of a note is expressed by the
4543 shape of the note head rather than by the horizontal graphical extent of
4544 the note symbol.  In contrast, the shape of a cluster geometrically
4545 describes the development of a range of pitches (vertical extent) over
4546 time (horizontal extent).  Still, the geometrical shape of a cluster
4547 covers the area in wich any single pitch contained in the cluster would
4548 be notated as an ordinary note.  From this point of view, it is
4549 reasonable to specify a cluster as the envelope of a set of notes.  This
4550 is exactly how to construct a cluster with lilypond.
4551
4552 @lilypond[singleline,verbatim]
4553 \score {
4554     \context PianoStaff <
4555         \context Voice = voiceI { % same as voiceII, but with ordinary notes
4556             \notes \relative c' {
4557                 c4 f4
4558                 a4 <e4 d'4> | \break
4559                 < g8 a8 > < e8 a8 > a4 c1 < d4 b4 > e4 |
4560                 c4 a4 f4 g4 a4
4561             }
4562         }
4563         \context Voice = voiceII { % same as voiceI, but with cluster notation
4564             \notes \relative c' {
4565
4566                 % hide notes, accidentals, etc.
4567                 \property Thread.NoteHead \set #'transparent = ##t
4568                 \property Voice.Stem \set #'transparent = ##t
4569                 \property Voice.Beam \set #'transparent = ##t
4570                 \property Staff.Accidental \set #'transparent = ##t
4571
4572                 \property Voice.Cluster \set #'padding = #0.01
4573                 \property Voice.Cluster \set #'shape = #'ramp
4574
4575                 c4 f4
4576                 \startCluster
4577                 a4 <e4 d'4> | \break
4578                 < g8 a8 > < e8 a8 > a4 c1 < d4 b4 > e4 |
4579                 c4 \stopCluster a4 f4 g4 a4
4580             }
4581         }
4582     >
4583 }
4584 @end lilypond
4585
4586 Note that the second voice differs from the first one only by the
4587 additional keywords @code{\startCluster} and @code{\stopCluster} and the
4588 fact that notes, accidentals, etc. are hidden.  A future version of
4589 lilypond may automatically hide notes, accidentals, etc. within the
4590 scope of clusters.
4591
4592 Also note that a music expression like @code{< @{ g8 e8 @} a4 >} is
4593 illegal; in such a case, you can instead use the expression @code{< g8
4594 a8 > < e8 a8 >}.
4595
4596 By default, cluster engraver is in the voice context.  This allows
4597 putting ordinary notes and clusters together in the same staff, even
4598 simultaneously.  However, in such a case no attempt is made to
4599 automatically avoid collisions between ordinary notes and clusters.
4600
4601 The geometrical shape can be further controlled with grob properties
4602 @code{padding} and @code{shape}.  @code{padding} adds to the vertical
4603 extent of the shape (top and bottom) and is expressed in units of
4604 staffspace.  Since the pitch range of a single pitch is infinitely
4605 small, if padding is set to @code{0.0}, this possibly results in an
4606 invisible shape, if you,for example, say @code{ \startCluster c d e
4607 \endCluster}.  The default value for @code{padding} therefore is
4608 @code{0.25}, such that a single pitch roughly shows the same height as a
4609 note head.  Property @code{shape} controls how the overall shape of the
4610 cluster is constructed from the set of notes.  Currently supported
4611 values are @code{leftsided-stairs}, @code{rightsided-stairs},
4612 @code{centered-stairs}, and @code{ramp}.
4613
4614 @c . {Tuning output}
4615 @node Tuning output
4616 @section Tuning output
4617
4618 LilyPond tries to take as much formatting as possible out of your
4619 hands. Nevertheless, there are situations where it needs some help, or
4620 where you want to override its decisions. In this section we discuss
4621 ways to do just that.
4622
4623 Formatting is internally done by manipulating so called objects (graphic
4624 objects). Each object carries with it a set of properties (object
4625 properties) specific to that object.  For example, a stem object has
4626 properties that specify its direction, length and thickness.
4627
4628 The most direct way of tuning the output is by altering the values of
4629 these properties. There are two ways of doing that: first, you can
4630 temporarily change the definition of a certain type of object, thus
4631 affecting a whole set of objects.  Second, you can select one specific
4632 object, and set a object property in that object.
4633
4634 @menu
4635 * Tuning groups of objects ::   
4636 * Tuning per object ::          
4637 * Font selection::              
4638 * Text markup::                 
4639 @end menu
4640
4641 @node Tuning groups of objects 
4642 @subsection Tuning groups of objects 
4643
4644 @cindex object description
4645
4646 A object definition is a Scheme association list, that is stored in a
4647 context property.  By assigning to that property (using plain
4648 @code{\property}), you can change the resulting objects.
4649
4650 @lilypond[verbatim, fragment]
4651 c'4 \property Voice.NoteHead  = #'() c'4
4652 @end lilypond
4653 This mechanism is fairly crude, since you can only set, but not modify,
4654 the definition of an object. Also, it will thoroughly confuse LilyPond.
4655
4656 The definition of an object is actually a list of default object
4657 properties. For example, the definition of the Stem object (available
4658 in @file{scm/grob-description.scm}), includes the following definitions for
4659 @internalsref{Stem}
4660
4661 @example
4662         (thickness . 0.8)
4663         (beamed-lengths . (0.0 2.5 2.0 1.5))
4664         (Y-extent-callback . ,Stem::height)
4665         @var{...}
4666 @end example
4667
4668 You can add a property on top of the existing definition, or remove a
4669 property, thus overriding the system defaults:
4670 @lilypond[verbatim]
4671 c'4 \property Voice.Stem \override #'thickness = #4.0
4672 c'4 \property Voice.Stem \revert #'thickness
4673 c'4
4674 @end lilypond
4675 You should balance @code{\override} and @code{\revert}. If that's too
4676 much work, you can use the @code{\set} shorthand. It performs a revert
4677 followed by an override. The following example gives exactly the same
4678 result as the previous one. 
4679 @lilypond[verbatim]
4680 c'4 \property Voice.Stem \set #'thickness = #4.0
4681 c'4 \property Voice.Stem \set #'thickness = #0.8
4682 c'4
4683 @end lilypond
4684 If you use @code{\set}, you must explicitly restore the default.
4685
4686
4687 Formally the syntax for these constructions is
4688 @example
4689 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
4690 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
4691 \property @var{context}.@var{grobname} \revert @var{symbol}
4692 @end example
4693 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
4694 and @var{grobname} are strings and @var{value} is a Scheme expression.
4695
4696
4697 If you revert a setting which was not set in the first place, then it
4698 has no effect. However, if the setting was set as a system default, it
4699 may remove the default value, and this may give surprising results,
4700 including crashes.  In other words, @code{\override} and @code{\revert},
4701 must be carefully balanced.
4702
4703 These are examples of correct nesting of @code{\override}, @code{\set},
4704 @code{\revert}. 
4705
4706 A clumsy but correct form:
4707 @example
4708   \override \revert \override \revert \override \revert
4709 @end example
4710
4711 Shorter version of the same:
4712 @example 
4713   \override \set \set  \revert
4714 @end example
4715
4716 A short form, using only @code{\set}. This requires you to know the
4717 default value:
4718 @example
4719   \set \set \set \set @var{to default value}
4720 @end example
4721
4722 If there is no default (i.e. by default, the object property is unset),
4723 then you can use
4724 @example
4725   \set \set \set \revert
4726 @end example
4727
4728 For the digirati, the object description is an Scheme association
4729 list. Since a Scheme list is a singly linked list, we can treat it as a
4730 stack, and @code{\override} and @code{\revert} are just push and pop
4731 operations. This pushing and popping is also used for overriding
4732 automatic beaming settings.
4733
4734 @refbugs
4735
4736 LilyPond will hang or crash if @var{value} contains cyclic references.
4737 The backend is not very strict in type-checking object properties. If you
4738 @code{\revert} properties that are expected to be set by default,
4739 LilyPond may crash.
4740
4741
4742
4743
4744 @node Tuning per object 
4745 @subsection Tuning per object 
4746
4747 @cindex \once
4748 Tuning a single object is most often done with @code{\property}. The
4749 form,
4750 @example
4751         \once \property @dots{}
4752 @end example
4753 @c
4754 applies a setting only during one moment in the score: notice how the
4755 original setting for stem thickness is restored automatically in the
4756 following example
4757 @c
4758 @lilypond[verbatim, fragment, relative=1]
4759   c4 
4760   \once \property Voice.Stem \set #'thickness = #4
4761   c4
4762   c4
4763 @end lilypond
4764
4765 @cindex \once
4766 @cindex \outputproperty
4767
4768 A second way of tuning objects is the more arcane @code{\outputproperty}
4769 feature.  The syntax is as follows:
4770 @example
4771 \outputproperty @var{predicate} @var{symbol} = @var{value}
4772 @end example
4773 Here @code{predicate} is a Scheme function taking a object argument, and
4774 returning a boolean.  This statement is processed by the
4775 @code{Output_property_engraver}.  It instructs the engraver to feed all
4776 objects that it sees to @var{predicate}. Whenever the predicate returns
4777 true, the object property @var{symbol} will be set to @var{value}.
4778
4779 This command is only single shot, in contrast to @code{\override} and
4780 @code{\set}.
4781
4782 You will need to combine this statement with @code{\context} to select
4783 the appropriate context to apply this to.
4784
4785 In the following example, all note heads occurring at current staff
4786 level, are shifted up and right by setting their @code{extra-offset}
4787 property.
4788
4789 @lilypond[fragment,verbatim,singleline]
4790 \relative c'' { c4
4791   \context Staff \outputproperty
4792   #(make-type-checker 'note-head-interface)
4793   #'extra-offset = #'(0.5 . 0.75)
4794   <<c e g>>8 }
4795 @end lilypond
4796
4797 @cindex @code{extra-offset}
4798
4799 In this example, the predicate checks the @code{text} object property, to
4800 shift only the `m.d.' text,  but not the fingering instruction "2".
4801 @lilypond[verbatim,singleline]
4802 #(define (make-text-checker text)
4803    (lambda (grob) (equal? text (ly:get-grob-property grob 'text))))
4804
4805 \score {    
4806   \notes\relative c''' {
4807     \property Voice.Stem \set #'direction = #1
4808     \outputproperty #(make-text-checker "m.d.")
4809       #'extra-offset = #'(-3.5 . -4.5)
4810     a^2^"m.d."    
4811   }
4812 }
4813 @end lilypond
4814
4815 @refbugs
4816
4817 If possible, avoid this feature: the semantics are not very clean, and
4818 the syntax and semantics are up for rewrite.
4819
4820
4821
4822
4823 @node Font selection
4824 @subsection Font selection
4825
4826 The most common thing to change about the appearance of fonts is
4827 their size. The font size of a @internalsref{Voice},
4828 @internalsref{Staff} or @internalsref{Thread} context, can be easily
4829 changed by setting the @code{fontSize} property for that context:
4830 @lilypond[fragment,relative=1]
4831   c4 c4 \property Voice.fontSize = #-1
4832   f4 g4
4833 @end lilypond
4834  This command will not change the size of variable symbols, such as
4835 beams or slurs.  You can use this command to get smaller symbol for
4836 cue notes, but that involves some more subtleties. An elaborate
4837 example of those is in @file{input/test/cue-notes.ly}.
4838
4839 @cindex cue notes
4840 @cindex font size
4841 @cindex size
4842 @cindex symbol size
4843 @cindex glyph size
4844
4845 The font used for printing a object can be selected by setting
4846 @code{font-name}, e.g.
4847 @example
4848   \property Staff.TimeSignature
4849     \set #'font-name = #"cmr17"
4850 @end example
4851 You may use any font which is available to @TeX{}, such as foreign
4852 fonts or fonts that do not belong to the Computer Modern font family.
4853 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
4854 can also be adjusted with a more fine-grained mechanism.  By setting
4855 the object properties described below, you can select a different font.
4856 All three mechanisms work for every object that supports
4857 @code{font-interface}.
4858
4859 @table @code
4860 @item font-family
4861  A symbol indicating the general class of the typeface.  Supported are
4862 @code{roman} (Computer Modern), @code{braces} (for piano staff
4863 braces), @code{music} (the standard music font), @code{ancient} (the
4864 ancient notation font) @code{dynamic} (font for dynamic signs) and
4865 @code{typewriter}. 
4866   
4867 @item font-shape
4868   A symbol indicating the shape of the font, there are typically several
4869   font shapes available for each font family. Choices are @code{italic},
4870   @code{caps} and @code{upright} 
4871
4872 @item font-series
4873 A  symbol indicating the series of the font. There are typically several
4874 font series for each font family and shape. Choices are @code{medium}
4875 and @code{bold}. 
4876
4877 @item font-relative-size
4878   A number indicating the size relative the standard size.  For example,
4879   with 20pt staff height, relative size -1  corresponds to 16pt staff
4880   height, and relative size +1 corresponds to 23 pt staff height.
4881
4882 @item font-design-size
4883 A number indicating  the design size of the font. 
4884
4885 This is a feature of the Computer Modern Font: each point size has a
4886 slightly different design. Smaller design sizes are relatively wider,
4887 which enhances readability.
4888 @end table
4889
4890 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
4891 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
4892 to override default setting, which are always present. For example:
4893 @example
4894   \property Lyrics.LyricText \override #'font-series = #'bold
4895   \property Lyrics.LyricText \override #'font-family = #'typewriter
4896   \property Lyrics.LyricText \override #'font-shape  = #'*
4897 @end example
4898
4899 @cindex @code{font-style}
4900
4901 There are also pre-cooked font selection qualifiers. These are
4902 selected through the object property @code{font-style}.  For example,
4903 the style @code{finger} selects family @code{number} and relative size
4904 @code{-3}.  Styles available include @code{volta}, @code{finger},
4905 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
4906 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
4907 tables for selecting fonts are located in @file{scm/font.scm}. Refer
4908 to this file for more information.
4909
4910 @cindex magnification
4911
4912 The size of the font may be scaled with the object property
4913 @code{font-magnification}.  For example, @code{2.0} blows up all
4914 letters by a factor 2 in both directions.
4915
4916 @refbugs
4917
4918 Relative size is not linked to any real size.
4919
4920 There is no style sheet provided for other fonts besides the @TeX{}
4921 family, and the style sheet can not be modified easily.
4922
4923 @cindex font selection
4924 @cindex font magnification
4925 @cindex @code{font-interface}
4926
4927
4928 @node Text markup
4929 @subsection Text markup
4930 @cindex text markup
4931 @cindex markup text
4932
4933
4934 @cindex typeset text
4935
4936 LilyPond has an internal mechanism to typeset texts. You can access it
4937 with the keyword @code{\markup}. Within markup mode, you can enter texts
4938 similar to lyrics: simply enter them, surrounded by spaces. 
4939 @cindex markup
4940
4941 @lilypond[verbatim,fragment,relative=1]
4942  c1^\markup { hello }
4943  c1_\markup { hi there }
4944  c1^\markup { hi \bold there, is \italic anyone home? }
4945 @end lilypond
4946
4947 @cindex font switching
4948
4949 The line of the example demonstrates font switching commands. Notice
4950 that the command only apply to the first following word; enclose a set
4951 of texts with braces to apply a command to more words.
4952 @example
4953   \markup @{ \bold @{ hi there @} @}
4954 @end example
4955 For clarity, you can also do this for single arguments, e.g.
4956 @example
4957   \markup @{ is \italic @{ anyone @} home @}
4958 @end example
4959
4960 @cindex font size, texts
4961
4962
4963 The following size commands set abolute sizes
4964
4965 @cindex \teeny
4966 @cindex \tiny
4967 @cindex \small
4968 @cindex \large
4969 @cindex \huge
4970
4971 @table @code
4972 @item \teeny
4973 @item \tiny
4974 @item \small
4975 @item \large
4976 @item \huge
4977 @end table
4978
4979 You can also make letter larger or smaller relative to their neighbors,
4980 with the commands @code{\larger} and @code{\smaller}.
4981 @cindex smaller
4982 @cindex larger
4983
4984 @cindex font style, for texts
4985 @cindex \bold
4986 @cindex \dynamic
4987 @cindex \number
4988 @cindex \italic
4989
4990 The following font change commands are defined:
4991 @table @code
4992 @item \dynamic
4993 This changes to the font used for dynamic signs. Note that this font
4994 doesn't contain all characters of the alphabet.
4995 @item \number
4996 This changes to the font used for time signatures. It only contains
4997 numbers and a few punctuation marks.
4998 @item \italic
4999 @item \bold
5000 @end table
5001
5002 @cindex raising text
5003 @cindex lowering text
5004 @cindex moving text
5005 @cindex translating text
5006
5007 @cindex \sub
5008 @cindex \super
5009
5010 Raising and lowering texts can be done with @code{\super} and
5011 @code{\sub}.
5012
5013 @lilypond[verbatim,fragment,relative=1]
5014  c1^\markup { E "=" mc \super "2" }
5015 @end lilypond
5016
5017 @cindex \raise
5018
5019 If you want to give an explicit amount for lowering or raising, use
5020 @code{\raise}.  This command takes a Scheme valued argument,
5021 @lilypond[verbatim,fragment,relative=1]
5022  c1^\markup { C \small \raise #1.0 { "9/7+" }}
5023 @end lilypond
5024 The argument to @code{\raise} is the vertical displacement amount,
5025 measured in (global) staff spaces.
5026
5027 Other commands taking  single arguments include
5028 @table @code
5029
5030 @item \musicglyph
5031 @cindex \musicglyph
5032   This is converted to a musical symbol, e.g. @code{\musicglyph
5033 #"accidentals-0"} will select the natural sign from the music font.
5034 See @ref{The Feta font} for  a complete listing of the possible glyphs.
5035 @item \char
5036 This produces a single character, e.g. @code{\char #65} produces the 
5037 letter 'A'.
5038
5039 @item \hspace #@var{amount}
5040 @cindex \hspace
5041 This produces a invisible object taking horizontal space.
5042 @example 
5043 \markup @{ A \hspace #2.0 B @} 
5044 @end example
5045 will put extra space between A and B. Note that lilypond 
5046 inserts space before and after @code{\hspace}. 
5047
5048 @item \fontsize #@var{size}
5049 @cindex \fontsize
5050 This sets the relative font size, eg.
5051 @example
5052 A \fontsize #2 @{ B C @} D
5053 @end example
5054
5055 This will enlarge the B and the C by two steps.
5056 @item  \translate #(cons @var{x} @var{y})
5057 @cindex  \translate
5058 This translates an object. It's first argument is a cons of numbers
5059 @example
5060 A \translate #(cons 2 -3) @{ B C @} D
5061 @end example
5062 This moves `B C' 2 spaces to the right, and 3 down.
5063
5064 @item \magnify  #@var{mag}
5065 @cindex \magnify
5066 This sets the font magnification for the its argument. In the following
5067 example, the middle A will be 10% larger.
5068 @example
5069 A \magnify #1.1 @{ A @} A
5070 @end example
5071
5072
5073 @item \override #(@var{key} . @var{value})
5074 @cindex \override
5075 This overrides a  formatting property for its argument. The argument
5076 should be a key/value pair, e.g.
5077 @example
5078 m \override #'(font-family . math) m m
5079 @end example
5080 @end table
5081
5082 In markup mode you can compose expressions, similar to mathematical
5083 expressions, XML documents and music expressions.  The braces group
5084 notes into horizontal lines. Other types of lists also exist: you can
5085 stack expressions grouped with @code{<<}, and @code{>>} vertically with
5086 the command @code{\column}. Similarly, @code{\center} aligns texts by
5087 their center lines. 
5088
5089 @lilypond[verbatim,fragment,relative=1]
5090  c1^\markup { \column << a bbbb c >> }
5091  c1^\markup { \center << a bbbb c >> }
5092  c1^\markup { \line << a b c >> }
5093 @end lilypond
5094
5095
5096
5097 The markup mechanism is very flexible and extensible.  Refer to
5098 @file{scm/new-markup.scm} for more information on extending the markup
5099 mode.
5100
5101
5102 @cindex metronome mark
5103
5104 One practical application of complicated markup is to fake a metronome
5105 marking:
5106
5107 @lilypond[verbatim]
5108 eighthStem = \markup \combine
5109         \musicglyph #"flags-stem"
5110         \translate #'(0.0 . 3.5) \musicglyph #"flags-u3"
5111 eighthNote = \markup
5112         \override #'(word-space . 0.0)
5113         { \musicglyph #"noteheads-2"
5114           \translate #'(-0.05 . 0.1) \eighthStem }
5115
5116 \score {
5117   \notes\relative c'' {
5118     a1^\markup { \magnify #0.9 \eighthNote " = 64" }
5119   }
5120 }
5121 @end lilypond
5122
5123 @refbugs
5124
5125 @cindex kerning
5126
5127 LilyPond does not account for kerning in its text formatting, so it
5128 spaces texts slightly too wide.
5129
5130 Syntax errors for markup mode are confusing.
5131
5132
5133 @node Global layout
5134 @section Global layout
5135
5136 The global layout determined by three factors: the page layout, the
5137 line breaks and the spacing. These all influence each other: The
5138 choice of spacing determines how densely each system of music is set,
5139 where line breaks breaks are chosen, and thus ultimately how many
5140 pages a piece of music takes. In this section we will explain how the
5141 lilypond spacing engine works, and how you can tune its results.
5142
5143 Globally spoken, this procedure happens in three steps: first,
5144 flexible distances (``springs'') are chosen, based on durations. All
5145 possible line breaking combination are tried, and the one with the
5146 best results---a layout that has uniform density and requires as
5147 little stretching or cramping as possible---is chosen. When the score
5148 is processed by @TeX{}, page are filled with systems, and page breaks
5149 are chosen whenever the page gets full.
5150
5151 @menu
5152 * Vertical spacing::            
5153 * Horizontal spacing::          
5154 * Font Size::                   
5155 * Line breaking::               
5156 * Page layout::                 
5157 @end menu
5158
5159
5160 @node Vertical spacing
5161 @subsection Vertical spacing
5162
5163 @cindex vertical spacing
5164 @cindex distance between staves
5165 @cindex staff distance
5166 @cindex between staves, distance
5167 @cindex staffs per page
5168
5169
5170 The height of each system is determined automatically by lilypond, to
5171 keep systems from bumping into each other, some minimum distances are
5172 set.  By changing these, you can put staves closer together, and thus
5173 put more  systems onto one page.
5174
5175 Normally staves are stacked vertically. To make
5176 staves maintain a distance, their vertical size is padded. This is
5177 done with the property @code{minimumVerticalExtent}. It takes a pair
5178 of numbers, so if you want to make it smaller from its, then you could
5179 set
5180 @example
5181   \property Staff.minimumVerticalExtent = #'(-4 . 4)
5182 @end example
5183 This sets the vertical size of the current staff to 4 staff-space on
5184 either side of the center staff line.  The argument of
5185 @code{minimumVerticalExtent} is interpreted as an interval, where the
5186 center line is the 0, so the first number is generally negative.  you
5187 could also make the staff larger at the bottom by setting it to
5188 @code{(-6 . 4)}. The default value is @code{(-6 . 6)}.
5189
5190 Vertical aligment of staves is handled by the
5191 @internalsref{VerticalAlignment} object, which lives at
5192 @internalsref{Score} level.
5193
5194 The piano staves are handled a little differently: to make cross-staff
5195 beaming work correctly, it necessary that the distance between staves
5196 is fixed.  This is also done with a @internalsref{VerticalAlignment}
5197 object, created in @internalsref{PianoStaff}, but a forced distance is
5198 set. This is done with the object property #'forced-distance. If you
5199 want to override this, use a @code{\translator} block as follows:
5200 @example
5201   \translator @{
5202     \PianoStaffContext
5203     VerticalAlignment \override #'forced-distance = #9
5204   @}
5205 @end example
5206 This would bring the staves together at a distance of 9 staff spaces,
5207 and again this is measured from the center line of each staff.
5208
5209
5210
5211 @node Horizontal spacing
5212 @subsection Horizontal Spacing
5213
5214 The spacing engine translates differences in durations into
5215 stretchable distances (``springs'') of differing lengths. Longer
5216 durations get more space, shorter durations get less.  The basis for
5217 assigning spaces to durations, is that the shortest durations get a
5218 fixed amount of space, and the longer durations get more: doubling a
5219 duration adds a fixed amount of space to the note.
5220
5221 For example, the following piece contains lots of half, quarter and
5222 8th notes, the eighth note is followed by 1 note head width. The The
5223 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
5224 @lilypond[fragment, verbatim, relative=1]
5225  c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
5226 @end lilypond
5227
5228 These two amounts of space are @code{shortest-duration-space}
5229 @code{spacing-increment}, object properties of
5230 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
5231 set to 1.2, which is the width of a note head, and
5232 @code{shortest-duration-space} is set to 2.0, meaning that the
5233 shortest note gets 2 noteheads of space. For normal notes, this space
5234 is always counted from the left edge of the symbol, so the short notes
5235 in a score is generally followed by one note head width of space.
5236
5237 If one would follow the above procedure exactly, then adding a single
5238 32th note to a score that uses 8th and 16th notes, would widen up the
5239 entire score a lot. The shortest note is no longer a 16th, but a 64th,
5240 thus adding 2 noteheads of space to every note. To prevent this, the
5241 shortest duration for spacing is not the shortest note in the score,
5242 but the most commonly found shortest note.  Notes that are even
5243 shorter this are followed by a space that is proportonial to their
5244 duration relative to the common shortest note.  So if we were to add
5245 only a few 16th notes to the example above, they would be followed by
5246 half a NHW:
5247
5248 @lilypond[fragment, verbatim, relative=1]
5249  c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
5250 @end lilypond
5251
5252 The most common shortest duration is determined as follows: in every
5253 measure, the shortest duration is determined. The most common short
5254 duration, is taken as the basis for the spacing, with the stipulation
5255 that this shortest duration should always be equal to or shorter than
5256 1/8th note. The shortest duration is printed when you run lilypond
5257 with @code{--verbose}.  These durations may also be customized. If you
5258 set the @code{common-shortest-duration} in
5259 @internalsref{SpacingSpanner}, then this sets the base duration for
5260 spacing. The maximum duration for this base (normally 1/8th), is set
5261 through @code{base-shortest-duration}.
5262
5263 @cindex @code{common-shortest-duration}
5264 @cindex @code{base-shortest-duration}
5265 @cindex @code{stem-spacing-correction}
5266 @cindex @code{spacing}
5267
5268 In the introduction it was explained that stem directions influence
5269 spacing. This is controlled with @code{stem-spacing-correction} in
5270 @internalsref{NoteSpacing}. The @code{StaffSpacing} object contains the
5271 same property for controlling the stem/barline spacing. In the
5272 following example shows these corrections, once with default settings,
5273 and once with exaggerated corrections.  
5274
5275 @lilypond
5276     \score { \notes {
5277       c'4 e''4 e'4 b'4 |
5278       b'4 e''4 b'4 e''4|
5279       \property Staff.NoteSpacing \override #'stem-spacing-correction
5280       = #1.5
5281       \property Staff.StaffSpacing \override #'stem-spacing-correction
5282       = #1.5
5283       c'4 e''4 e'4 b'4 |
5284       b'4 e''4 b'4 e''4|      
5285     }
5286     \paper { linewidth = -1. } }
5287 @end lilypond
5288
5289
5290
5291 @refbugs
5292
5293 Spacing is determined on a score wide basis. If you have a score that
5294 changes its character (measured in durations) half way during the
5295 score, the part containing the longer durations will be spaced too
5296 widely.
5297
5298 Generating optically pleasing spacing is black magic. LilyPond tries
5299 to deal with a number of frequent cases. Here is an example that is
5300 not handled correctly, due to the combination of chord collisions and
5301 kneed stems.
5302
5303 @lilypond
5304 \score {
5305      \context PianoStaff \notes \transpose c c'' <
5306      \context Staff = up { s1 }
5307      \context Staff = down { [c8 c \translator Staff=up <<c d>> c 
5308 \translator Staff=down c c c] }
5309      >
5310      \paper { linewidth = -1 }
5311 }
5312 @end lilypond
5313
5314
5315 @c .  {Font size}
5316 @node Font Size
5317 @subsection Font size
5318 @cindex font size, setting
5319 @cindex staff size, setting
5320 @cindex @code{paper} file
5321
5322 The Feta font provides musical symbols at seven different sizes.
5323 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
5324 point, and 26 point.  The point size of a font is the height of the
5325 five lines in a staff when displayed in the font.
5326
5327 Definitions for these sizes are the files @file{paperSZ.ly}, where
5328 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26.  If you include any
5329 of these files, the identifiers @code{paperEleven},
5330 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
5331 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
5332 are defined respectively.  The default @code{\paper} block is also
5333 set. These files should be imported at toplevel, i.e.
5334 @example
5335         \include "paper26.ly"
5336         \score @{  ... @}
5337 @end example
5338
5339 The font definitions are generated using a Scheme function. For more
5340 details, see the file @file{scm/font.scm}.
5341
5342
5343 @c .  {Line break}
5344 @node Line breaking
5345 @subsection Line breaking
5346
5347 @cindex line breaks
5348 @cindex breaking lines
5349
5350 Line breaks are normally computed automatically. They are chosen such
5351 that it looks neither cramped nor loose, and that consecutive lines have
5352 similar density.
5353
5354 Occasionally you might want to override the automatic breaks; you can
5355 do this by specifying @code{\break}. This will force a line break at
5356 this point.  Line breaks can only occur at places where there are bar
5357 lines.  If you want to have a line break where there is no bar line,
5358 you can force an invisible bar line by entering @code{\bar
5359 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
5360 point.
5361
5362
5363 @cindex regular line breaks
5364 @cindex four bar music. 
5365
5366 If you want linebreaks at regular intervals, you can use the following:
5367 @example
5368 <  \repeat 7 unfold @{ s1 * 4 \break  @}
5369    @emph{real music}
5370
5371 @end  example
5372 This makes the following 28 measures (assuming 4/4 time) be broken every
5373 4 measures.
5374
5375 @node Page layout
5376 @subsection Page layout
5377
5378 @cindex page breaks
5379 @cindex breaking pages
5380
5381 @cindex @code{indent}
5382 @cindex @code{linewidth}
5383
5384 The most basic settings influencing the spacing are @code{indent} and
5385 @code{linewidth}. They are set in the @code{\paper} block. They
5386 control the indentation of the first line of music, and the lengths of
5387 the lines.  If @code{linewidth} set to a negative value, a single
5388 unjustified line is produced.  A similar effect for scores that are
5389 longer than one line, can be produced by setting @code{raggedright} to
5390 true in the @code{\paper} block.
5391
5392 @cindex page layout
5393 @cindex vertical spacing
5394
5395 The page layout process happens outside lilypond. Ly2dvi sets page
5396 layout instructions. Ly2dvi responds to the following variables in the
5397 @code{\paper} block.  The variable @code{textheight} sets the total
5398 height of the music on each page.  The spacing between systems is
5399 controlled with @code{interscoreline}, its default is 16pt.
5400 The distance between the score lines will stretch in order to fill the
5401 full page @code{interscorelinefill} is set to a positive number.  In
5402 that case @code{interscoreline} specifies the minimum spacing.
5403
5404 @cindex @code{textheight}
5405 @cindex @code{interscoreline}
5406 @cindex @code{interscorelinefill}
5407
5408 If the variable @code{lastpagefill} is defined (that is, it gets any
5409 value assigned in the @code{\paper} block), systems are evenly
5410 distributed vertically on the last page.  This might produce ugly
5411 results in case there are not enough systems on the last page.  Note
5412 that @command{lilypond-book} ignores @code{lastpagefill}.  See
5413 @ref{Integrating text and music with lilypond-book} for
5414 more information.
5415
5416 @cindex @code{lastpagefill}
5417
5418 Page breaks are normally computed by @TeX{}, so they are not under
5419 direct control of LilyPond.  However, you can insert a commands into
5420 the @file{.tex} output to instruct @TeX{} where to break pages. You
5421 can insert a @code{\newpage} from within lilypond. This is done by
5422 setting the @code{between-systems-strings} on the
5423 @internalsref{NonMusicalPaperColumn} where the system is broken.
5424
5425 @cindex paper size
5426 @cindex page size
5427 @cindex @code{papersize}
5428
5429 To change the paper size, you must first set the
5430 @code{papersize} paper variable variable.  Set it to
5431 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
5432 specification, you must set the font as described above.  If you want
5433 the default font, then use the 20 point font.
5434
5435 @example
5436         \paper@{ papersize = "a4" @}
5437         \include "paper16.ly"
5438 @end example
5439
5440 The file @code{paper16.ly}  will now include a file named @file{a4.ly}, which
5441 will set the paper variables @code{hsize} and @code{vsize} (used by
5442 Lilypond and @code{ly2dvi})
5443
5444
5445
5446
5447 @c . {Sound}
5448 @node Sound
5449 @section Sound
5450 @cindex Sound
5451
5452 LilyPond can produce MIDI output.  The performance lacks lots of
5453 interesting effects, such as swing, articulation, slurring, etc., but it
5454 is good enough for proof-hearing the music you have entered.  Ties,
5455 dynamics and tempo changes are interpreted.
5456
5457 Dynamic marks, crescendi and decrescendi translate into MIDI volume
5458 levels.  Dynamic marks translate to a fixed fraction of the available
5459 MIDI volume range, crescendi and decrescendi make the the volume vary
5460 linearly between their two extremities.  The fractions be adjusted by
5461 overriding the @code{absolute-volume-alist} defined in
5462 @file{scm/midi.scm}.
5463
5464 For each type of musical instrument (that MIDI supports), a volume range
5465 can be defined.  This gives you basic equalizer control, which can
5466 enhance the quality of the MIDI output remarkably.  You can add
5467 instruments and ranges or change the default settings by overriding the
5468 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
5469
5470 Both loudness controls are combined to produce the final  MIDI volume. 
5471
5472 @menu
5473 * MIDI block::                  
5474 * MIDI instrument names::       
5475 @end menu
5476
5477 @c .  {MIDI block}
5478 @node MIDI block
5479 @subsection MIDI block
5480 @cindex MIDI block
5481
5482
5483 The MIDI block is analogous to the paper block, but it is somewhat
5484 simpler.  The @code{\midi} block can contain:
5485 @cindex MIDI block
5486
5487 @itemize @bullet
5488   @item  a @code{\tempo} definition
5489   @item  context definitions
5490 @end itemize
5491
5492 Assignments in the @code{\midi} block are not allowed.
5493
5494
5495
5496 @cindex context definition
5497
5498 Context definitions follow precisely the same syntax as within the
5499 \paper block.  Translation modules for sound are called performers.
5500 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
5501
5502
5503 @node MIDI instrument names
5504 @subsection MIDI instrument names
5505
5506 @cindex instrument names
5507 @cindex @code{Staff.midiInstrument}
5508 @cindex @code{Staff.instrument}
5509
5510 The MIDI instrument name is set by the @code{Staff.midiInstrument}
5511 property or, if that property is not set, the @code{Staff.instrument}
5512 property.  The instrument name should be chosen from the list in
5513 @ref{MIDI instruments}.
5514
5515 @refbugs
5516
5517 If the selected string does not exactly match, then LilyPond uses the
5518 default (Grand Piano). It is not possible to select an instrument by
5519 number.
5520
5521