]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
patch::: 1.3.127.jcn3
[lilypond.git] / Documentation / user / refman.itely
1 @c Note:
2 @c
3 @c A menu is needed before every deeper *section nesting of @nodes
4 @c Run M-x texinfo-all-menus-update
5 @c to automagically fill in these menus
6 @c before saving changes
7
8
9 @ignore
10  TODO:
11
12    fix all FIXMEs
13
14    Rhythm staff (clef, x-notehead)
15    Piano pedals
16    \addlyrics, \autochange, \partcombine: music (re)grouping
17    markup text
18    postscript, scheme output?
19    (links to?) using/existance of ly2dvi, lilypond-book
20 @end ignore
21
22
23 @c.{Reference Manual}
24
25 @node Reference Manual
26 @chapter Reference Manual
27 @menu
28 * Overview::                    
29 * Music constructs::            
30 * Modifying music::             
31 * Note entry::                  
32 * Note specification::          
33 * Music notation::              
34 * Lyrics entry::                
35 * Chord entry::                 
36 * Page layout::                 
37 * Sound::                       
38 * Music entry::                 
39 * Engravers::                   
40 * Lexer innards::               
41 * Unsorted::                    
42 @end menu
43
44 @c. {Overview}
45 @node Overview
46 @section Overview
47
48 This document
49 describes the the GNU LilyPond input format This format represents a
50 piece of music in an elegant way, but contains enough information for
51 both automatic typesetting and automatic performances.
52
53 This document has been revised for LilyPond 1.3.125
54
55 [todo: ]
56
57 There are two things to note here. The format contains musical
58 concepts like pitches and durations, instead of symbols and positions:
59 the input format tries to capture the meaning of @emph{music}, and not
60 notation.  Second, the format tries to be @emph{context-free}:
61 a note will sound the same regardless of the current time signature,
62 the key, etc.
63
64 The purpose of LilyPond is explained informally by the term `music
65 typesetter'.  This is not a fully correct name: not only does the
66 program print musical symbols, it also makes esthetic decisions.  All
67 symbols and their placement is @emph{generated} from a high-level musical
68 description.  In other words,  LilyPond would be best
69 described by `music compiler' or `music to notation compiler'.
70
71 LilyPond input can be classified  into three types:
72 @itemize @bullet
73   @item musical expressions: a musical expression is some combination of
74 rest, notes, lyrics
75   @item output definitions: recipes for translating those musical
76 expressions into performances (MIDI) or graphics (eg. PostScript).
77
78   @item declarations: by declaring and naming musical expressions, you
79 can enter and edit them in manageable chunks.
80 @end itemize
81
82
83 @c. {Music constructs}
84 @node Music constructs
85 @section Music constructs
86 @cindex Music constructs
87 @menu
88 * Music expressions::           
89 * Sequential music::            
90 * Simultanious music::          
91 * Compound music expressions::  
92 * Grace music::                 
93 * Explicit atomic music::       
94 @end menu
95
96 @c.  {Music expressions}
97 @node Music expressions
98 @subsection Music expressions
99
100 @cindex music expressions
101
102 Music in LilyPond is entered as a music expression.  Notes, rests,
103 lyric syllables are music expressions (the atomic
104 expressions),
105 @cindex atomic music expressions
106 and you can combine music expressions to form new ones.  This example
107 forms a compound expressions out of the quarter @code{c} note and a
108 @code{d} note:
109
110 @example 
111 \sequential @{ c4 d4 @} 
112 @end example 
113
114 The meaning of this compound expression is to play the @code{c}
115 first, and then the @code{d} (as opposed to playing them
116 simultaneously, for instance).
117
118 Atomic music expression are discussed in
119 subsection @ref{Atomic music expressions}.  Compound music expressions are
120 discussed in subsection @ref{Compound music expressions}.
121
122
123 @c.  {Sequential music}
124 @node Sequential music
125 @subsection Sequential music
126 @cindex Sequential music
127 @cindex @code{\sequential}
128 @cindex sequential music
129
130 @example
131   \sequential @code{@{} @var{musicexprlist} @code{@}}
132 @end example
133
134 This means that list should be played or written in sequence, i.e.,
135 the second after the first, the third after the second.  The duration
136 of sequential music is the the sum of the durations of the elements. 
137 There is a shorthand, which leaves out the keyword:
138
139 @example
140 @cindex @code{<}
141 @cindex @code{>}
142
143   @code{@{} @var{musicexprlist} @code{@}}
144 @end example
145
146 @c.  {Simultanious music}
147 @node Simultanious music
148 @subsection Simultanious music
149 @cindex Simultanious music
150 @cindex @code{\simultaneous}
151
152 @example
153   \simultaneous @code{@{} @var{musicexprlist} @code{@}}
154 @end example
155
156 It constructs a music expression where all of its arguments start at
157 the same moment.  The duration is the maximum of the durations of the
158 elements.  The following shorthand is a common idiom:
159
160 @example
161   @code{<} @var{musicexprlist} @code{>}
162 @end example
163
164 If you try to use a chord as the first thing in your score, you might
165 get multiple staffs instead of a chord.
166
167 @lilypond[verbatim,center]
168   \score {
169     \notes <c''4 e''>
170     \paper {
171       linewidth = -1.;
172     }
173   }
174 @end lilypond
175
176 This happens because the chord is interpreted by a score context.
177 Each time a note is encountered a default Voice context (along with a
178 Staff context) is created.  The solution is to explicitly instantiate
179 a Voice context:
180
181 @lilypond[verbatim,center]
182   \score {
183     \notes\context Voice <c''4 e''>
184     \paper {
185       linewidth = -1.;
186     }
187   }
188 @end lilypond
189
190 @c.  {Compound music expressions}
191 @node Compound music expressions
192 @subsection Compound music expressions
193
194 @cindex Compound music expressions
195
196 Music expressions are compound data structures.  You can nest music
197 expressions any way you like.  This simple example shows how three
198 chords can be expressed in two different ways:
199
200 @lilypond[fragment,verbatim,center]
201   \notes \context Staff {
202     <a c'> <b  d' > <c' e'>
203     < { a b  c' } { c' d' e' } >
204   }
205
206 @end lilypond
207
208 @cindex @code{\context}
209 @cindex context selection
210
211 @example
212   \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
213 @end example
214
215 Interpret @var{musicexpr} within a context of type @var{contexttype}. 
216 If the context does not exist, it will be created.  The new context
217 can optionally be given a name.  
218
219
220 @c.  {Grace music} <-> Grace notes
221 @node Grace music
222 @subsection Grace music
223 @cindex Grace music
224 @cindex @code{\grace}
225 @cindex ornaments
226 @cindex grace notes
227 @cindex @code{graceAlignPosition}
228
229 @example
230   \grace @var{musicexpr}
231 @end example
232
233 A grace note expression has duration 0; the next real note is
234 assumed to be the main note.
235
236 You cannot have the grace note after the main note, in terms of
237 duration, and main notes, but you can typeset the grace notes to the
238 right of the main note using the property
239 @code{graceAlignPosition}.
240 @cindex @code{flagStyle}
241
242 When grace music is interpreted, a score-within-a-score is set up:
243 @var{musicexpr} has its own time bookkeeping, and you could (for
244 example) have a separate time signature within grace notes.  While in
245 this score-within-a-score, you can create notes, beams, slurs, etc.
246 Unbeamed eighth notes and shorter by default have a slash through the
247 stem.  This behavior can be controlled with the
248 @code{flagStyle} property.
249
250 @quotation
251 @lilypond[fragment,verbatim]
252 \relative c'' {
253   \grace c8 c4 \grace { [c16 c16] } c4
254   \grace { \property Grace.flagStyle = "" c16 } c4
255 }
256
257 @end lilypond
258 @end quotation
259 @cindex @code{\grace}
260
261 At present, nesting @code{\grace} notes is not supported. The following
262 may cause run-time errors:
263 @example
264   @code{\grace @{ \grace c32 c16 @} c4}
265 @end example
266 Since the meaning of such a construct is unclear, we don't consider
267 this a loss.  Similarly, juxtaposing two @code{\grace} sections is
268 syntactically valid, but makes no sense and may cause runtime errors.
269
270 Ending a staff or score with grace notes may also generate a run-time
271 error, since there will be no main note to attach the grace notes to.
272
273 The present implementation is not robust and generally kludgy. We expect
274 it to change after LilyPond 1.4
275
276
277 @c.  {Explicit atomic music}
278 @node Explicit atomic music
279 @subsection Explicit atomic music
280 @cindex Explicit atomic music
281
282
283 @cindex pitch
284
285 The syntax for pitch specification is
286
287 @cindex @code{\pitch}
288 @example
289   \pitch @var{scmpitch}
290 @end example
291
292 @var{scmpitch} is a pitch scheme object, see @ref{Pitch}.
293
294 In Note and Chord mode, pitches may be designated by names.  See
295 section @ref{Other languages} for pitch names in different languages.
296
297 @cindex duration
298 @cindex @code{\duration}
299
300 The syntax for duration specification is
301 @example
302  \duration @var{scmduration}
303 @end example
304
305 In Note, Chord, and Lyrics mode, durations may be designated by
306 numbers and dots.  
307
308
309
310
311 @c. {Modifying music}
312 @node Modifying music
313 @section Modifying music
314 @cindex Modifying music
315
316 FIXME: more verbose titling:
317 music expressions?
318 Repeat?
319 Repeated music?
320 Repeating music expressions?
321
322 @menu
323 * Relative::                    
324 * Transpose::                   
325 * Repeat::                      
326 * Times ::                      
327 * Apply::                       
328 * Transform::                   
329 @end menu
330
331 @c.  {Relative}
332 @node Relative
333 @subsection Relative
334 @cindex Relative
335 @cindex relative octave specification
336
337 It is easy to get confused by octave changing marks and accidentally
338 putting a pitch in the wrong octave.  A much better way of entering a
339 note's octave is `the relative octave' mode.
340
341 @cindex @code{\relative}
342 @example
343   \relative @var{startpitch} @var{musicexpr}
344 @end example
345
346 The octave of notes that appear in @var{musicexpr} are calculated as
347 follows: If no octave changing marks are used, the basic interval
348 between this and the last note is always taken to be a fourth or
349 less.@footnote{The interval is determined without regarding
350 accidentals.  A @code{fisis} following a @code{ceses} will be put above
351 the @code{ceses}.}  The octave changing marks @code{'} and @code{,}
352 can then be added to raise or lower the pitch by an extra octave. 
353 Upon entering relative mode, an absolute starting pitch must be
354 specified that will act as the predecessor of the first note of
355 @var{musicexpr}.
356
357 Entering scales is straightforward in relative mode.
358
359 @lilypond[fragment,verbatim,center]
360   \relative c' {
361     c d e f g a b c c,
362   }
363 @end lilypond
364
365 And octave changing marks are used for intervals greater than a fourth.
366
367 @lilypond[fragment,verbatim,center]
368   \relative c'' {
369     c g c f, c' a, e'' }
370 @end lilypond
371
372 If the preceding item is a chord, the first note of the chord is used
373 to determine the first note of the next chord.  But other notes
374 within the second chord are determined by looking at the immediately
375 preceding note.
376
377 @lilypond[fragment,verbatim,center]
378   \relative c' {
379     c <c e g> 
380     <c' e g>
381     <c, e' g>
382   }
383 @end lilypond 
384 @cindex @code{\notes}
385
386 The pitch after the @code{\relative} contains a notename.  To parse
387 the pitch as a notename, you have to be in note mode, so there must
388 be a surrounding @code{\notes} keyword (which is not
389 shown here).
390
391 The relative conversion will not affect @code{\transpose} or
392 @code{\relative} sections in its argument.  If you want to use
393 relative within transposed music, you must place an additional
394 @code{\relative} inside the @code{\transpose}.
395
396 It is strongly recommended to use relative pitch mode: less work,
397 less error-prone, and more readable.
398
399 @c.  {Transpose}
400 @node Transpose
401 @subsection Transpose
402 @cindex Transpose
403 @cindex transposition of pitches
404 @cindex @code{\transpose}
405
406 A music expression can be transposed with @code{\transpose}.  The syntax
407 is
408 @example
409   \transpose @var{pitch} @var{musicexpr}
410 @end example
411
412 This means that middle C in @var{musicexpr} is transposed to
413 @var{pitch}.
414
415 @code{\transpose} distinguishes between enharmonic pitches: both
416 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
417 a tone.  The first version will print sharps and the second version
418 will print flats.
419
420 @quotation
421 @lilypond[fragment,verbatim]
422 \context Staff {
423   \clef "F";
424   { \key e \major; c d e f }
425   \clef "G";
426   \transpose des'' { \key e \major; c d e f }
427   \transpose cis'' { \key e \major; c d e f }
428 }
429
430 @end lilypond
431 @end quotation
432
433 If you want to use both @code{\transpose} and @code{\relative}, then
434 you must use @code{\transpose} first.  @code{\relative} will have no
435 effect music that appears inside a @code{\transpose}.
436
437 @c.  {Repeat}
438 @node Repeat
439 @subsection Repeat
440 @cindex Repeat
441 @cindex repeats
442
443 @ref{Volta}
444 [TODO: document #'repeatCommands.]
445
446 @cindex @code{\repeat}
447
448 In order to specify repeats, use the @code{\repeat}
449 keyword.  Since repeats look and sound differently when played or
450 printed, there are a few different variants of repeats.
451
452 @table @asis
453 @item unfolded  
454 Repeated music is fully written (played) out.  Useful for MIDI
455 output.
456
457 @item volta  
458 This is the normal notation: Repeats are not written out, but
459 alternative endings (voltas) are printed, left to right.
460
461 @item folded  
462 Alternative endings are written stacked.  Which is unfortunately not
463 practical for anything right now.
464
465 @item tremolo
466 Make tremolo beams.
467 @end table  
468
469 The syntax for repeats is
470
471 @example
472   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
473 @end example
474
475 If you have alternative endings, you may add
476
477 @cindex @code{\alternative}
478 @example
479  \alternative @code{@{} @var{alternative1}
480             @var{alternative2}
481             @var{alternative3} @dots{} @code{@}}
482 @end example
483
484 where each @var{alternative} is a Music expression.
485
486 Normal notation repeats are used like this:
487
488 @quotation
489
490 @lilypond[fragment,verbatim]
491   c'1
492   \repeat volta 2 { c'4 d' e' f' }
493   \repeat volta 2 { f' e' d' c' }
494
495 @end lilypond
496 @end quotation
497
498 With alternative endings:
499
500 @quotation
501
502 @lilypond[fragment,verbatim]
503   c'1
504   \repeat volta 2 {c'4 d' e' f'} 
505   \alternative { {d'2 d'} {f' f} }
506
507 @end lilypond
508 @end quotation
509
510 Folded repeats look like this:@footnote{Folded repeats offer little
511 more over simultaneous music.  However, it is to be expected that
512 more functionality -- especially for the MIDI backend -- will be
513 implemented.}
514
515 @quotation
516
517 @lilypond[fragment,verbatim]
518   c'1
519   \repeat fold 2 {c'4 d' e' f'} 
520   \alternative { {d'2 d'} {f' f} }
521
522 @end lilypond
523 @end quotation
524
525 @quotation
526
527 @lilypond[fragment,verbatim]
528 \context Staff {
529   \relative c' {
530     \partial 4;
531     \repeat volta 2 { e | c2 d2 | e2 f2 | }
532     \alternative { { g4 g g } { a | a a a a | b1 } }
533   }
534 }
535
536 @end lilypond
537 @end quotation
538
539 If you don't give enough alternatives for all of the repeats, then
540 the first alternative is assumed to be repeated often enough to equal
541 the specified number of repeats.
542
543 @quotation
544 @lilypond[fragment,verbatim]
545 \context Staff {
546   \relative c' {
547     \repeat volta 3 { \partial 4; e | c2 d2 | e2 f2 | }
548     \alternative { { g4 g g }
549                    {\partial 1; e4 e e } 
550                    {\partial 1; a a a a | b1 } }
551   }
552 }
553 @end lilypond
554 @end quotation
555
556 As you can see, LilyPond doesn't remember the timing information, nor
557 are slurs or ties repeated. We hope to fix this after 1.4. 
558
559 It is possible to nest @code{\repeat}.  This is not entirely
560 supported: the notes will come be in the right places, but the repeat
561 bars will not.
562
563 To place tremolo marks between notes, use @code{\repeat} with tremolo
564 style.
565 @cindex tremolo beams
566 To create tremolo beams on a single note, simply attach
567 `@code{:}@var{length}' to the note itself.
568
569 @lilypond[verbatim,center]
570 \score { 
571   \context Voice \notes\relative c' {
572     \repeat "tremolo" 8 { c16 d16 }
573     \repeat "tremolo" 4 { c16 d16 }    
574     \repeat "tremolo" 2 { c16 d16 }    
575   }
576   \paper {
577     linewidth = 40*\staffspace;
578   }  
579 }
580 @end lilypond
581 @cindex @code{__}
582
583 @lilypond[fragment,verbatim,center]
584
585   c'4:32
586 @end lilypond
587
588 @c.  {Times}
589 @node Times 
590 @subsection Times
591 @cindex Times 
592 @ref{Tuplets}
593 Tuplets are made out of a music expression by multiplying their
594 duration with a fraction.
595
596 @cindex @code{\times}
597 @example
598   \times @var{fraction} @var{musicexpr}
599 @end example
600
601 The duration of @var{musicexpr} will be multiplied by the fraction. 
602 In print, the fraction's denominator will be printed over the notes,
603 optionally with a bracket.  The most common tuplet is the triplet in
604 which 3 notes have the length of 2, so the notes are 2/3 of
605 their written length:
606
607 @lilypond[fragment,verbatim,center]
608   g'4 \times 2/3 {c'4 c' c'} d'4 d'4
609 @end lilypond
610
611
612 @c.  {Apply}
613 @node Apply
614 @subsection Apply
615 @cindex Apply
616 Apply allows a Scheme-function to operate directly on the internal
617 representation of music.
618 @example
619         \apply #@var{func} @var{music}
620 @end example
621 The function takes two arguments, being a function and an musical
622 argument for that function. The function should return a music
623 expression.
624
625 This example replaces the text string of a script. It also shows a dump
626 of the music it processes.
627 @lilypond[verbatim]
628 #(define (testfunc x)
629         (if (eq? (ly-get-mus-property x 'text) "foo")
630                 (ly-set-mus-property x 'text "bar"))
631         ;; recurse
632         (ly-set-mus-property x 'elements
633           (map testfunc (ly-get-mus-property x 'elements)))
634         (display x)
635         x        
636 )
637 \score { \notes
638   \apply #testfunc { c4_"foo" }
639
640 @end lilypond
641
642 For more information on what is possible, see the @ref{Tricks} and the
643 automatically generated documentation.
644
645 @c.  {Transform}
646 @node Transform
647 @subsection Transform
648 @cindex Transform
649
650
651 @c. {Note entry}
652 @node Note entry
653 @section Note entry
654 @cindex Note entry
655
656 @menu
657 * Notes mode::                  
658 * Pitch names::                 
659 @end menu
660
661 @c.  {Notes mode}
662 @node Notes mode
663 @subsection Notes mode
664
665 @cindex note mode
666
667 @cindex @code{\notes}
668 Note mode is introduced by the keyword
669 @code{\notes}.  In Note mode, words can only
670 contain alphabetic characters.  If @code{word} is encountered,
671 LilyPond first checks for a notename of @code{word}.  If no
672 notename is found, then @code{word} is treated as a string.
673
674 Since combinations of numbers and dots are used for indicating
675 durations, it is not possible to enter real numbers in this mode.
676
677
678 @cindex Notes mode
679
680 @c.  {Pitch names}
681 @node Pitch names
682 @subsection Pitch names
683 @cindex Pitch names
684 @node Note specification
685 @section Note specification
686 @cindex Note specification
687
688 @cindex pitches
689 @cindex entering notes
690
691 A note specification has the form
692
693 @example
694   @var{pitch}[@var{octavespec}][!][?][@var{duration}]
695 @end example
696
697 The pitch of the note is specified by the note's name.
698
699
700 The default names are the Dutch note names.  The notes are specified
701 by the letters @code{c} through @code{b}, where @code{c} is an
702 octave below middle C and the letters span the octave above that C. 
703 In Dutch,
704 @cindex note names, Dutch
705 a sharp is formed by adding @code{-is} to the end of a pitch name.  A
706 flat is formed by adding @code{-es}. Double sharps and double flats are
707 obtained by adding @code{-isis} or @code{-eses}.  @code{aes} and
708 @code{ees} are contracted to @code{as} and @code{es} in Dutch, but both
709 forms will be accepted.
710
711 LilyPond has predefined sets of notenames for various other languages.
712 To use them, simply include the language specific init file.  For
713 example: @code{\include "english.ly"}.  The available language files and
714 the names they define are:
715
716 @example 
717                         Note Names               sharp       flat
718 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
719 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
720 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
721 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
722 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
723 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
724 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b 
725 @end example 
726 @cindex @code{'}
727 @cindex @code{,}
728
729 Pitch names can be redefined using the @code{\pitchnames} command, see
730 @ref{Pitch names}.
731
732
733
734
735 The optional octave specification takes the form of a series of
736 single quote (`@code{'}') characters or a series of comma
737 (`@code{,}') characters.  Each @code{'} raises the pitch by one
738 octave; each @code{,} lowers the pitch by an octave.
739
740 @lilypond[fragment,verbatim,center]
741   c' d' e' f' g' a' b' c''
742 @end lilypond
743
744 @lilypond[fragment,verbatim,center]
745   cis' dis' eis' fis' gis' ais' bis'
746 @end lilypond
747
748 @lilypond[fragment,verbatim,center]
749   ces' des' es' fes' ges' as' bes'
750 @end lilypond
751
752 @lilypond[fragment,verbatim,center]
753   cisis' eisis' gisis' aisis' beses'
754 @end lilypond
755
756 @lilypond[fragment,verbatim,center]
757   ceses' eses' geses' ases' beses'
758 @end lilypond
759
760 LilyPond will determine what accidentals to typeset depending on the key
761 and context, so alteration refer to what note is heard, not to whether
762 accidentals are printed.  A reminder accidental
763 @cindex reminder accidental
764 @cindex @code{?}
765 can be forced by adding an exclamation mark @code{!} after the pitch.
766 A cautionary accidental,
767 @cindex cautionary accidental
768
769 i.e., an accidental within parentheses can be obtained by adding the
770 question mark `@code{?}' after the pitch.
771
772 @lilypond[fragment,verbatim,center]
773   cis' d' e' cis'  c'? d' e' c'!
774 @end lilypond
775
776
777 @c.  {Rests}
778 @menu
779 * Rests::                       
780 * Durations::                   
781 * Multi measure rests::         
782 * Skip::                        
783 @end menu
784
785 @node  Rests
786 @subsection Rests
787 @cindex Rests
788
789 Rests are entered like notes, with note name `@code{r}'.
790 There is also a note name
791 `@code{s}', which produces a space of the specified
792 duration.
793
794
795 @c.  {Durations}
796 @node Durations
797 @subsection Durations
798 @cindex Durations
799
800 Durations are entered as their reciprocal values.  For notes longer
801 than a whole note, use identifiers.
802
803 @quotation
804
805 @example 
806 c'\longa c'\breve  
807 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 
808 r\longa r\breve  
809 r1 r2 r4 r8 r16 r32 r64 r64 
810 @end example 
811
812
813 @lilypond[]
814 \score {
815   \notes \relative c'' {
816     a\longa a\breve  \autoBeamOff
817     a1 a2 a4 a8 a16 a32 a64 a64 
818     r\longa r\breve  
819     r1 r2 r4 r8 r16 r32 r64 r64 
820   }
821   \paper {
822     \translator {
823       \StaffContext
824         \remove "Clef_engraver";
825         \remove "Staff_symbol_engraver";
826         \remove "Time_signature_engraver";
827         \consists "Pitch_squash_engraver";
828     }
829   }
830 }
831 @end lilypond
832 @end quotation
833
834 As you  can see, the longa is not printed. To get a longa note head, you
835 have to use a different style of note heads. See [TODO].
836
837 @cindex @code{.}
838
839
840 If the duration is omitted then it is set equal to the previous duration
841 entered.  At the start of parsing there is no previous duration, so then
842 a quarter note is assumed.  The duration can be followed by a dot
843 (`@code{.}')  to obtain dotted note lengths.
844
845
846
847 @lilypond[fragment,verbatim,center]
848   a'4. b'4.
849 @end lilypond
850 @cindex @code{r}
851 @cindex @code{s}
852
853 You can alter the length of duration by writing `@code{*}@var{fraction}'
854 after it.  This will not affect the appearance of note heads or rests.
855
856 @c.  {Multi measure rests}
857 @node  Multi measure rests
858 @subsection Multi measure rests
859 @cindex Multi measure rests
860
861 @cindex @code{R}
862
863 Multi_measure_rest are entered using `@code{R}'. It is specifically
864 meant for entering parts: the rest can expand to fill a score with
865 rests, or it can be printed as a single multimeasure rest This expansion
866 is controlled by the property @code{Score.skipBars}. If this is set to true,
867 Lily will not expand empty measures, and the multimeasure rests
868 automatically adds the appropriate number.
869
870 @lilypond[fragment]
871  \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17  R2.*4
872 @end lilypond
873
874 Note that there is currently no way to condense multiple rests into a
875 single multimeasure rest.
876
877 @c.  {Skip}
878 @node Skip
879 @subsection Skip
880 @cindex Skip
881
882
883 @example
884   \skip @var{duration} @code{;}
885 @end example
886 @cindex @code{\skip}
887
888 Skips the amount of time specified by @var{duration}.  If no other
889 music is played, a gap will be left for the skipped time with no
890 notes printed.  It works in Note Mode or Lyrics Mode.  In Note mode,
891 this has the same effect as the spacer rest.
892
893
894
895
896
897 @c. {Music notation}
898 @node Music notation
899 @section Music notation
900 @cindex Music notation
901 @menu
902 * Key::                         
903 * Clef::                        
904 * Time signature::              
905 * Spanners::                    
906 * Ornaments::                   
907 * Bar check::                   
908 @end menu
909
910 @c.  {Key}
911 @node Key
912 @subsection Key
913 @cindex Key
914
915 @cindex @code{\key}
916
917 @example
918   @code{\key} @var{pitch} @var{type} @code{;}
919 @end example
920 @cindex @code{\minor}
921 @cindex @code{\major}
922 @cindex @code{\minor}
923 @cindex @code{\ionian}
924 @cindex @code{\locrian}
925 @cindex @code{\aeolian}
926 @cindex @code{\mixolydian}
927 @cindex @code{\lydian}
928 @cindex @code{\phrygian}
929 @cindex @code{\dorian}
930
931 Change the key signature.  @var{type} should be @code{\major} or
932 @code{\minor} to get @var{pitch}-major or @var{pitch}-minor,
933 respectively.  The second argument is optional; the default is major
934 keys.  The @var{\context} argument can also be given as an integer,
935 which tells the number of semitones that should be added to the pitch
936 given in the subsequent @code{\key} commands to get the corresponding
937 major key, e.g., @code{\minor} is defined as 3.  The standard mode names
938 @code{\ionian}, @code{\locrian}, @code{\aeolian}, @code{\mixolydian},
939 @code{\lydian}, @code{\phrygian}, and @code{\dorian} are also defined.
940
941
942 @c.  {Clef}
943 @node Clef
944 @subsection Clef
945 @cindex Clef
946
947
948 @c.   {Clef changes}
949 @subsubsection Clef changes
950 @cindex @code{\clef}
951 @example
952   \clef @var{clefname} @code{;}
953 @end example
954
955 Short-cut for
956
957 @example
958   \property Clef.clefGlyph = @var{symbol associated with clefname} 
959   \property Clef.clefPosition = @var{clef Y-position for clefname}
960   \property Clef.clefOctavation = @var{extra pitch of clefname}
961 @end example
962
963 Supported clef-names include 
964
965 [todo]
966
967
968 @c.  {Time signature}
969 @node Time signature
970 @subsection Time signature
971 @cindex Time signature
972 @cindex meter
973 @cindex @code{\time}
974
975 @example
976   \time @var{numerator}@code{/}@var{denominator} @code{;}
977 @end example
978
979 A short-cut for doing
980 @example
981      \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
982 @end example
983
984 See the documentation of @code{timeSignatureFraction}
985
986
987 @c.   {Partial}
988 @subsubsection Partial
989 @cindex Partial
990 @cindex anacrusis
991 @cindex upstep
992 @cindex partial measure
993 @cindex measure, partial
994 @cindex shorten measures
995 @cindex @code{\partial}
996 @example
997   \partial @var{duration} @code{;}
998 @end example
999
1000 Short cut for 
1001
1002 @example
1003   \property Score.measurePosition = @var{length of duration}
1004 @end example
1005 @cindex @code{|}
1006
1007 See the documentation of @code{measurePosition}.
1008
1009
1010
1011 @c.  {Spanners}
1012 @node Spanners
1013 @subsection Spanners
1014 @cindex Spanners
1015
1016 @menu
1017 * Beam::                        
1018 * Slur::                        
1019 * Tie::                         
1020 * Tuplet::                      
1021 * Volta::                       
1022 * Crescendo and Decrescendo::   
1023 * Text spanner::                
1024 * Ottava::                      
1025 * Span requests::               
1026 @end menu
1027
1028 @c.   {Beam}
1029 @node Beam
1030 @subsubsection Beam
1031 @cindex Beam
1032
1033 @c.    {Automatic beams}
1034 @unnumberedsubsubsec Automatic beams
1035
1036 @cindex automatic beam generation
1037 @cindex autobeam
1038
1039 @cindex @code{Voice.noAutoBeaming}
1040
1041 LilyPond will group flagged notes and generate beams autmatically, where
1042 appropriate.  This feature can be disabled by setting the
1043 @code{Voice.noAutoBeaming} property to true, which you may find
1044 necessary for the melody that goes with lyrics, eg.  Automatic beaming
1045 can easily be overridden for specific cases by specifying explicit
1046 beams, see @ref{Manual beams}.
1047
1048 @cindex @code{Voice.autoBeamSettings}
1049 @cindex @code{(end * * * *)}
1050 @cindex @code{(begin * * * *)}
1051
1052 A large number of Voice properties are used to decide how to generate
1053 beams.  Their default values appear in @file{scm/auto-beam.scm}.  In
1054 general, beams can begin anywhere, but their ending location is
1055 significant.  Beams can end on a beat, or at durations specified by the
1056 properties in @code{Voice.autoBeamSettings}.  To end beams every quarter
1057 note, for example, you could set the property @code{(end * * * *)} to
1058 @code{(make-moment 1 4)}.  To end beams at every three eighth notes you
1059 would set it to @code{(make-moment 1 8)}.  The same syntax can be used
1060 to specify beam starting points using @code{(begin * * * *)}, eg:
1061 @quotation
1062 @example
1063 \property Voice.autoBeamSettings \override
1064     #'(end * * * *) = #(make-moment 1 4)
1065 \property Voice.autoBeamSettings \override
1066     #'(begin * * * *) = #(make-moment 1 8)
1067 @end example
1068 @end quotation
1069
1070 To allow different settings for different time signatures, instead of
1071 the first two asterisks @code{* *} you can specify a time signature; use
1072 @code{(end N M * *)} to restrict the definition to
1073 `@var{N}@code{/}@var{M}' time.  For example, to specify beams ending
1074 only for 6/8 time you would use the property @code{(end 6 8 * *)}.
1075
1076 To allow different endings for notes of different durations, instead of
1077 th last two asterisks you can specify a duration; use @code{(end * * N
1078 M)} to restrict the definition to beams that contain notes of
1079 `@var{N}@code{/}@var{M}' duration.
1080
1081 For example, to specify beam endings for beams that contain 32nd notes,
1082 you would use @code{(end * * 1 32)}.
1083
1084
1085
1086 @c.    {Manual beams}
1087 @cindex Automatic beams
1088 @unnumberedsubsubsec Manual beams
1089 @cindex beams, manual
1090 @cindex @code{]}
1091 @cindex @code{[}
1092
1093 For most situations, beaming can be generated automatically; see section
1094 @ref{Automatic Beaming}.  In certain cases it may be necessary to
1095 override the automatic beaming decisions that LilyPond makes.  You can
1096 do this by specifying beams explicitely.
1097
1098 A manual beam is specified by surrounding the notes that should make up
1099 the beam, with brackets `@code{[}' and `@code{]}'.
1100
1101 FIXME: example.  (or tell: why would the auto-beamer fail here?)
1102
1103 @lilypond[fragment,verbatim,center]
1104   [a'8 a'] [a'16 a' a' a']
1105   [a'16 <a' c''> c'' <a' c''>]
1106   \times 2/3 { [e'8 f' g'] }
1107 @end lilypond
1108
1109
1110
1111 @c.    {Adjusting beams}
1112 @unnumberedsubsubsec Adjusting beams
1113 @cindex Adjusting beams
1114
1115 FIXME
1116
1117 @c.   {Slur}
1118
1119 @node Slur
1120 @subsubsection Slur
1121 @cindex Slur
1122
1123 @cindex slur
1124
1125 Slurs connects chords and try to avoid crossing stems.  A slur is
1126 started with @code{(} and stopped with @code{)}.  The
1127 starting @code{(} appears to the right of the first note in
1128 the slur.  The terminal @code{)} appears to the left of the
1129 first note in the slur.  This makes it possible to put a note in
1130 slurs from both sides:
1131
1132 @lilypond[fragment,verbatim,center]
1133   f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1134 @end lilypond
1135
1136
1137
1138 @c.    {Adjusting slurs}
1139 @unnumberedsubsubsec Adjusting slurs
1140 @c.   {Tie}
1141 @cindex Adusting slurs
1142 @node Tie
1143 @subsubsection Tie
1144
1145 @cindex Tie
1146 @cindex ties
1147 @cindex @code{~}
1148
1149 A tie connects two adjacent note heads of the same pitch.  When used
1150 with chords, it connects all of the note heads whose pitches match.
1151 Ties are indicated using the tilde symbol `@code{~}'.
1152 If you try to tie together chords which have no common pitches, a
1153 warning message will appear and no ties will be created.
1154
1155 @lilypond[fragment,verbatim,center]
1156   e' ~ e' <c' e' g'> ~ <c' e' g'>
1157 @end lilypond
1158
1159 [sparseTies]
1160
1161
1162 @c.   {Tuplet}
1163 @node Tuplet
1164 @subsubsection Tuplet
1165 @cindex Tuplet
1166
1167 A @rgrob{TupletBracket} is typeset automatically for music that
1168 is time scaled, see @ref{Times}.
1169
1170
1171 See @ref{Times}.
1172
1173 @c.   {Volta}
1174 @node Volta
1175 @subsubsection Volta
1176 @cindex Volta
1177
1178 A @rgrob{VoltaBracket} is typeset automatically for music that contains a
1179 repetition, see @ref{Repeat}.
1180
1181
1182 @c.   {Crescendo and Decrescendo}
1183 @node Crescendo and Decrescendo
1184 @subsubsection Crescendo and Decrescendo
1185 @cindex Crescendo and Decrescendo
1186 @cindex crescendo
1187 @cindex @code{\cr}
1188 @cindex @code{\rc}
1189 @cindex @code{\decr}
1190 @cindex @code{\rced}
1191 @cindex @code{\<}
1192 @cindex @code{\>}
1193 @cindex @code{\"!}
1194
1195
1196
1197 A crescendo mark is started with @code{\cr} and terminated with
1198 @code{\rc}, the textual reverse of @code{cr}.  A decrescendo mark is
1199 started with @code{\decr} and terminated with @code{\rced}.  There are
1200 also shorthands for these marks.  A crescendo can be started with
1201 @code{\<} and a decrescendo can be started with @code{\>}.  Either one
1202 can be terminated with @code{\!}.  Note that @code{\!}  must go before
1203 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1204 after the last note.  Because these marks are bound to notes, if you
1205 want to get several marks during one note, you must use spacer notes.
1206
1207 @lilypond[fragment,verbatim,center]
1208   c'' \< \! c''   d'' \decr e'' \rced 
1209   < f''1 { s4 \< \! s2 \> \! s4 } >
1210 @end lilypond
1211
1212 [todo: text cr] 
1213
1214
1215 @c.   {Text spanner}
1216 @node Text spanner
1217 @subsubsection Text spanner
1218 @cindex Text spanner
1219
1220 Have crescendo set a text spanner instead of hairpin
1221
1222 @lilypond[fragment,relative,verbatim]
1223   \context Voice {
1224     \property Voice.crescendoText = "cresc."
1225     \property Voice.crescendoSpanner = #'dashed-line
1226     a''2\mf\< a a \!a 
1227   }
1228 @end lilypond
1229
1230 @c.   {Ottava}
1231 @node Ottava
1232 @subsubsection Ottava
1233 @cindex Ottava
1234 @unnumberedsubsubsec Ottava
1235
1236 @lilypond[fragment,relative,verbatim]
1237   a'''' b c a
1238   \property Voice.TextSpanner \set #'type = #'dotted-line
1239   \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1240   \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1241   \property Staff.centralCPosition = #-13
1242   a\spanrequest \start "text" b c a \spanrequest \stop "text"
1243 @end lilypond
1244
1245
1246
1247 @c.    {Text crescendo and decrescendo}
1248 @unnumberedsubsubsec Text crescendo and decrescendo
1249
1250 TODO
1251
1252 @c.   {Span requests}
1253 @node Span requests
1254 @subsubsection Span requests
1255 @cindex Span requests
1256
1257 @cindex @code{\spanrequest}
1258
1259 @example
1260   \spanrequest @var{startstop} @var{type}
1261 @end example
1262 @cindex @code{\start}
1263 @cindex @code{\stop}
1264
1265 Define a spanning request. The @var{startstop} parameter is either -1
1266 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
1267 describes what should be started.  Supported types are @code{crescendo},
1268 @code{decrescendo}, @code{beam}, @code{slur}.  This is an internal
1269 command.  Users should use the shorthands which are defined in the
1270 initialization file @file{spanners.ly}.
1271
1272 You can attach a (general) span request to a note using
1273
1274 @lilypond[fragment,verbatim,center]
1275   c'4-\spanrequest \start "slur"
1276   c'4-\spanrequest \stop "slur"
1277 @end lilypond
1278
1279 The slur syntax with parentheses is a shorthand for this.
1280
1281
1282 @c.  {Ornaments}
1283 @node Ornaments
1284 @subsection Ornaments
1285 @cindex Ornaments
1286 @menu
1287 * Articulation::                
1288 * Text scripts::                
1289 * Grace notes::                 
1290 * Stem tremolo::                
1291 * Arpeggio::                    
1292 * Glissando ::                  
1293 * Dynamics::                    
1294 * Bar lines::                   
1295 * Breath marks::                
1296 * Rehearsal marks::             
1297 @end menu
1298
1299 @c.   {Articulation}
1300 @node Articulation
1301 @subsubsection Articulation
1302 @cindex Articulation
1303
1304 @cindex articulations
1305 @cindex scripts
1306 @cindex ornaments
1307
1308 A variety of symbols can appear above and below notes to indicate
1309 different characteristics of the performance.  These symbols can be
1310 added to a note with `@var{note}@code{-\}@var{name}'.  Numerous symbols
1311 are defined in @file{script.ly} and @file{script.scm}.  Symbols can be
1312 forced to appear above or below the note by writing
1313 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1314 respectively.  Here is a chart showing symbols above notes, with the
1315 name of the corresponding symbol appearing underneath.
1316
1317 @lilypond[]
1318
1319   \score {
1320     < \notes {
1321         \property Score.LyricSyllable \override #'font-family =
1322 #'typewriter
1323         \property Score.LyricSyllable \override #'font-shape = #'upright
1324         c''-\accent      c''-\marcato      c''-\staccatissimo c''-\fermata 
1325         c''-\stopped     c''-\staccato     c''-\tenuto        c''-\upbow
1326         c''-\downbow     c''^\lheel        c''-\rheel         c''^\ltoe
1327         c''-\rtoe        c''-\turn         c''-\open          c''-\flageolet
1328         c''-\reverseturn c''-\trill        c''-\prall         c''-\mordent
1329         c''-\prallprall  c''-\prallmordent c''-\upprall       c''-\downprall
1330         c''-\thumb       c''-\segno        c''-\coda
1331       }
1332       \context Lyrics \lyrics {
1333         accent__      marcato__      staccatissimo__ fermata
1334         stopped__     staccato__     tenuto__        upbow
1335         downbow__     lheel__        rheel__         ltoe
1336         rtoe__        turn__         open__          flageolet
1337         reverseturn__ trill__        prall__         mordent
1338         prallprall__  prallmordent__ uprall__        downprall
1339         thumb__       segno__        coda
1340       }
1341     >
1342     \paper {
1343       linewidth = 5.875\in;          
1344       indent    = 0.0;
1345     }
1346   }
1347
1348 @end lilypond
1349
1350 @c.   {Text scripts}
1351 @node Text scripts
1352 @subsubsection Text scripts
1353 @cindex Text scripts
1354
1355 FIXME: markup
1356
1357 In addition, it is possible to place arbitrary strings of text or
1358 @TeX{} above or below notes by using a string instead of an
1359 identifier: @code{c^"text"}.  Fingerings 
1360 can be placed by simply using digits.  All of these note ornaments
1361 appear in the printed output but have no effect on the MIDI rendering of
1362 the music.
1363
1364 @c.    {Fingerings}
1365 @unnumberedsubsubsec Fingerings
1366 @cindex Fingerings
1367
1368 To save typing, fingering instructions (digits 0 to 9 are
1369 supported) and single characters shorthands exist for a few
1370 common symbols
1371
1372 @lilypond[]
1373   \score {
1374     \notes \context Voice {
1375       \property Voice.TextScript \set #'font-family = #'typewriter
1376       \property Voice.TextScript \set #'font-shape = #'upright
1377       c''4-._"c-."      s4
1378       c''4--_"c-{}-"    s4
1379       c''4-+_"c-+"      s4
1380       c''4-|_"c-|"      s4
1381       c''4->_"c->"      s4
1382       c''4-^_"c-\\^{ }" s4
1383       c''4-1_"c-1"      s4
1384       c''4-2_"c-2"      s4
1385       c''4-3_"c-3"      s4
1386       c''4-4_"c-4"      s4
1387     }
1388     \paper {
1389       linewidth = 5.875 \in;
1390       indent    = 0.0;
1391     }
1392   }
1393
1394 @end lilypond
1395
1396
1397 @cindex @code{\textscript}
1398
1399 @example
1400
1401   \textscript @var{text} @var{style}
1402 @end example
1403
1404 Defines a text to be printed over or under a note.  @var{style} is a
1405 string that may be one of @code{roman}, @code{italic}, @code{typewriter}, 
1406 @code{bold}, @code{Large}, @code{large}, @code{dynamic} or @code{finger}.
1407
1408 You can attach a general textscript request using this syntax:
1409
1410 @quotation
1411
1412 @example 
1413 c4-\textscript "6" "finger"
1414 c4-\textscript "foo" "normal" 
1415 @end example 
1416
1417 @end quotation
1418
1419 This is equivalent to @code{c4-6 c4-"foo"}.  
1420
1421 @cindex @code{\script}
1422 @cindex scripts
1423
1424 @example
1425
1426   \script @var{alias}
1427 @end example
1428 @cindex @code{\script}
1429
1430 Prints a symbol above or below a note.  The argument is a string which
1431 points into the script-alias table defined in @file{scm/script.scm}, for
1432 information on how to add scripts, read the comments in that file.
1433 Usually the @code{\script} keyword is not used directly.  Various
1434 helpful identifier definitions appear in @file{script.ly}.
1435
1436
1437
1438
1439 @c.   {Grace notes}
1440 @node Grace notes
1441 @subsubsection Grace notes
1442 @cindex Grace notes
1443
1444 See @ref{Grace music}.
1445
1446 @c.   {Stem tremolo}
1447 @node Stem tremolo
1448 @subsubsection Stem tremolo
1449 @cindex tremolo marks
1450 @cindex @code{tremoloFlags}
1451
1452 [FIXME: should be \repeat]
1453
1454 Tremolo marks can be printed on a single note by adding
1455 `@code{:}[@var{length}]' after the note.  The length must be at
1456 least 8.  A @var{length} value of 8 gives one line across
1457 the note stem.  If the length is omitted, then the last value is
1458 used, or the value of the @code{tremoloFlags} property if there was
1459 no last value.
1460
1461 @lilypond[verbatim,fragment,center]
1462   c'2:8 c':32
1463 @end lilypond
1464
1465
1466 @c.   {Arpeggio}
1467 @node Arpeggio
1468 @subsubsection Arpeggio
1469 @cindex Arpeggio
1470
1471 @cindex broken arpeggio
1472 @cindex @code{\arpeggio}
1473
1474 You can specify an @rgrob{Arpeggio} sign on a chord by issuing an
1475 @c FIXME
1476
1477 @code{\arpeggio} request:
1478
1479
1480 @quotation
1481 @lilypond[fragment,relative,verbatim]
1482   \context Voice <c'\arpeggio e g c>
1483 @end lilypond
1484 @end quotation
1485
1486 Typesetting of simultanious chords with arpeggios can be controlled with
1487 the property @code{PianoStaff.connectArpeggios} @footnote{ FIXME:
1488 connectArpeggios.  Can't find the English terms for two kinds of
1489 arpeggio (Dutch: gebroken arpeggio vs doorlopend arpeggio).}  By
1490 default, LilyPond prints broken arpeggios; when set to true, one
1491 extended arpeggio sign is printed.
1492
1493 @quotation
1494 @lilypond[fragment,relative,verbatim]
1495   \context PianoStaff <
1496     \property PianoStaff.connectArpeggios = ##t
1497     \context Staff \context Voice <c''\arpeggio e g c>
1498     \context Staff=other \context Voice <c,\arpeggio e g>
1499   >  
1500 @end lilypond
1501 @end quotation
1502
1503
1504 @c.   {Glissando}
1505 @node Glissando 
1506 @subsubsection Glissando
1507 @cindex Glissando 
1508
1509 @cindex @code{\glissando}
1510
1511 A @rgrob{Glissando} line can be requested by issuing a
1512 FIXME
1513
1514 @code{\glissando} request:
1515
1516
1517 @quotation
1518 @lilypond[fragment,relative,verbatim]
1519   c'' \glissando c'
1520 @end lilypond
1521 @end quotation
1522
1523 Printing of the additional text @samp{gliss.} must be done manually.
1524
1525
1526 @c.    {Follow Thread}
1527 @subsubsection Follow Thread
1528 @cindex follow thread
1529 @cindex staff switching
1530 @cindex cross staff
1531
1532 @c Documented here because it looks like a glissando...
1533 @cindex @code{followThread}
1534 A glissando-like line can be printed to connect notes whenever a thread
1535 switches to another staff.  This is enabled if the property
1536 @code{PianoStaff.followThread} is set to true:
1537
1538 @quotation
1539 @lilypond[fragment,relative,verbatim]
1540   \context PianoStaff <
1541     \property PianoStaff.followThread = ##t
1542     \context Staff \context Voice {
1543       c'1
1544       \translator Staff=two
1545       b2 a
1546     }
1547     \context Staff=two {\clef bass; \skip 1*2;}
1548   >  
1549 @end lilypond
1550 @end quotation
1551
1552
1553
1554 @c.   {Dynamics}
1555 @node Dynamics
1556 @subsubsection Dynamics
1557 @cindex Dynamics
1558
1559 @unnumberedsubsec Dynamics
1560
1561 @cindex @code{\ppp}
1562 @cindex @code{\pp}
1563 @cindex @code{\p}
1564 @cindex @code{\mp}
1565 @cindex @code{\mf}
1566 @cindex @code{\f}
1567 @cindex @code{\ff}
1568 @cindex @code{\fff}
1569 @cindex @code{\ffff}
1570 @cindex @code{\fp}
1571 @cindex @code{\sf}
1572 @cindex @code{\sff}
1573 @cindex @code{\sp}
1574 @cindex @code{\spp}
1575 @cindex @code{\sfz}
1576 @cindex @code{\rfz}
1577
1578 Dynamic marks are specified by using an identifier after a note:
1579 @code{c4-\ff} (the dash is optional for dynamics: `@code{c4 \ff})'.  
1580 The available dynamic marks are:
1581 @code{\ppp},
1582 @code{\pp}, @code{\p}, @code{\mp},
1583 @code{\mf}, @code{\f}, @code{\ff},
1584 @code{\fff}, @code{\fff},
1585 @code{\fp}, @code{\sf},
1586 @code{\sff}, @code{\sp},
1587 @code{\spp}, @code{\sfz}, and
1588 @code{\rfz}.
1589
1590 See also @ref{Crescendo and Decrescendo}
1591
1592
1593 @c.   {Bar lines}
1594 @node Bar lines
1595 @subsubsection Bar lines
1596 @cindex Bar lines
1597
1598 @cindex @code{\bar}
1599 @cindex measure lines
1600 @cindex repeat bars
1601
1602 @example
1603   \bar @var{bartype};
1604 @end example
1605
1606 This is a short-cut for doing
1607 @example
1608   \property Score.whichBar = @var{bartype} 
1609 @end example
1610
1611 You are encouraged to use @code{\repeat} for repetitions.  See
1612 @ref{Repeat}, @ref{Volta}, and the documentation of @code{whichBar} in
1613 @ref{(lilypond-internals)LilyPond context properties}.
1614
1615
1616 [FIXME]
1617
1618 @c.   {Breath marks}
1619 @node Breath marks
1620 @subsubsection Breath marks
1621 @cindex Breath marks
1622
1623 @c.   {Rehearsal marks}
1624 @node Rehearsal marks
1625 @subsubsection Rehearsal marks
1626 @cindex Rehearsal marks
1627 @cindex mark
1628 @cindex @code{\mark}
1629
1630 @example
1631   \mark @var{unsigned};
1632 @cindex @code{Mark_engraver}
1633   \mark @var{string};
1634 @end example
1635
1636 Prints a mark over or under the staff.  
1637
1638
1639 @c.  {Bar check}
1640 @node Bar check
1641 @subsection Bar check
1642 @cindex Bar check
1643
1644 @cindex bar check
1645 @cindex @code{barCheckNoSynchronize}
1646 @cindex @code{|}
1647
1648
1649 Bar checks help you find errors in the input: Whenever one is
1650 encountered during interpretation, a warning message is issued if it
1651 doesn't fall at a measure boundary.  Depending on the value of
1652 @code{barCheckNoSynchronize},  the beginning of the measure will be
1653 relocated, so this can also be used to shorten measures.
1654
1655 A bar check is entered using the bar symbol, @code{|}
1656
1657 This can help you finding errors in the input.
1658
1659
1660 @c. {Lyrics entry}
1661 @node Lyrics entry
1662 @section Lyrics entry
1663 @cindex Lyrics entry
1664
1665 @menu
1666 * Lyrics mode::                 
1667 * Printing lyrics::             
1668 * Lyric hyphen::                
1669 * Lyric extender::              
1670 * Addlyrics::                   
1671 @end menu
1672
1673 @c.  {Lyrics mode}
1674 @node Lyrics mode
1675 @subsection Lyrics mode
1676 @cindex Lyrics mode
1677
1678 @cindex lyric mode
1679 @cindex @code{\lyrics}
1680
1681 Lyrics mode is introduced by the keyword @code{\lyrics}.  This mode has
1682 rules that make it easy to include punctuation and diacritical marks in
1683 words: The purpose of Lyrics mode is that you can enter lyrics in @TeX{}
1684 format or a standard encoding without needing quotes.  The precise
1685 definition of this mode is ludicrous, and this will remain so until the
1686 authors of LilyPond acquire a deeper understanding of character
1687 encoding, or someone else steps up to fix this.
1688
1689 A word in Lyrics mode begins with: an alphabetic character, @code{_},
1690 @code{?}, @code{!}, @code{:}, @code{'}, the control characters @code{^A}
1691 through @code{^F}, @code{^Q} through @code{^W}, @code{^Y}, @code{^^},
1692 any 8-bit character with ASCII code over 127, or a two-character
1693 combination of a backslash followed by one of @code{`}, @code{'},
1694 @code{"}, or @code{^}.
1695
1696 Subsequent characters of a word can be any character that is not a digit
1697 and not white space.  One important consequence of this is that a word
1698 can end with `@code{@}}', which may be confusing. However, LilyPond will
1699 issue a warning.  Any @code{_} character which appears in an unquoted
1700 word is converted to a space.  This provides a mechanism for introducing
1701 spaces into words without using quotes.  Quoted words can also be used
1702 in Lyrics mode to specify words that cannot be written with the above
1703 rules.  Here are some examples.  Not all of these words are printable by
1704 @TeX{}.
1705
1706 @example 
1707 Ah!             % a word
1708 2B_||_!2B       % not a word because it starts with a digit
1709 ``Hello''       % not a word because it starts with `
1710 _ _ _ _         % 4 words, each one a space 
1711 @end example 
1712
1713 Since combinations of numbers and dots are used for indicating
1714 durations, you can not enter real numbers in this mode.
1715
1716 [todo: include short table showing differences] 
1717
1718 @cindex lyrics expressions
1719
1720 Syllables are entered like notes, with pitches replaced by text.  For
1721 example, @code{Twin-4 kle4 twin-4 kle4} enters four syllables, each
1722 with quarter note duration.  Note that the hyphen has no special
1723 meaning for lyrics, and does not introduce special symbols.  See
1724 section @ref{Lexical modes} for a description of what is interpreted as
1725 lyrics.
1726
1727 Spaces can be introduced into a lyric either by using quotes
1728 (@code{"}) or by using an underscore without quotes: @code{He_could4
1729 not4}.  All unquoted underscores are converted to spaces.  Printing
1730 lyrics is discussed in section @ref{lyricprint}.
1731
1732
1733 @c.  {Printing Lyrics}
1734 @node Printing lyrics
1735 @subsection lyricprint
1736 @cindex lyrics
1737
1738
1739 @cindex printing!lyrics
1740
1741
1742 Lyric syllables must be interpreted within a @code{Lyrics} context
1743
1744 @cindex context!Lyrics
1745  for printing them.
1746
1747 Here is a full example: 
1748
1749 @quotation
1750 @lilypond[verbatim]
1751 \score {
1752   <
1753     \notes \transpose c'' {
1754       c d e c | c d e c |
1755       e f g2 | e4 f g2 \bar "|.";
1756     }
1757     \context Lyrics \lyrics { 
1758       Va-4 der Ja- cob Va- der Ja- cob
1759       Slaapt gij nog?2 Slaapt4 gij nog?2
1760     }
1761   >
1762 }
1763
1764 @end lilypond
1765 @end quotation
1766
1767 You may want a continuous line after the syllables to show melismata. 
1768 To achieve this effect, add a @code{__} lyric as a separate word
1769 after the lyric to be extended.  This will create an extender, a line
1770 that extends over the entire duration of the lyric.  This line will
1771 run all the way to the start of the next lyric, so you may want to
1772 shorten it by using a blank lyric (using @code{_}).
1773
1774 @quotation
1775
1776 @lilypond[verbatim]
1777 \score {
1778   <
1779     \notes \relative c'' {
1780       a4 () b () c () d | c () d () b () a | c () d () b () a
1781     }
1782     \context Lyrics \lyrics {
1783       foo1 __ | bar2. __ _4 | baz1 __
1784     }
1785   >
1786 }
1787
1788 @end lilypond
1789 @end quotation
1790
1791      
1792 If you want to have hyphens centered between syllables (rather than
1793 attached to the end of the first syllable) you can use the special
1794 `@code{-}@code{-}' lyric as a separate word between syllables.  This
1795 will result in a hyphen which length varies depending on the space
1796 between syllables, and which will be centered between the syllables. 
1797 For example:
1798
1799 @quotation
1800
1801 @lilypond[verbatim]
1802 \score {
1803   <
1804     \notes \transpose c'' {
1805       c d e c | c d e c |
1806       e f g2 | e4 f g2 \bar "|.";
1807     }
1808     \context Lyrics \lyrics {
1809       Va4 -- der Ja -- cob | Va -- der Ja -- cob |
1810       Slaapt gij nog?2 | Slaapt4 gij nog?2
1811     }
1812   >
1813 }
1814
1815 @end lilypond
1816 @end quotation
1817
1818
1819
1820
1821 @c.  {Lyric hyphen}
1822 @node Lyric hyphen
1823 @subsection Lyric hyphen
1824 @cindex Lyric hyphen
1825
1826 The syntax for a spanning hyphen (i.e., a hyphen that will be printed
1827 between two lyric syllables) is `@code{-}@code{-}'.
1828
1829 @c.  {Lyric extender}
1830 @node Lyric extender
1831 @subsection Lyric extender
1832 @cindex Lyric extender
1833 @cindex extender
1834 @cindex lyric extender
1835 @cindex hyphen
1836
1837 The syntax for an extender mark is @code{__}.  This syntax can only
1838 be used within lyrics mode.
1839
1840
1841
1842
1843 @c.  {Addlyrics}
1844 @node Addlyrics
1845 @subsection Addlyrics
1846 @cindex Addlyrics
1847
1848
1849 [explain automatic phrasing]
1850 @cindex automatic lyric durations
1851 @cindex @code{\addlyrics}
1852
1853 If you have lyrics that are set to a melody, you can import the rhythm
1854 of that melody into the lyrics using @code{\addlyrics}.  The syntax for
1855 this is
1856 @example
1857   \addlyrics @var{musicexpr1 musicexpr2}
1858 @end example
1859
1860 This means that both @var{musicexpr1} and @var{musicexpr2} are
1861 interpreted, but that every non-command atomic music expression
1862 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1863 of @var{musicexpr1}.
1864 @cindex @code{automaticMelismata}
1865
1866 If the property @code{automaticMelismata} is set in the
1867 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1868 notes.
1869
1870 @quotation
1871 @lilypond[verbatim,fragment]
1872 \addlyrics
1873 \transpose c'' {
1874   \property Voice.automaticMelismata = ##t
1875   c8 () cis d8. e16 f2
1876 }
1877 \context Lyrics \lyrics {
1878  do4 re mi fa }
1879 @end lilypond
1880 @end quotation
1881
1882 You should use a single rhythm melody, and single rhythm lyrics (a
1883 constant duration is the obvious choice).  If you do not, you will get
1884 undesired effects when using multiple stanzas:
1885
1886 @quotation
1887 @lilypond[verbatim,fragment]
1888 \addlyrics
1889 \transpose c'' {
1890   c8 () cis d8. e16 f2
1891 }
1892 \context Lyrics \lyrics
1893 < { do4 re mi fa }
1894   { do8 re mi fa } >
1895
1896 @end lilypond
1897 @end quotation
1898
1899 It is valid (but probably not very useful) to use notes instead of
1900 lyrics for @var{musicexpr2}.
1901
1902
1903
1904 @c. {Chord entry}
1905 @node Chord entry
1906 @section Chord entry
1907 @cindex Chord entry
1908
1909 @menu
1910 * Chords mode::                 
1911 * Entering named chords::       
1912 * Printing named chords::       
1913 @end menu
1914
1915 @c.  {Chords mode}
1916 @node Chords mode
1917 @subsection Chords mode
1918 @cindex Chords mode
1919
1920 Chord mode is introduced by the keyword
1921 @code{\chords}.  It is similar to Note mode, but
1922 words are also looked up in a chord modifier table (containing
1923 @code{maj}, @code{dim}, etc).
1924
1925 Since combinations of numbers and dots are used for indicating
1926 durations, you can not enter real numbers in this mode.  Dashes
1927 and carets are used to indicate chord additions and subtractions,
1928 so scripts can not be entered in Chord mode.
1929
1930 @c.  {Entering named chords}
1931 @node Entering named chords
1932 @subsection Entering named chords
1933 @cindex Chords names
1934
1935 Chord names are a way to generate simultaneous music expressions that
1936 correspond with traditional chord names.  It can only be used in
1937 Chord mode (see section @ref{Lexical modes}).
1938
1939 @example
1940
1941   @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1942 @end example
1943
1944 @var{tonic} should be the tonic note of the chord, and @var{duration}
1945 is the chord duration in the usual notation.  There are two kinds of
1946 modifiers.  One type is @emph{chord additions}, which are obtained by
1947 listing intervals separated by dots.  An interval is written by its
1948 number with an optional @code{+} or @code{-} to indicate raising or
1949 lowering by half a step.  Chord additions has two effects: It adds
1950 the specified interval and all lower odd numbered intervals to the
1951 chord, and it may lower or raise the specified interval.  Intervals
1952 must be separated by a dot (@code{.}).
1953
1954
1955 Throughout these examples, chords have been shifted around the staff
1956 using @code{\transpose}.
1957
1958
1959 @quotation
1960
1961 @lilypond[fragment,verbatim]
1962 \transpose c'' {
1963   \chords {
1964     c1  c:3-       c:7     c:8
1965     c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1966   }
1967 }
1968
1969 @end lilypond
1970 @end quotation
1971
1972 @cindex @code{aug}
1973 @cindex @code{dim}
1974 @cindex @code{maj}
1975 @cindex @code{sus}
1976
1977 The second type of modifier that may appear after the @code{:} is a
1978 named modifier.  Named modifiers are listed in the file
1979 @file{chord-modifiers.ly}.  The available modifiers are @code{m} and
1980 @code{min} which lower the 3rd half a step, `@code{aug}' which
1981 raises the 5th, `@code{dim}' which lowers the 5th,
1982 `@code{maj}' which adds a raised 7th, and `@code{sus}'
1983 which replaces the 5th with a 4th.
1984
1985 @quotation
1986
1987 @lilypond[fragment,verbatim]
1988 \transpose c'' {
1989   \chords {
1990     c1:m c:min7 c:maj c:aug c:dim c:sus
1991   }
1992 }
1993
1994 @end lilypond
1995 @end quotation
1996  
1997
1998 Chord subtractions are used to eliminate notes from a chord.  The
1999 notes to be subtracted are listed after a @code{^} character,
2000 separated by dots.
2001
2002 @lilypond[fragment,verbatim,center]
2003   \transpose c'' {
2004     \chords {
2005       c1^3 c:7^5.3 c:8^7
2006     }
2007   }
2008 @end lilypond 
2009 @cindex @code{/}
2010
2011 Chord inversions can be specified by appending `@code{/}' and
2012 the name of a single note to a chord.  This has the effect of
2013 lowering the specified note by an octave so it becomes the lowest
2014 note in the chord.  If the specified note is not in the chord, a
2015 warning will be printed.
2016
2017 @lilypond[fragment,verbatim,center]
2018   \transpose c''' {
2019     \chords {
2020       c1 c/e c/g c:7/e
2021     }
2022   }
2023
2024 @end lilypond 
2025 @cindex @code{/+}
2026
2027 Bass notes can be added by `@code{/+}' and
2028 the name of a single note to a chord.  This has the effect of
2029 adding the specified note to the chord, lowered by an octave,
2030 so it becomes the lowest note in the chord.
2031
2032 @lilypond[fragment,verbatim,center]
2033   \transpose c''' {
2034     \chords {
2035       c1 c/+c c/+g c:7/+b
2036     }
2037   }
2038
2039 @end lilypond 
2040
2041 The most interesting application is printing  chords using chord names,
2042 See @ref{Chord names}.
2043
2044 You should not combine @code{\relative} with named chords. [FIXME]
2045
2046 @c.  {Printing named chords}
2047 @node Printing named chords
2048 @subsection Printing named chords
2049
2050 @cindex chord names
2051 @cindex chords
2052
2053 @cindex printing!chord names
2054 @cindex @code{ChordNames}
2055 @cindex @code{ChordNameVoice}
2056
2057 For displaying printed chord names, use the @code{ChordNames} and
2058 @code{ChordNameVoice} contexts.  The chords may be entered either using
2059 the notation described above, or directly using simultaneous music.
2060
2061 @quotation
2062 @lilypond[verbatim]
2063 scheme = \notes {
2064   \chords {a1 b c} <d f g>  <e g b>
2065 }
2066 \score {
2067   \notes<
2068     \context ChordNamesVoice \scheme
2069     \context Staff \transpose c'' \scheme
2070   >
2071   \paper { linewidth = -1.; }
2072 }
2073 @end lilypond
2074 @end quotation
2075
2076 You can make the chord changes stand out more by setting property
2077 @code{ChordNames.chordChanges} to true.  This will only display chord
2078 names when there's a change in the chords scheme, but always display the
2079 chord name after a line break:
2080
2081 @c bug
2082 @quotation
2083 @lilypond[verbatim]
2084 scheme = \chords {
2085   c1:m \break c:m c:m c:m d
2086 }
2087
2088 \score {
2089   \notes <
2090     \context ChordNames \scheme
2091     \context Staff \transpose c'' \scheme
2092   >
2093   \paper{
2094     linewidth = 40 * \staffspace;
2095     \translator {
2096       \ChordNamesContext
2097       chordChanges = ##t
2098     }
2099   }
2100 }
2101 @end lilypond
2102 @end quotation
2103
2104
2105
2106 LilyPond examines chords specified as lists of notes to determine a
2107 name to give the chord. LilyPond will not try to
2108 identify chord inversions or added base, which may result in strange
2109 chord names when chords are entered as a list of pitches:
2110
2111 @quotation
2112 @lilypond[verbatim,center]
2113 scheme = \notes {
2114   <c'1 e' g'>
2115   <e' g' c''>
2116   <e e' g' c''>
2117 }
2118
2119 \score {
2120   <
2121     \context ChordNamesVoice \scheme
2122     \context Staff \scheme
2123   >
2124   \paper { linewidth = -1.; }
2125 }
2126 @end lilypond
2127 @end quotation
2128
2129 To specify chord inversions, append @code{/<notename>}.  To specify an
2130 added bass note, append @code{/+<notename}:
2131
2132 @quotation
2133 @lilypond[verbatim,center]
2134 scheme = \chords {
2135   d1 d/a d/+gis
2136 }
2137
2138 \score {
2139   \notes <
2140     \context ChordNames \scheme
2141     \context Staff \transpose c'' \scheme
2142   >
2143   \paper { linewidth = -1.; }
2144 }
2145 @end lilypond
2146 @end quotation
2147
2148 The chord names that LilyPond should print are fully customizable.  The
2149 code to print chord names is written in Scheme. It can be found in
2150 @file{scm/chord-name.scm}.  Chord names are based on Banter style
2151 naming, which is unambiguous and has a logical structure.  Typical
2152 American style chord names are implemented as a variation on Banter
2153 names, they can be selected by setting property @code{ChordName.style}
2154 to @code{american}:
2155
2156 @quotation
2157 @lilypond[verbatim]
2158 \include "english.ly"
2159
2160 scheme = \chords {
2161   c         % Major triad
2162   cs:m      % Minor triad
2163   df:m5-    % Diminished triad
2164   c:5^3     % Root-fifth chord
2165   c:4^3     % Suspended fourth triad
2166   c:5+      % Augmented triad
2167   c:2^3     % "2" chord
2168   c:m5-.7-  % Diminished seventh
2169   c:7+      % Major seventh
2170   c:7.4^3   % Dominant seventh suspended fourth
2171   c:5+.7    % Augmented dominant seventh
2172   c:m5-.7   % "Half" diminished seventh
2173   c:5-.7    % Dominant seventh flat fifth
2174   c:5-.7+   % Major seventh flat fifth
2175   c:m7+     % Minor-major seventh
2176   c:m7      % Minor seventh
2177   c:7       % Dominant seventh
2178   c:6       % Major sixth
2179   c:m6      % Minor sixth
2180   c:9^7     % Major triad w/added ninth
2181   c:6.9^7   % Six/Nine chord
2182   c:9       % Dominant ninth 
2183   c:7+.9    % Major ninth
2184   c:m7.9    % Minor ninth
2185 }
2186
2187 \score {
2188   \notes <
2189     \context ChordNames \scheme
2190     \context Staff \transpose c'' \scheme
2191   >
2192   \paper {
2193     \translator { 
2194       \ChordNamesContext
2195       ChordName \override #'word-space = #1 
2196       ChordName \override #'style = #'american
2197     }
2198   }
2199 }
2200 @end lilypond
2201 @end quotation
2202
2203 Similarly, Jazz style chord names are implemented as a variation on
2204 American style names:
2205 @quotation
2206 @lilypond[verbatim]
2207 scheme = \chords {
2208   % major chords
2209   c
2210   c:6           % 6 = major triad with added sixth
2211   c:maj         % triangle = maj
2212   c:6.9^7       % 6/9 
2213   c:9^7         % add9
2214
2215   % minor chords
2216   c:m           % m = minor triad
2217   c:m.6         % m6 = minor triad with added sixth
2218   c:m.7+        % m triangle = minor major seventh chord
2219   c:3-.6.9^7    % m6/9 
2220   c:m.7         % m7
2221   c:3-.9        % m9
2222   c:3-.9^7      % madd9
2223
2224   % dominant chords
2225   c:7           % 7 = dominant
2226   c:7.5+        % +7 = augmented dominant
2227   c:7.5-        % 7b5 = hard diminished dominant
2228   c:9           % 7(9)
2229   c:9-          % 7(b9)
2230   c:9+          % 7(#9)
2231   c:13^9.11     % 7(13)
2232   c:13-^9.11    % 7(b13)
2233   c:13^11       % 7(9,13)
2234   c:13.9-^11    % 7(b9,13)
2235   c:13.9+^11    % 7(#9,13)
2236   c:13-^11      % 7(9,b13)
2237   c:13-.9-^11   % 7(b9,b13)
2238   c:13-.9+^11   % 7(#9,b13)
2239
2240   % half diminished chords
2241   c:m5-.7               % slashed o = m7b5
2242   c:9.3-.5-     % o/7(pure 9)
2243
2244   % diminished chords
2245   c:m5-.7-      % o = diminished seventh chord
2246 }
2247
2248 \score {
2249   \notes <
2250     \context ChordNames \scheme
2251     \context Staff \transpose c'' \scheme
2252   >
2253   \paper {
2254     \translator { 
2255       \ChordNamesContext
2256       ChordName \override #'word-space = #1 
2257       ChordName \override #'style = #'jazz
2258     }
2259   }
2260 }
2261 @end lilypond
2262 @end quotation
2263
2264
2265
2266
2267 @c. {Page layout}
2268 @node Page layout
2269 @section Page layout
2270 @cindex Page layout
2271
2272 @menu
2273 * Paper block::                 
2274 * Paper variables::             
2275 * Font Size::                   
2276 * Paper size::                  
2277 * Line break::                  
2278 * Page break::                  
2279 @end menu
2280
2281 @c.  {Paper block}
2282 @node Paper block
2283 @subsection Paper block
2284 @cindex Paper block
2285
2286 The most important output definition is the @code{\paper} block, for
2287 music notation.  The syntax is
2288
2289 @example
2290   @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2291 @end example
2292
2293 where each of the items is one of
2294
2295 @itemize @bullet
2296   @item  An assignment.  The assignment must be terminated by a
2297        semicolon.  
2298
2299   @item  A context definition.  See section @ref{contextdefs} for
2300        more information on context definitions.
2301
2302 @ignore
2303
2304                 FIXME
2305
2306
2307   @item
2308         
2309         A margin shape declaration.  The syntax is
2310 @cindex @code{\shape}
2311        @example
2312
2313          \shape @var{indent1}@code{,} @var{width1}@code{,}
2314                       @var{indent2}@code{,} @var{width2} @dots{} @code{;}
2315          @end example
2316
2317        
2318
2319        Each pair of @var{indent} and @var{width} values is a dimension
2320        specifying how far to indent and how wide to make the line. 
2321        The indentation and width of successive lines are specified by
2322        the successive pairs of dimensions.  The last pair of
2323        dimensions will define the characeristics of all lines beyond
2324        those explicitly specified.
2325 @end ignore
2326
2327   @item  \stylesheet  declaration.  Its syntax is
2328        @example
2329                 \stylesheet @var{alist}
2330        @end example
2331
2332         See @file{font.scm} for details of @var{alist}.
2333 @end itemize
2334
2335 @c.  {Paper variables}
2336 @node Paper variables
2337 @subsection Paper variables 
2338 @cindex Paper variables
2339
2340 The paper block has some variables you may want to use or change:
2341
2342 @table @code
2343 @cindex @code{indent}
2344   @item @code{indent}  
2345     The indentation of the first line of music.
2346 @cindex @code{staffspace}
2347
2348   @item @code{staffspace}
2349     The distance between two staff lines, calculated from the center
2350     of the lines.  You should use either this or @code{rulethickness}
2351     as a unit for distances you modify.
2352   
2353 @cindex @code{linewidth}
2354   @item @code{linewidth}  
2355     Sets the width of the lines.  If set to -1.0, a single
2356     unjustified line is produced.  If you use this variable, you
2357     probably want to define it in staff spaces, ie
2358     @example
2359         linewidth = 30 * \staffspace;
2360     @end example
2361 @cindex @code{textheight}
2362
2363   @item @code{textheight}  
2364     Sets the total height of the music on each page. Only used by
2365     ly2dvi.
2366 @cindex @code{interscoreline}
2367
2368   @item @code{interscoreline}  
2369     Sets the spacing between the score lines. Defaults to 16 pt.
2370 @cindex @code{interscorelinefill}
2371
2372   @item @code{interscorelinefill}  
2373     If set to a positive number, the distance between the score 
2374     lines will stretch in order to fill the full page. In that
2375     case @code{interscoreline} specifies the minimum spacing.
2376     Defaults to 0.
2377 @cindex @code{stafflinethickness}
2378
2379   @item @code{stafflinethickness}  
2380     Determines the thickness of staff lines, and also acts as a scaling
2381     parameter for other line thicknesses.
2382 @end table
2383
2384
2385 @c.  {Font size}
2386 @node Font Size
2387 @subsection Font size
2388 @cindex font size
2389
2390 The Feta font provides musical symbols at six different sizes.  These
2391 fonts are 11 point, 13 point, 16 point, 20 point,
2392 23 point, and 26 point.  The point size of a font is the
2393 height of the five lines in a staff when displayed in the font.
2394
2395 Definitions for these sizes are the files @file{paperSZ.ly}, where
2396 @code{SZ} is one of 11, 13, 16, 20, 23 and 26.  If you include any of
2397 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2398 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2399 @code{paperTwentysix} are defined respectively.  The default
2400 @code{\paper} block is also set.
2401
2402 The font definitions are generated using a Scheme function. For more
2403 details, see the file @file{font.scm}.
2404
2405
2406
2407 @c.  {Paper size}
2408 @node Paper size
2409 @subsection Paper size
2410 @cindex Paper size
2411
2412 @cindex paper size
2413 @cindex page size
2414 @cindex @code{papersize}
2415
2416 To change the paper size, you must first set the
2417 @code{papersize} variable at top level.  Set it to
2418 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
2419 specification, you must set the font as described above.  If you want
2420 the default font, then use the 20 point font.  The new paper size will
2421 not take effect if the font is not loaded and selected afterwards.
2422
2423 @example
2424         papersize = "a4"
2425         \include "paper16.ly"
2426
2427         \score @{
2428                 ...
2429                 \paper @{ \paperSixteen @}
2430         @}
2431 @end example
2432
2433 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2434 will set the paper variables @code{hsize} and @code{vsize} (used by
2435 @code{ly2dvi})
2436
2437
2438
2439
2440
2441
2442
2443 @c.  {Line break}
2444 @node Line break
2445 @subsection Line break
2446 @cindex Line break
2447
2448
2449 @cindex @code{\penalty}
2450
2451 @example
2452   \penalty @var{int} @code{;}
2453 @end example
2454
2455 Discourage or encourage line breaks.  See @ref{Page layout}. 
2456
2457
2458
2459
2460 @cindex line breaks
2461 @cindex breaking lines
2462
2463 Line breaks are normally computed automatically. They are chosen such
2464 that the resulting spacing has low variation, and looks neither cramped
2465 nor loose.
2466
2467 Occasionally you might want to override the automatic breaks; you can do
2468 this by specifying @code{\break} (see also @ref{Pre-defined
2469 Identifiers}). This will force a line break at this point. Do remember
2470 that line breaks can only occur at places where there are barlines.  If
2471 you want to have a line break where there is no barline, you can force a
2472 barline by entering @code{\bar "";}.
2473
2474
2475
2476
2477 @c.  {Page break}
2478 @node Page break
2479 @subsection Page break
2480 @cindex Page break
2481
2482
2483 Not implemented, but see @ref{Tricks}
2484
2485 Page breaks are normally computed by @TeX{}, so they are not under direct
2486 control.  However, you can insert a commands into the .tex output to
2487 instruct @TeX{} where to break pages. For more details, see  the
2488 example file @file{input/test/between-systems.ly}
2489
2490
2491 @cindex page breaks
2492 @cindex breaking pages
2493
2494
2495
2496
2497
2498 @c. {Sound}
2499 @node Sound
2500 @section Sound
2501 @cindex Sound
2502 @menu
2503 * MIDI block::                  
2504 * MIDI instrument names::       
2505 * Tempo::                       
2506 @end menu
2507
2508 @c.  {MIDI block}
2509 @node MIDI block
2510 @subsection MIDI block
2511 @cindex MIDI block
2512
2513
2514 The MIDI block is analogous to the paper block, but it is somewhat
2515 simpler.  The @code{\midi} block can contain:
2516 @cindex MIDI block
2517
2518 @itemize @bullet
2519   @item  a @code{\tempo} definition
2520   @item  context definitions
2521 @end itemize
2522
2523 Assignments in the @code{\midi} block are not allowed.
2524
2525
2526
2527 @cindex context definition
2528
2529 Context definitions follow precisely the same syntax as within the
2530 \paper block.  Translation modules for sound are called performers.
2531 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2532
2533
2534 @c.  {MIDI instrument names}
2535 @node MIDI instrument names
2536 @subsection MIDI instrument names
2537 @cindex instrument names
2538 @cindex @code{Staff.midiInstrument}
2539 @cindex @code{Staff.instrument}
2540
2541 The MIDI instrument name is set by the @code{Staff.midiInstrument}
2542 property or, if that property is not set, the @code{Staff.instrument}
2543 property.  The instrument name should be chosen from the following list.
2544 If the selected string does not exactly match, then LilyPond uses the
2545 default piano.
2546
2547 [FIXME: to appendix ]
2548
2549
2550 @example 
2551 "acoustic grand"            "contrabass"           "lead 7 (fifths)"
2552 "bright acoustic"           "tremolo strings"      "lead 8 (bass+lead)"
2553 "electric grand"            "pizzicato strings"    "pad 1 (new age)"
2554 "honky-tonk"                "orchestral strings"   "pad 2 (warm)"
2555 "electric piano 1"          "timpani"              "pad 3 (polysynth)"
2556 "electric piano 2"          "string ensemble 1"    "pad 4 (choir)"
2557 "harpsichord"               "string ensemble 2"    "pad 5 (bowed)"
2558 "clav"                      "synthstrings 1"       "pad 6 (metallic)"
2559 "celesta"                   "synthstrings 2"       "pad 7 (halo)"
2560 "glockenspiel"              "choir aahs"           "pad 8 (sweep)"
2561 "music box"                 "voice oohs"           "fx 1 (rain)"
2562 "vibraphone"                "synth voice"          "fx 2 (soundtrack)"
2563 "marimba"                   "orchestra hit"        "fx 3 (crystal)"
2564 "xylophone"                 "trumpet"              "fx 4 (atmosphere)"
2565 "tubular bells"             "trombone"             "fx 5 (brightness)"
2566 "dulcimer"                  "tuba"                 "fx 6 (goblins)"
2567 "drawbar organ"             "muted trumpet"        "fx 7 (echoes)"
2568 "percussive organ"          "french horn"          "fx 8 (sci-fi)"
2569 "rock organ"                "brass section"        "sitar"
2570 "church organ"              "synthbrass 1"         "banjo"
2571 "reed organ"                "synthbrass 2"         "shamisen"
2572 "accordion"                 "soprano sax"          "koto"
2573 "harmonica"                 "alto sax"             "kalimba"
2574 "concertina"                "tenor sax"            "bagpipe"
2575 "acoustic guitar (nylon)"   "baritone sax"         "fiddle"
2576 "acoustic guitar (steel)"   "oboe"                 "shanai"
2577 "electric guitar (jazz)"    "english horn"         "tinkle bell"
2578 "electric guitar (clean)"   "bassoon"              "agogo"
2579 "electric guitar (muted)"   "clarinet"             "steel drums"
2580 "overdriven guitar"         "piccolo"              "woodblock"
2581 "distorted guitar"          "flute"                "taiko drum"
2582 "guitar harmonics"          "recorder"             "melodic tom"
2583 "acoustic bass"             "pan flute"            "synth drum"
2584 "electric bass (finger)"    "blown bottle"         "reverse cymbal"
2585 "electric bass (pick)"      "skakuhachi"           "guitar fret noise"
2586 "fretless bass"             "whistle"              "breath noise"
2587 "slap bass 1"               "ocarina"              "seashore"
2588 "slap bass 2"               "lead 1 (square)"      "bird tweet"
2589 "synth bass 1"              "lead 2 (sawtooth)"    "telephone ring"
2590 "synth bass 2"              "lead 3 (calliope)"    "helicopter"
2591 "violin"                    "lead 4 (chiff)"       "applause"
2592 "viola"                     "lead 5 (charang)"     "gunshot"
2593 "cello"                     "lead 6 (voice)" 
2594 @end example 
2595
2596
2597
2598
2599
2600 @c.  {Tempo}
2601 @node Tempo
2602 @subsection Tempo
2603 @cindex Tempo
2604 @cindex beats per minute
2605 @cindex metronome marking
2606
2607 @cindex @code{\tempo}
2608 @example
2609   \tempo @var{duration} = @var{perminute} @code{;}
2610 @end example
2611
2612 Used to specify the tempo.  For example, @code{\tempo 4 = 76;} requests
2613 output with 76 quarter notes per minute.
2614
2615
2616
2617
2618
2619 @c. {Music entry}
2620 @node Music entry
2621 @section Music entry
2622 @cindex Music entry
2623 @menu
2624 * Pre-defined Identifiers::     
2625 * Point and click::             
2626 @end menu
2627
2628 @c.  {Pre-defined Identifiers}
2629 @node Pre-defined Identifiers
2630 @subsection Pre-defined Identifiers
2631 @cindex pre-defined identifiers
2632
2633
2634 Various identifiers are defined in the initialization files to
2635 provide shorthands for some settings.  Most of them are in
2636 @file{ly/declarations.ly} and @file{ly/property.ly}.
2637
2638 @table @code
2639 @cindex @code{\break}  
2640   @item @code{\break}
2641     Force a line break in music by using a large argument for the
2642     keyword @code{\penalty}.
2643
2644 @cindex @code{\nobreak}  
2645   @item @code{\nobreak}
2646     Prevent a line break in music by using a large negative argument
2647     for the keyword @code{\penalty}.
2648
2649 @cindex @code{\shiftOff}  
2650   @item @code{\shiftOff}
2651     Disable horizontal shifting of note heads that collide. 
2652
2653 @cindex @code{\shiftOn}  
2654   @item @code{\shiftOn}
2655     Enable note heads that collide with other note heads to be
2656     shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
2657 set different shift values.
2658
2659 @cindex @code{\stemBoth}  
2660   @item @code{\stemBoth}
2661     Allow stems, beams, and slurs to point either upwards or
2662     downwards, decided automatically by LilyPond.
2663
2664 @cindex @code{\stemDown}  
2665   @item @code{\stemDown}
2666     Force stems, beams, and slurs to point down.
2667
2668 @cindex @code{\stemUp}  
2669   @item @code{\stemUp}
2670     Force stems, beams and slurs to point up.
2671
2672 @end table
2673
2674
2675 @c.  {Point and click}
2676 @node Point and click
2677 @subsection Point and click
2678
2679 [todo]
2680
2681 @c. {Engravers}
2682 @node Engravers
2683 @section Engravers
2684 @cindex engravers
2685 @menu
2686 * Context definitions::         
2687 * Notation Contexts::           
2688 @end menu
2689
2690 @c.  {Context definitions}
2691 @node Context definitions
2692 @subsection Context definitions
2693
2694 @cindex context definition
2695 @cindex translator definition
2696 @cindex engraver hacking
2697
2698
2699 A notation contexts is defined by the following information
2700
2701 @enumerate 1
2702   @item  A name.
2703
2704   @item  The LilyPond modules that do the actual conversion of music to
2705        notation.  Each module is a so-called
2706        @emph{engraver}
2707 @cindex engraver
2708 .
2709
2710   @item  How these modules should cooperate, i.e. which ``cooperation
2711        module'' should be used.  This cooperation module is a special
2712        type of engraver.
2713
2714   @item  What other contexts the context can contain,
2715
2716   @item  What properties are defined.
2717 @end enumerate
2718
2719 A context definition has this syntax:
2720
2721 @example
2722
2723   \translator @code{@{}
2724                       @var{translatorinit} @var{translatormodifierlist}
2725                     @code{@}}
2726 @end example
2727
2728 @var{translatorinit} can be an identifier or of the form
2729
2730 @example
2731
2732   \type @var{typename} @code{;}
2733 @end example
2734
2735 @var{typename} is one of
2736
2737 @table @code
2738 @cindex @code{Engraver_group_engraver}
2739   @item @code{Engraver_group_engraver}  
2740     The standard cooperation engraver.
2741 @cindex @code{Score_engraver}
2742
2743   @item @code{Score_engraver}  
2744     This is cooperation module that should be in the top level context.
2745 @cindex @code{Grace_engraver_group}
2746
2747   @item @code{Grace_engraver_group}  
2748     This is a special cooperation module (resembling
2749     @code{Score_engraver}) that is used to created an embedded
2750     `miniscore'.
2751 @end table 
2752
2753 @var{translatormodifierlist} is a list of items where each item is
2754 one of
2755
2756 @itemize @bullet
2757   @item  @code{\consists} @var{engravername} @code{;}  
2758     Add @var{engravername} to the list of modules in this context. 
2759   The order of engravers added with @code{\consists} is
2760     significant.
2761   
2762   @item  @code{\consistsend} @var{engravername} @code{;}  
2763     Analogous to @code{\consists}, but makes sure that
2764     @var{engravername} is always added to the end of the list of
2765     engravers.
2766
2767     Some engraver types need to be at the end of the list; this
2768     insures they are put there, and stay there, if a user adds or
2769     removes engravers.  This command is usually not needed for
2770     end-users.
2771     
2772   @item  @code{\accepts} @var{contextname} @code{;}  
2773     Add @var{contextname} to the list of  context this context can
2774     contain.  The first listed context is the context to create by
2775     default.
2776
2777   @item @code{\denies}. The opposite of @code{\accepts}. Added for
2778 completeness, but is never used in practice.
2779  
2780   
2781   @item  @code{\remove} @var{engravername} @code{;}  
2782     Remove a previously added (with @code{\consists}) engraver.
2783   
2784   @item  @code{\name} @var{contextname} @code{;}  
2785     This sets name of the context, e.g. @code{Staff}, @code{Voice}.  If
2786     the name is not specified, the translator won't do anything.
2787
2788   @item  @var{propname} @code{=} @var{value} @code{;}  
2789     A property assignment.  It is allowed to use reals for
2790     @var{value}.
2791 @end itemize
2792
2793 In the @code{\paper} block, it is also possible to define translator
2794 identifiers.  Like other block identifiers, the identifier can only
2795 be used as the very first item of a translator.  In order to define
2796 such an identifier outside of @code{\score}, you must do
2797
2798 @quotation
2799
2800 @example 
2801 \paper @{
2802   foo = \translator @{ @dots{} @}
2803 @}
2804 \score @{
2805   \notes @{
2806     @dots{}
2807   @}
2808   \paper @{
2809     \translator @{ \foo @dots{} @}
2810   @}
2811 @} 
2812 @end example 
2813
2814 @end quotation
2815
2816
2817 @cindex paper types, engravers, and pre-defined translators
2818
2819 Some pre-defined identifiers can simplify modification of
2820 translators.  The pre-defined identifiers are:
2821
2822 @table @code
2823 @cindex @code{StaffContext}
2824   @item @code{StaffContext}  
2825     Default Staff context. 
2826 @cindex @code{RhythmicStaffContext}
2827
2828   @item @code{RhythmicStaffContext}  
2829     Default RhythmicStaff context. 
2830 @cindex @code{VoiceContext}
2831
2832   @item @code{VoiceContext}  
2833     Default Voice context.  
2834 @cindex @code{ScoreContext}
2835
2836   @item @code{ScoreContext}  
2837     Default Score context. 
2838 @cindex @code{ScoreWithNumbers}
2839
2840   @item @code{ScoreWithNumbers}  
2841     Score context with numbering at the Score level.
2842 @cindex @code{BarNumberingStaffContext}
2843
2844   @item @code{BarNumberingStaffContext}  
2845     Staff context with numbering at the Staff level.
2846 @cindex @code{HaraKiriStaffContext}
2847
2848   @item @code{HaraKiriStaffContext}  
2849     Staff context that does not print if it only contains rests. 
2850     Useful for orchestral scores.@footnote{Harakiri, also called
2851     Seppuku, is the ritual suicide of the Japanese Samourai warriors.}
2852 @cindex @code{OrchestralPartStaffContext}
2853
2854   @item @code{OrchestralPartStaffContext}
2855 @cindex @code{OrchestralScoreContext}
2856
2857   @item @code{OrchestralScoreContext}
2858 @end table
2859
2860 Using these pre-defined values, you can remove or add items to the
2861 translator:
2862
2863 @quotation
2864
2865 @example 
2866 \paper @{
2867   \translator @{
2868     \StaffContext
2869     \remove Some_engraver;
2870     \consists Different_engraver;
2871   @}
2872 @} 
2873 @end example 
2874
2875 @end quotation
2876
2877       
2878
2879
2880 @c.  {Notation Contexts}
2881 @node Notation Contexts
2882 @subsection Notation Contexts
2883
2884 @cindex notation contexts
2885
2886 Notation contexts are objects that only exist during a run of
2887 LilyPond.  During the interpretation phase of LilyPond, the Music
2888 expression contained in a @code{\score} block is interpreted in time
2889 order.  This is the order in which humans read, play, and write
2890 music.
2891
2892 A context is an object that holds the reading state of the
2893 expression; it contains information like
2894
2895 @itemize @bullet
2896   @item What notes are playing at this point?
2897   @item What symbols will be printed at this point?
2898   @item In what style will they printed?
2899   @item What is the current key signature, time signature, point within
2900        the measure, etc.?
2901 @end itemize
2902
2903 Contexts are grouped hierarchically: A @code{Voice} context is
2904 contained in a @code{Staff} context (because a staff can contain
2905 multiple voices at any point), a @code{Staff} context is contained in
2906 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
2907 these can all contain multiple staffs).
2908
2909 Contexts associated with sheet music output are called @emph{notation
2910 contexts}, those for sound output are called performance contexts.
2911
2912 Contexts are created either manually or automatically.  Initially, the
2913 top level music expression is interpreted by the top level context (the
2914 @code{Score} context).  When a atomic music expression (i.e. a note, a
2915 rest, etc.), a nested set of contexts is created that can process these
2916 atomic expressions, as in this example:
2917
2918 @example
2919 \score @{ \notes @{ c4 @} @} 
2920 @end example 
2921
2922 The sequential music, `@code{@{ c4 @}}' is interpreted by @code{Score}
2923 context. When the note @code{c4} itself is interpreted, a set of
2924 contexts is needed that will accept notes.  The default for this is a
2925 @code{Voice} context, contained in a @code{Staff} context.  Creation of
2926 these contexts results in the staff being printed.
2927
2928 @cindex context
2929
2930 You can also create contexts manually, and you probably have to do so
2931 if you want to typeset complicated multiple part material.  If a
2932 `@code{\context} @var{name} @var{musicexpr}' expression is encountered
2933 during the interpretation phase, the @var{musicexpr} argument will be
2934 interpreted with a context of type @var{name}.  If you specify a name,
2935 the specific context with that name is searched.
2936
2937 [type vs id]
2938
2939 If a context of the specified type and name can not be found, a new
2940 one is created.  For example,
2941
2942 @quotation
2943
2944 @lilypond[verbatim]
2945 \score {
2946   \notes \relative c'' {
2947     c4 <d4 \context Staff = "another" e4> f
2948   }
2949 }
2950
2951 @end lilypond
2952 @end quotation
2953
2954 In this example, the @code{c} and @code{d} are printed on the
2955 default staff.  For the @code{e}, a context Staff called
2956 @code{another} is specified; since that does not exist, a new
2957 context is created.  Within @code{another}, a (default) Voice context
2958 is created for the @code{e4}.  When all music referring to a
2959 context is finished, the context is ended as well.  So after the
2960 third quarter, @code{another} is removed.
2961
2962 Almost all music expressions inherit their interpretation context
2963 from their parent.  In other words, suppose that the syntax for a
2964 music expression is
2965
2966 @example
2967
2968   \keyword @var{musicexpr1} @var{musicexpr2} @dots{}
2969 @end example
2970
2971 When the interpretation of this music expression starts, the context
2972 for @var{musicexpr1}, @var{musicexpr2}, etc. is that of the total
2973 expression.
2974
2975 Lastly, you may wonder, why this:
2976
2977 @quotation
2978
2979 @example 
2980 \score @{
2981   \notes \relative c'' @{
2982     c4 d4 e4
2983   @}
2984 @} 
2985 @end example 
2986
2987 @end quotation
2988
2989 doesn't result in this:
2990
2991 @lilypond[]
2992
2993   \score {
2994     \notes \relative c'' {
2995       <c4> <d4> <e4>
2996     }
2997   }
2998
2999 @end lilypond
3000
3001 For the @code{c4}, a default @code{Staff} (with a contained
3002 @code{Voice}) context is created.  After the @code{c4} ends, no
3003 music refers to this default staff, so it would be ended, with the
3004 result shown.  To prevent this inconvenient behavior, the context to
3005 which the sequential music refers is adjusted during the
3006 interpretation.  So after the @code{c4} ends, the context of the
3007 sequential music is also the default @code{Voice} context. 
3008 The @code{d4} gets interpreted in the same context
3009 as @code{c4}.
3010
3011 Properties that are set in one context are inherited by all of the
3012 contained contexts.  This means that a property valid for the
3013 @code{Voice} context can be set in the @code{Score} context (for
3014 example) and thus take effect in all @code{Voice} contexts.
3015
3016 Properties can be preset within the @code{\translator} block
3017 corresponding to the appropriate context.  In this case, the syntax
3018 is
3019
3020 @example
3021   @var{propname} @code{=} @var{value}
3022 @end example
3023
3024 This assignment happens before interpretation starts, so a
3025 @code{\property} expression will override any predefined settings.
3026
3027 The property settings are used during the interpretation phase.  They
3028 are read by the LilyPond modules where interpretation contexts are
3029 built of.  These modules are called @emph{translators}.  Translators for
3030 notation are called @emph{engravers}, and translators for sound are
3031 called @emph{performers}.
3032
3033
3034
3035 @c. {Lexer innards}
3036 @node Lexer innards
3037 @section Lexer innards
3038 @cindex Lexer innards
3039 @menu
3040 * Top level::                   
3041 * Identifiers::                 
3042 * Assignments::                 
3043 * Lexical details::             
3044 * Lexical modes::               
3045 * Ambiguities::                 
3046 @end menu
3047
3048 @c.  {Top level}
3049 @node Top level
3050 @subsection Top level
3051 @cindex Top level
3052
3053 This section describes what you may enter at top level.
3054
3055
3056 @unnumberedsubsec Score definition
3057 @cindex score definition
3058
3059 The output is generated combining a music expression with an output
3060 definition.  A score block has the following syntax:
3061
3062 @example
3063   \score @{ @var{musicexpr} @var{outputdefs} @}
3064 @end example
3065
3066 @var{outputdefs} are zero or more output definitions.  If no output
3067 definition is supplied, the default @code{\paper} block will be added.
3068
3069
3070 @c.   {Score}
3071 @subsubsection Score
3072 @cindex Score
3073
3074 @c.   {Paper}
3075 @subsubsection Paper
3076 @cindex Paper
3077
3078 @c.   {Midi}
3079 @subsubsection Midi
3080 @cindex Midi
3081
3082 @c.   {Header}
3083 @subsubsection Header
3084 @cindex Header
3085 @cindex @code{\header}
3086
3087 The syntax is
3088
3089 @example
3090   \header @{ @var{key1} = @var{val1};
3091 @cindex @code{ly2dvi}
3092              @var{key2} = @var{val2}; @dots{} @}
3093 @end example
3094
3095
3096 A header describes the file's contents.  It can also appear in a
3097 @code{\score} block.  Tools like @code{ly2dvi} can use this
3098 information for generating titles.  Key values that are used by
3099 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3100 metre, arranger, piece and tagline.
3101
3102 It is customary to put the @code{\header} at the top of the file.
3103
3104 @subsubsection Default output
3105
3106 A @code{\midi} or @code{\paper} block at top-level sets the default
3107
3108 paper block for all scores that lack an explicit paper block.
3109
3110 @c.  {Identifiers}
3111 @node Identifiers
3112 @subsection Identifiers
3113 @cindex  Identifiers
3114
3115 All of the information in a LilyPond input file, is represented as a
3116 Scheme value. In addition to normal Scheme data types (such as pair,
3117 number, boolean, etc.), LilyPond has a number of specialized data types,
3118
3119 @itemize @bullet
3120 @item Input
3121 @item c++-function
3122 @item Music: see @ref{Music expressions}
3123 @item Identifier
3124 @item Translator_def:
3125 See section @ref{contextdefs} for more information
3126 @item Duration
3127 @item Pitch
3128 @item Score
3129 @item Music_output_def
3130 @item Moment (rational number)
3131 @end itemize
3132
3133 LilyPond also includes some transient object types. Objects of these
3134 types are built during a LilyPond run, and do not `exist' per se within
3135 your input file. These objects are created as a result of your input
3136 file, so you can include commands in the input to manipulate them,
3137 during a lilypond run.
3138
3139 @itemize @bullet
3140 @item Grob: short for Graphical object. See @ref{Grobs}. 
3141 @item Molecule: device-independent page output object,
3142 including dimensions.  Produced by some Grob functions
3143 See @ref{Molecules}
3144 @item Translator: object that produces audio objects or Grobs. This is
3145 not yet user accessible.
3146 @item Font_metric: object representing a font. (See @ref{Font metrics})
3147
3148 @end itemize
3149
3150
3151 @c.   {Assignments}
3152 @node Assignments
3153 @subsection Assignments
3154 @cindex Assignments
3155
3156 Identifiers allow objects to be assigned to names during the parse
3157 stage.  To assign an identifier, you use @var{name}@code{=}@var{value}
3158 and to refer to an identifier, you preceed its name with a backslash:
3159 `@code{\}@var{name}'.  @var{value} is any valid Scheme value or any of
3160 the input-types listed above.  Identifier assignments can appear at top
3161 level in the LilyPond file, but also in @code{\paper} blocks.
3162
3163 Semicolons are forbidden after top level assignments, but mandatory in
3164 other places. The rules about semicolons and assignments are very
3165 confusing, but when LilyPond input evolves more towards Scheme, we hope
3166 that this problem will grow smaller.
3167
3168 An identifier can be created with any string for its name, but you will
3169 only be able to refer to identifiers whose names begin with a letter,
3170 being entirely alphanumeric.  It is impossible to refer to an identifier
3171 whose name is the same as the name of a keyword.
3172
3173 The right hand side of an identifier assignment is parsed completely
3174 before the assignment is done, so it is allowed to redefine an
3175 identifier in terms of its old value, e.g.
3176
3177 @example
3178 foo = \foo * 2.0
3179 @end example
3180
3181 When an identifier is referenced, the information it points to is
3182 copied.  For this reason, an identifier reference must always be the
3183 first item in a block.
3184 @example
3185 \paper  @{
3186 foo = 1.0
3187 \paperIdent % wrong and invalid
3188 @}
3189
3190 \paper @{
3191 \paperIdent % correct
3192 foo = 1.0
3193 @}
3194 @end example
3195
3196
3197
3198 @c.  {Lexical details}
3199 @node Lexical details
3200 @subsection Lexical details
3201 @cindex Lexical details
3202 @menu
3203 @end menu
3204
3205 @c.   {Comments}
3206 @subsubsection Comments
3207 @cindex Comments
3208
3209 @cindex @code{%}
3210
3211
3212 A one line comment is introduced by a @code{%} character. 
3213 Block comments are started by @code{%@{} and ended by `@code{%@}}'. 
3214 They cannot be nested.
3215
3216 @c.  {Direct Scheme}
3217 @subsubsection Direct Scheme
3218 @cindex Scheme
3219 @cindex GUILE
3220 @cindex Scheme, in-line code
3221
3222
3223 LilyPond contains a Scheme interpreter (the GUILE library) for
3224 internal use. In some places Scheme expressions also form valid syntax:
3225 whereever it is allowed,
3226 @example
3227   #@var{scheme}
3228 @end example
3229 evaluates the specified Scheme code. If this is used at toplevel, then
3230 the result is discarded. Example:
3231 @example
3232   \property Staff.TestObject \override #'foobar =  #(+ 1 2)
3233 @end example
3234
3235 @code{\override} expects two Scheme expressions, so there are two Scheme
3236 expressions. The first one is a symbol (@code{foobar}), the second one
3237 an integer (namely, 3).
3238
3239 Scheme is a full-blown programming language, and a full discussion is
3240 outside the scope of this document. Interested readers are referred to
3241 the website @uref{http://www.schemers.org/} for more information on
3242 Scheme.
3243
3244
3245 @c.   {Keywords}
3246 @subsubsection Keywords
3247 @cindex Keywords
3248
3249
3250 Keywords start with a backslash, followed by a number of lower case
3251 alphabetic characters.  These are all the keywords.
3252
3253 @example
3254 apply arpeggio autochange spanrequest commandspanrequest
3255 simultaneous sequential accepts alternative bar breathe
3256 char chordmodifiers chords clef cm consists consistsend
3257 context denies duration dynamicscript elementdescriptions
3258 font grace header in lyrics key mark pitch
3259 time times midi mm name pitchnames notes outputproperty
3260 override set revert partial paper penalty property pt
3261 relative remove repeat addlyrics partcombine score
3262 script stylesheet skip textscript tempo translator
3263 transpose type
3264 @end example
3265
3266 @c.   {Integers}
3267 @subsubsection Integers
3268
3269 @cindex integers
3270 @cindex @code{+}
3271 @cindex @code{-}
3272 @cindex @code{*}
3273 @cindex @code{/}
3274
3275 Formed from an optional minus sign followed by digits.  Arithmetic
3276 operations cannot be done with integers, and integers cannot be mixed
3277 with reals.
3278
3279 @c.   {Reals}
3280 @subsubsection Reals
3281 @cindex real numbers
3282
3283
3284
3285
3286
3287 Formed from an optional minus sign and a sequence of digits followed
3288 by a @emph{required} decimal point and an optional exponent such as
3289 @code{-1.2e3}.  Reals can be built up using the usual operations:
3290 `@code{+}', `@code{-}', `@code{*}', and
3291 `@code{/}', with parentheses for grouping.
3292
3293 @cindex @code{\mm},
3294 @cindex @code{\in}
3295 @cindex @code{\cm}
3296 @cindex @code{\pt}
3297 @cindex dimensions
3298
3299 A real constant can be followed by one of the dimension keywords:
3300 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
3301 points, inches and centimeters, respectively.  This converts the number
3302 to a real that is the internal representation of dimensions.
3303
3304
3305 @c.   {Strings}
3306 @subsubsection Strings
3307 @cindex string
3308 @cindex concatenate
3309
3310 Begins and ends with the @code{"} character.  To include a @code{"}
3311 character in a string write @code{\"}.  Various other backslash
3312 sequences have special interpretations as in the C language.  A string
3313 that contains no spaces can be written without the quotes.  See
3314 @ref{Lexical modes} for details on unquoted strings; their interpretation varies
3315 depending on the situation.  Strings can be concatenated with the
3316 @code{+} operator.
3317
3318 The tokenizer accepts the following commands. They have no grammatical
3319 function, hence they can appear anywhere in the input.
3320
3321
3322 @c.   {Main input}
3323 @subsubsection Main input
3324 @cindex Main input
3325
3326 @cindex @code{\maininput}
3327
3328 The @code{\maininput} command is used in init files to signal that the
3329 user file must be read. This command cannot be used in a user file.
3330
3331 @c.   {File inclusion}
3332 @subsubsection Main input
3333 @cindex Main input
3334
3335 @subsubsection File inclusion
3336 @cindex @code{\include}
3337 @example
3338   \include @var{filename}
3339 @end example
3340
3341 Include @var{filename}.  The argument @var{filename} may be a quoted string (an
3342 unquoted string will not work here!) or a string identifier.  The full
3343 filename including the @file{.ly} extension must be given,
3344
3345 @subsubsection Version information 
3346 @cindex @code{\version}
3347 @example
3348   \version @var{string} ;
3349 @end example
3350
3351 Specify the version of LilyPond that a file was written for.  The
3352 argument is a version string in quotes, for example @code{"1.2.0"}. 
3353 This is used to detect invalid input, and to aid
3354 @code{convert-ly}  a tool that automatically upgrades input files. See
3355 See @ref{convert-ly} for more information on @code{convert-ly}.
3356
3357 @cindex convert-ly
3358
3359
3360
3361
3362 @c.   {Pitch names}
3363 @subsubsection Pitch names
3364 @cindex Lexical modes
3365 @cindex pitch names
3366
3367 @cindex note names
3368 @cindex chord modifier names
3369
3370 Note names and chord modifiers can be customised for nationalities.
3371 languages and conventions.  The syntax is as follows.
3372 @cindex @code{\pitchnames}
3373 @cindex @code{\chordmodifiers}
3374
3375 @example
3376    \pitchnames @var{scheme-alist}
3377    \chordmodifiers @var{scheme-alist}
3378 @end example
3379
3380 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
3381 specific examples how to do this.  tables can be tailored specified
3382 using. Some national note names have been provided, see
3383 section @ref{Other languages}.
3384 A @code{\paper} block at top level sets the default paper block.  A
3385 @code{\midi} block at top level works similarly.
3386
3387 @c.   {Assignments}
3388 @subsubsection Assignments
3389 @cindex assignments
3390 @cindex @code{#}
3391
3392 Identifier assignments may appear at top level.  @ref{Assignments}
3393
3394
3395
3396 @c.    {Direct scheme}
3397 @subsubsection Direct scheme
3398 @cindex Direct scheme
3399
3400 Scheme statements maybe issued to produce interesting side-effects. 
3401
3402
3403 @c.  {Lexical modes}
3404 @node Lexical modes
3405 @subsection Lexical modes
3406 @cindex Lexical modes
3407
3408 @cindex Lexical modes
3409 @cindex modes
3410
3411 To simplify entering notes, lyrics, and chords, LilyPond has three
3412 special input modes on top of the default mode.  In each mode, words
3413 are identified on the input.  If @code{"word"} is encountered, it is
3414 treated as a string.  If @code{\word} is encountered, it is treated as
3415 a keyword or as an identifier.  The behavior of the modes differs in
3416 two ways: Different modes treat unquoted words differently, and
3417 different modes have different rules for deciding what is a word.
3418
3419 @table  @asis
3420 @item Normal mode.
3421 @cindex normal mode
3422  
3423 At the start of parsing, LilyPond is in Normal mode.  In Normal
3424 mode, a word is an alphabetic character followed by alphanumeric
3425 characters.  If @code{word} is encountered on the input it is
3426 treated as a string.
3427
3428 @item Note mode
3429 See @ref{Note entry}.
3430
3431 @item Lyrics mode
3432 See @ref{Lyrics entry}.
3433
3434 @item Chord mode
3435 See @ref{Chord entry}.
3436 @end table
3437
3438 @cindex input modes
3439
3440 @cindex mode switch
3441
3442 @cindex @code{\notes}
3443 @cindex @code{\chords}
3444 @cindex @code{\lyrics}
3445
3446 Mode switching keywords form compound music expressions: @code{\notes}
3447 @var{musicexpr}, @code{\chords}  @var{musicexpr},
3448 and @code{\lyrics}  @var{musicexpr}.  These
3449 expressions do not add anything to the meaning of their arguments.  They
3450 are just a way to indicate that the arguments should be parsed in
3451 indicated mode.  See @ref{Lexical modes} for more information on modes.
3452
3453 @c.  {Ambiguities}
3454 @node Ambiguities
3455 @subsection Ambiguities
3456 @cindex ambiguities
3457 @cindex grammar
3458
3459
3460 The grammar contains a number of ambiguities. We hope to resolve them at
3461 some time.
3462
3463 @itemize @bullet
3464   @item  The assignment
3465
3466          @example 
3467 foo = bar 
3468 @end example 
3469
3470        can be interpreted as making a string identifier @code{\foo}
3471        containing @code{"bar"}, or a music identifier @code{\foo}
3472        containing the syllable `bar'.
3473
3474   @item  The assignment
3475
3476          @example 
3477 foo = -6 
3478 @end example 
3479
3480        can be interpreted as making an integer identifier
3481        containing -6, or a Request identifier containing the
3482        fingering `6' (with neutral direction).
3483
3484   @item  If you do a nested repeat like
3485
3486        @quotation
3487
3488 @example 
3489 \repeat @dots{}
3490 \repeat @dots{}
3491 \alternative 
3492 @end example 
3493
3494        @end quotation
3495
3496        then it is ambiguous to which @code{\repeat} the
3497        @code{\alternative} belongs.  This is the classic if-then-else
3498        dilemma.  It may be solved by using braces.
3499
3500   @item  (an as yet unidentified ambiguity :-)
3501 @end itemize
3502
3503
3504
3505
3506
3507 @c. {Unsorted}
3508 @node Unsorted
3509 @section Unsorted
3510
3511 [mucho todo]
3512
3513 Translation?
3514
3515 @cindex properties
3516 @unnumberedsubsec Translation property
3517
3518 @cindex @code{\property}
3519 @example
3520   \property @var{contextname}.@var{propname} =  @var{value}
3521 @end example
3522
3523 Sets the @var{propname} property of the context @var{contextname} to
3524 the specified @var{value}.  All three arguments are strings. 
3525 Depending on the context, it may be necessary to quote the strings or
3526 to leave space on both sides of the dot.
3527
3528 @cindex translator switches
3529 @unnumberedsubsec Translator switches
3530
3531 @cindex @code{\translator}
3532 @example
3533   \translator @var{contexttype} = @var{name}
3534 @end example
3535
3536 A music expression indicating that the context which is a direct
3537 child of the a context of type @var{contexttype} should be shifted to
3538 a context of type @var{contexttype} and the specified name.
3539
3540 Usually this is used to switch staffs in Piano music, e.g.
3541
3542 @example
3543   \translator Staff = top @var{Music}
3544 @end example
3545
3546
3547 @cindex output properties
3548 @unnumberedsubsec Output properties
3549
3550 These allow you to tweak what is happening in the back-end
3551 directly. If you want to control every detail of the output
3552 formatting, this is the feature to use. The downside to this is that
3553 you need to know exactly how the backend works. Example:
3554
3555
3556 @lilypond[fragment,verbatim]
3557 \relative c'' { c4
3558         \context Staff \outputproperty
3559                 #(make-type-checker 'note-head-interface)
3560                 #'extra-offset = #'(5.0 . 7.5)
3561 <c8 e g> }
3562 @end lilypond
3563
3564 This selects all note heads occurring at current staff level, and sets
3565 the @code{extra-offset} of those heads to @code{(5,7.5)}, shifting them
3566 up and right.
3567
3568 Use of this feature is entirely on your own risk: if you use this, the
3569 result will depend very heavily on the implementation of the backend,
3570 which we change regularly and unscrupulously.
3571
3572
3573 @c.{Local emacs vars}
3574 @c Local variables:
3575 @c mode: texinfo
3576 @c minor-mode: font-lock
3577 @c minor-mode: outline
3578 @c outline-layout: (-1 : 0)
3579 @c outline-use-mode-specific-leader: "@c\."
3580 @c outline-primary-bullet: "{"
3581 @c outline-stylish-prefixes: nil
3582 @c outline-override-protect: t
3583 @c End:
3584