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