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