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