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