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