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