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