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