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