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