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