]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
patch::: 1.3.140.jcn6
[lilypond.git] / Documentation / user / refman.itely
1
2 @c Note:
3 @c
4 @c A menu is needed before every deeper *section nesting of @nodes
5 @c Run M-x texinfo-all-menus-update
6 @c to automagically fill in these menus
7 @c before saving changes
8
9
10 @macro refbugs
11 @unnumberedsubsec Bugs
12
13 @end macro
14
15
16 @c .{Reference Manual}
17
18 @node Reference Manual
19 @chapter Reference Manual
20
21 This document describes GNU LilyPond and its input format. The last
22 revision of this document was for LilyPond 1.3.141.
23
24
25 @menu
26 * Overview::                    
27 * Note entry::                  
28 * Staff notation::              
29 * Polyphony::                   
30 * Beaming::                     
31 * Expressive marks::            
32 * Ornaments::                   
33 * Repeats::                     
34 * Rhythmic music::              
35 * Piano music::                 
36 * Lyrics::                      
37 * Chords::                      
38 * Writing parts::               
39 * Custodes::                    
40 * Tuning output::               
41 * Page layout::                 
42 * Sound::                       
43 * Music entry::                 
44 * Using LilyPond::              
45 * Interpretation context::      
46 * Syntactic details::           
47 * Lexical details::             
48 @end menu
49
50 @c . {Overview}
51 @node Overview
52 @section Overview
53
54
55 The purpose of LilyPond is explained informally by the term `music
56 typesetter'.  This is not a fully correct name: not only does the
57 program print musical symbols, it also makes esthetic decisions.
58 Symbols and their placements are @emph{generated} from a high-level
59 musical description.  In other words, LilyPond would be best described
60 by `music compiler' or `music to notation compiler'.
61
62 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
63 Scheme library provides the glue that holds together the low-level
64 routines and separate modules general, which are C++.
65
66 When lilypond is run to typeset sheet music, the following happens:
67 @itemize @bullet
68 @item GUILE Initialization: various scheme files are read
69 @item parsing: first standard @code{ly} initialization  files are read, and
70 then the user @file{ly} file is read.
71 @item interpretation: the music in the file is processed ``in playing
72 order'', i.e. the order that  you  use to read sheet music, or the
73 order in which notes are played.
74
75 @item typesetting:
76 in this step, the results of the interpretation, a typesetting
77 specification, is solved.
78
79 @item the visible results ("virtual ink") is written to the output file.
80 @end itemize
81
82 During these stages different types of data play the the main role:
83 during parsing, @strong{Music} objects are created.  During the
84 interpretation, @strong{context} is constructed, and with this context
85 af network of @strong{graphical objects} (``grobs'') is created. The
86 grobs contain unknown variables, and the network forms a set of
87 equations. After solving the equations and filling in these variables,
88 the printed output (in the form of @strong{molecules}) is written to an
89 output file.
90
91 These threemanship of tasks (parsing, translating, typesetting) and
92 data-structures (music, context, graphical objects) permeates the entire
93 design of the program.  This manual is ordered in terms of user
94 tasks. With each concept will be explained to which of the three parts
95 it belongs.
96
97
98 @c . {Note entry}
99 @node Note entry
100 @section Note entry
101 @cindex Note entry
102
103 The most basic forms of music are notes. We discuss how you enter them
104 here.  Notes on their own don't form valid input, but for the sake of
105 brevity we omit obligotary lint such as @code{\score} blocks and
106 @code{\paper} declarations.
107
108
109 @menu
110 * Pitches::                     
111 * Defining pitch names::        
112 * Durations::                   
113 * Notes::                       
114 * Easy Notation note heads ::   
115 * Tie::                         
116 * Tuplets::                     
117 * Rests::                       
118 * Skip::                        
119 * Note mode::                   
120 @end menu
121
122 @c .  {Pitches}
123 @node Pitches
124 @subsection Pitches
125
126 @cindex Pitch names
127 @cindex Note specification
128 @cindex pitches
129 @cindex entering notes
130
131 The verbose syntax for pitch specification is
132
133 @cindex @code{\pitch}
134 @example
135   \pitch @var{scmpitch}
136 @end example
137
138 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
139
140 In Note and Chord mode, pitches may be designated by names.  The default
141 names are the Dutch note names.  The notes are specified by the letters
142 @code{a} through @code{g} (where the octave is formed by notes ranging
143 from @code{c}, to @code{b}).  The pitch @code{c} is an octave below
144 middle C and the letters span the octave above that C.
145
146 @cindex note names, Dutch
147
148 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
149 name.  A flat is formed by adding @code{-es}. Double sharps and double
150 flats are obtained by adding @code{-isis} or @code{-eses}.  @code{aes}
151 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
152 both forms are accepted.
153
154 LilyPond has predefined sets of notenames for various other languages.
155 To use them, simply include the language specific init file.  For
156 example: @code{\include "english.ly"}.  The available language files and
157 the names they define are:
158
159 @example 
160                         Note Names               sharp       flat
161 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
162 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
163 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
164 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
165 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
166 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
167 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b 
168 @end example 
169
170 @cindex @code{'}
171 @cindex @code{,}
172
173
174
175 The optional octave specification takes the form of a series of
176 single quote (`@code{'}') characters or a series of comma
177 (`@code{,}') characters.  Each @code{'} raises the pitch by one
178 octave; each @code{,} lowers the pitch by an octave.
179
180 @lilypond[fragment,verbatim,center]
181   c' c'' es' g' as' gisis' ais'  
182 @end lilypond
183
184 @c .  {Defining pitch names}
185 @node Defining pitch names
186 @subsection Defining pitch names
187
188 @cindex defining pitch names
189 @cindex pitch names, defining 
190
191 Note names and chord modifiers can be customised for nationalities.  The
192 syntax is as follows.
193
194 @cindex @code{\pitchnames}
195 @cindex @code{\chordmodifiers}
196 @example
197    \pitchnames @var{scheme-alist}
198    \chordmodifiers @var{scheme-alist}
199 @end example
200
201 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
202 specific examples how to do this.
203
204
205
206 @c .  {Durations}
207 @node Durations
208 @subsection Durations
209
210
211 @cindex duration
212 @cindex @code{\duration}
213
214 The syntax for a verbose duration specification is
215 @example
216  \duration @var{scmduration}
217 @end example
218 Here, @var{scmduration} is a Scheme object of type Duration. See
219 @ref{Duration} for more information.
220
221
222 In Note, Chord, and Lyrics mode, durations may be designated by numbers
223 and dots: durations are entered as their reciprocal values.  For notes
224 longer than a whole note, use identifiers.
225
226 @quotation
227
228 @example 
229 c'\longa c'\breve  
230 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 
231 r\longa r\breve  
232 r1 r2 r4 r8 r16 r32 r64 r64 
233 @end example 
234
235
236 @lilypond[]
237 \score {
238   \notes \relative c'' {
239     a\longa a\breve  \autoBeamOff
240     a1 a2 a4 a8 a16 a32 a64 a64 
241     r\longa r\breve  
242     r1 r2 r4 r8 r16 r32 r64 r64 
243   }
244   \paper {
245     \translator {
246       \StaffContext
247         \remove "Clef_engraver";
248         \remove "Staff_symbol_engraver";
249         \remove "Time_signature_engraver";
250         \consists "Pitch_squash_engraver";
251     }
252   }
253 }
254 @end lilypond
255 @end quotation
256
257 As you can see, the longa is not printed. To get a longa note head, you
258 have to use a mensural note heads. This is done accomplished by setting
259 the @code{style} property of the NoteHead grob to @code{mensural}.
260
261 If the duration is omitted then it is set to the previous duration
262 entered.  At the start of parsing a quarter note is assumed.  The
263 duration can be followed by a dot (`@code{.}')  to obtain dotted note
264 lengths.
265 @cindex @code{.}
266
267 @lilypond[fragment,verbatim,center]
268   a'4. b'4.. c'8.
269 @end lilypond
270 @cindex @code{r}
271 @cindex @code{s}
272
273 You can alter the length of duration by appending
274 `@code{*}@var{fraction}'.  This will not affect the appearance of the
275 notes or rests produced.
276
277 @c . {Notes}
278 @node Notes
279 @subsection Notes
280
281 A note specification has the form
282
283 @example
284   @var{pitch}[@var{octavespec}][!][?][@var{duration}]
285 @end example
286
287 LilyPond will determine what accidentals to typeset depending on the key
288 and context. The alteration refers to what note is heard, not to whether
289 an accidental is printed.  A reminder accidental
290 @cindex reminder accidental
291 @cindex @code{?}
292 can be forced by adding an exclamation mark @code{!} after the pitch.  A
293 cautionary accidental,
294 @cindex cautionary accidental
295 i.e., an accidental within parentheses can be obtained by adding the
296 question mark `@code{?}' after the pitch.
297
298 @lilypond[fragment,verbatim,center]
299   cis' d' e' cis'  c'? d' e' c'!
300 @end lilypond
301
302
303 @node Easy Notation note heads 
304 @subsection Easy Notation note heads
305
306 @cindex easy notation
307 @cindex Hal Leonard
308
309 A entirely different type of note head is the "easyplay" note head: a
310 note head that includes a note name.  It is used in some publications by
311 Hal-Leonard Inc.  music publishers.
312
313 @lilypond[singleline,verbatim]
314 \include "paper26.ly"
315 \score {
316         \notes { c'2 e'4 f' | g'1 }
317         \paper { \translator { \EasyNotation } } 
318 }
319 @end lilypond
320
321 Note that @code{EasyNotation} overrides a @code{Score} context.  You
322 probably will want to print it with magnification to make it better
323 readable.
324
325 @cindex Xdvi
326 @cindex ghostscript
327
328 If you view the result with Xdvi, then staff lines will show through the
329 letters.  Printing the postscript file obtained either by using dvips or
330 the @code{-f ps} option of lilypond will produce the desired result.
331
332
333 @node Tie
334 @subsection Tie
335
336 @cindex Tie
337 @cindex ties
338 @cindex @code{~}
339
340 A tie connects two adjacent note heads of the same pitch.  When used
341 with chords, it connects all of the note heads whose pitches match.
342 Ties are indicated using the tilde symbol `@code{~}'.
343 If you try to tie together chords which have no common pitches, a
344 warning message will appear and no ties will be created.
345
346 @lilypond[fragment,verbatim,center]
347   e' ~ e' <c' e' g'> ~ <c' e' g'>
348 @end lilypond
349
350 If you dislike the amount of ties created for a chord, you set
351 @code{Voice.sparseTies} to true, resulting in  a smaller number of
352 ties:
353 @lilypond[fragment,verbatim,center]
354   \property Voice.sparseTies = ##t
355   <c' e' g'> ~ <c' e' g'>
356 @end lilypond
357
358 In its meaning a tie is just a way of extending a note duration, similar
359 to the augmentation dot: the following example are three ways of notating
360 exactly the same concept.
361 @lilypond[fragment, singleline]
362 c'2 c'4 ~ c'4
363 @end lilypond
364
365 @refbugs
366
367 At present, the tie is implemented as a separate thing, temporally
368 located in between the notes. There is also no way to convert
369 between tied notes, dotted notes and plain notes.
370
371 Tieing only a subset of the note heads of a chord is not supported in a
372 simple way.  It can be achieved by moving the tie-engraver into Thread
373 context and turning off ties per Thread.
374
375
376 @node Tuplets
377 @subsection Tuplets
378
379 @cindex tuplets
380 @cindex triplets
381 @cindex @code{\times}
382
383 Tuplets are made out of a music expression by multiplying their duration
384 with a fraction.
385
386 @cindex @code{\times}
387 @example
388   \times @var{fraction} @var{musicexpr}
389 @end example
390
391 The duration of @var{musicexpr} will be multiplied by the fraction. 
392 In print, the fraction's denominator will be printed over the notes,
393 optionally with a bracket.  The most common tuplet is the triplet in
394 which 3 notes have the length of 2, so the notes are 2/3 of
395 their written length:
396
397 @lilypond[fragment,verbatim,center]
398   g'4 \times 2/3 {c'4 c' c'} d'4 d'4
399 @end lilypond
400
401 The property @code{tupletSpannerDuration} specifies how long brackets
402 should last.  With this, you can make lots of tuplets while typing
403 @code{\times} only once. This saves typing work when you must make lots
404 of tuplets.
405
406 @lilypond[fragment,  relative, singleline, verbatim]
407 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
408 \times 2/3 { c''8 c c c c c }
409 @end lilypond
410
411 @c .  {Rests}
412 @node  Rests
413 @subsection Rests
414 @cindex Rests
415
416 Rests are entered like notes, with note name `@code{r}'.
417
418
419 @c .  {Skip}
420 @node Skip
421 @subsection Skip
422 @cindex Skip
423
424
425 @example
426   \skip @var{duration} @code{;}
427   s@var{duration}
428 @end example
429 @cindex @code{\skip}
430
431 Skips the amount of time specified by @var{duration}.  If no other music
432 is played, a gap will be left for the skipped time with no notes
433 printed.  The shorthand is only available in Note and Chord mode.
434
435
436
437 @node Note mode
438 @subsection Note mode
439
440
441
442 @cindex note mode
443 @cindex @code{\notes}
444
445 Note mode is the lexical mode generally used for inputting notes. The
446 syntax is
447 @example
448 \notes @var{expr}
449 @end example
450
451 This instructs the tokenizer to interpret @var{expr} in note mode.  If a
452 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
453 checks if @code{foobar} is a pitch name.  If it is not a pitch name,
454 then it is treated as a string.
455
456 Numbers and dots indicate durations, so you can enter floating point
457 numbers in this mode.
458
459
460 @node Staff notation
461 @section Staff notation
462
463 @cindex Staff notation
464
465 @menu
466 * Key signature::               
467 * Clef::                        
468 * Time signature::              
469 * Unmetered music::             
470 * Bar lines::                   
471 @end menu
472
473 @c .  {Key}
474 @node Key signature
475 @subsection Key signature
476 @cindex Key
477
478 @cindex @code{\key}
479
480 Changing the key signature is done with the @code{\key} command.
481 @example
482   @code{\key} @var{pitch} @var{type} @code{;}
483 @end example
484
485 @cindex @code{\minor}
486 @cindex @code{\major}
487 @cindex @code{\minor}
488 @cindex @code{\ionian}
489 @cindex @code{\locrian}
490 @cindex @code{\aeolian}
491 @cindex @code{\mixolydian}
492 @cindex @code{\lydian}
493 @cindex @code{\phrygian}
494 @cindex @code{\dorian}
495
496 Here, @var{type} should be @code{\major} or @code{\minor} to get
497 @var{pitch}-major or @var{pitch}-minor, respectively.  The second
498 argument is optional; the default is major keys.  The @var{\context}
499 argument can also be given as an integer, which tells the number of
500 semitones that should be added to the pitch given in the subsequent
501 @code{\key} commands to get the corresponding major key, e.g.,
502 @code{\minor} is defined as 3.  The standard mode names @code{\ionian},
503 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
504 @code{\phrygian}, and @code{\dorian} are also defined.
505
506 This command sets context property @code{Staff.keySignature}.
507
508 @cindex @code{keySignature}
509
510 @c .  {Clef}
511 @node Clef
512 @subsection Clef
513 @cindex @code{\clef}
514 @example
515   \clef @var{clefname} @code{;}
516 @end example
517
518 Shortcut for
519
520 @example
521   \property Staff.clefGlyph = @var{glyph associated with clefname} 
522   \property Staff.clefPosition = @var{clef Y-position for clefname}
523   \property Staff.clefOctavation = @var{extra pitch of clefname}
524 @end example
525
526 Supported clef-names include 
527
528 @itemize @bullet
529 @item treble, violin, G, G2: G clef on 2nd line
530 @item french: G clef on 1st line
531 @item soprano: C clef on 1st line
532 @item mezzosoprano: C clef on 2nd line
533 @item alto: C clef on 3rd line
534 @item tenor: C clef on 4th line
535 @item baritone: C clef on 5th line
536 @item varbaritone: F clef on 3rd line
537 @item bass, F: F clef on 4th line
538 @item subbass: F clef on 5th line
539 @item percussion: percussion clef
540 @end itemize
541
542 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
543
544 @itemize @bullet
545 @item clefs-C: modern style C clef
546 @item clefs-F: modern style F clef
547 @item clefs-G: modern style G clef
548 @item clefs-vaticana_do: Editio Vaticana style do clef
549 @item clefs-vaticana_fa: Editio Vaticana style fa clef
550 @item clefs-medicaea_do: Editio Medicaea style do clef
551 @item clefs-medicaea_fa: Editio Medicaea style fa clef
552 @item clefs-mensural1_c: modern style mensural C clef
553 @item clefs-mensural2_c: historic style small mensural C clef
554 @item clefs-mensural3_c: historic style big mensural C clef
555 @item clefs-mensural1_f: historic style traditional mensural F clef
556 @item clefs-mensural2_f: historic style new mensural F clef
557 @item clefs-mensural_g: historic style mensural G clef
558 @item clefs-hufnagel_do: historic style hufnagel do clef
559 @item clefs-hufnagel_fa: historic style hufnagel fa clef
560 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
561 @item clefs-percussion: modern style percussion clef
562 @end itemize
563
564 @emph{Modern style} means ``as is typeset in current editions.''
565 @emph{Historic style} means ``as was typeset or written in contemporary
566 historic editions''.  @emph{Editio XXX style} means ``as is/was printed in
567 Editio XXX.''
568
569 @cindex Vaticana, Editio
570 @cindex Medicaea, Editio
571 @cindex hufnagel clefs
572
573
574 @c .  {Time signature}
575 @node Time signature
576 @subsection Time signature
577 @cindex Time signature
578 @cindex meter
579 @cindex @code{\time}
580
581 The time signature is changed by the @code{\time} command. Syntax:
582 @example
583   \time @var{numerator}@code{/}@var{denominator} @code{;}
584 @end example
585 Internally, this is a shortcut for doing
586 @example
587      \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
588 @end example
589
590 [TODO: discuss options for layout]
591
592 @c .   {Partial}
593 @subsection Partial
594 @cindex Partial
595 @cindex anacrusis
596 @cindex upstep
597 @cindex partial measure
598 @cindex measure, partial
599 @cindex shorten measures
600 @cindex @code{\partial}
601
602 Partial measures are entered using the @code{\partial} command:
603 @example
604   \partial @var{duration} @code{;}
605 @end example
606
607 Internally,  this is a shortcut for 
608
609 @example
610   \property Score.measurePosition = -@var{length of duration}
611 @end example
612 @cindex @code{|}
613
614
615 @node Unmetered music
616 @subsection Unmetered music
617
618 Bar lines and bar numbers are calculated automatically. For unmetered
619 music (e.g. cadenzas), this is not desirable. The property
620 @code{Score.timing} can be used to switch off this automatic timing
621
622 @lilypond[fragment,relative,singleline,verbatim]
623 c'2.
624 \property Score.timing = ##f
625 c4 c4 c4  
626 \property Score.timing = ##t
627 c4 c4 c4 
628 @end lilypond
629
630 The identifiers @code{\cadenzaOn} and @code{\cadenzaOff} can be used to
631 achieve the same effect.
632
633
634
635 @c .   {Bar lines}
636 @node Bar lines
637 @subsection Bar lines
638 @cindex Bar lines
639
640 @cindex @code{\bar}
641 @cindex measure lines
642 @cindex repeat bars
643
644 @example
645   \bar @var{bartype};
646 @end example
647
648 This is a shortcut for doing
649 @example
650   \property Score.whichBar = @var{bartype} 
651 @end example
652
653 You are encouraged to use @code{\repeat} for repetitions.  See
654 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
655 documentation.
656
657
658 @cindex Bar_line_engraver
659 @cindex whichBar
660 @cindex repeatCommands
661 @cindex defaultBarType
662
663 Bar lines are created by the @code{Bar_line_engraver}. That engraver examines
664 @code{whichBar} at every moment. Whenever it is set to a string, it will
665 create a bar with that type.  @code{whichBar} is usually set
666 automatically: at the start of a measure it is set to
667 @code{defaultBarType}. The contents of @code{repeatCommands} is used to
668 override default measure bars. 
669
670 @code{whichBar} can also be set directly, using @code{\property} or
671 @code{\bar ; }.  These settings take precedence over automatic @code{whichBar}
672 settings. 
673
674
675 @c .   {Polyphony}
676 @node Polyphony
677 @section Polyphony
678 @cindex Polyphony
679
680 [TODO: collisions, rest-collisinos, voiceX identifiers, how to
681 which  contexts to instantiate.  some small examples? ]
682
683
684 @table @code
685 @cindex @code{\shiftOff}  
686   @item @code{\shiftOff}
687     Disable horizontal shifting of note heads that collide. 
688
689 @cindex @code{\shiftOn}  
690   @item @code{\shiftOn}
691     Enable note heads that collide with other note heads to be
692     shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
693 set different shift values.
694
695 @cindex @code{\stemBoth} 
696   @item @code{\stemBoth}
697     Allow stems and beams to point either upwards or
698     downwards, decided automatically by LilyPond.
699
700 @cindex @code{\stemDown}  
701   @item @code{\stemDown}
702     Force stems and beams to point down.
703
704 @cindex @code{\stemUp}  
705   @item @code{\stemUp}
706     Force stems and beams to point up.
707 @end table
708
709 @cindex @code{\slurBoth}
710 @cindex @code{\slurDown} 
711 @cindex @code{\slurUp}
712 Similarly, for slurs use
713 @code{\slurBoth}, 
714 @code{\slurDown}, 
715 @code{\slurUp}.
716
717 @cindex @code{\tieBoth}
718 @cindex @code{\tieDown} 
719 @cindex @code{\tieUp}
720 For ties use
721 @code{\tieBoth}, 
722 @code{\tieDown}, 
723 @code{\tieUp}.
724
725 @cindex @code{\dynacmicBoth}
726 @cindex @code{\dynamicDown} 
727 @cindex @code{\dynamicUp}
728 For dynamics use
729 @code{\dynamicBoth}, 
730 @code{\dynamicDown}, 
731 @code{\dynamicUp}.
732
733 @c text scripts? articulation scripts? fingering?
734
735 @cindex @code{\voiceOne}
736 @cindex @code{\voiceTwo}
737 @cindex @code{\voiceThree}
738 @cindex @code{\voiceFour}
739 @cindex @code{\oneVoice}
740 @cindex @code{\shiftOn}
741 @cindex @code{\shiftOff}
742
743 If two voices sharing one staff have the same stem directions, their
744 note heads may collide.  You can shift the note heads of one voice by
745 setting @code{\shiftOn}.  This can be undone by setting
746 @code{\shiftOff}.
747
748 For simple polyphonic music, shorthands are available that combine
749 directions and shift settings: @code{\voiceOne}, @code{\voiceTwo},
750 @code{\voiceThree}, @code{\voiceFour} and @code{\oneVoice}.
751
752
753 @node Beaming
754 @section Beaming
755
756 Beams are used to group short notes into chunks that are aligned with
757 the metrum.  LilyPond guesses where beams should be inserted, but if
758 you're not satisfied with the automatic beaming, you can either instruct
759 lilypond which patterns to beam automatically. In specific cases, you
760 can also specify explicitly what to beam and what not.
761
762
763 @c .    {Automatic beams}
764 @subsection Automatic beams
765
766 @cindex @code{Voice.autoBeamSettings}
767 @cindex @code{(end * * * *)}
768 @cindex @code{(begin * * * *)}
769
770 A large number of Voice properties are used to decide how to generate
771 beams.  Their default values appear in @file{scm/auto-beam.scm}.
772
773 By default, automatic beams can start on any note@footnote{In exotic
774 time signatures such as 1/8 and 1/16 this is not true} but can only end
775 in a few positions within the measure: they can end on a beat, or at
776 durations specified by the properties in
777 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
778 are defined in @file{scm/auto-beam.scm}.
779
780 The syntax for  changing the value @code{autoBeamSettings} is set using
781 @code{\override} and unset using @code{\revert}:
782 @example
783 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
784 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
785 @end example
786 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
787 whether the rule applies to begin or end-points.  The quantity
788 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
789 designate all time signatures), @var{P}/@var{Q} refers to the length of
790 the beamed notes (@code{* *} designate notes of any length).
791
792 If you want automatic beams to end on every  quarter note, you can
793 use the following:
794 @example
795 \property Voice.autoBeamSettings \override
796     #'(end * * * *) = #(make-moment 1 4)
797 @end example
798 The duration a quarter note is 1/4 of a whole note. It is entered as
799 @code{(make-moment 1 4)}. 
800
801 The same syntax can be used to specify beam starting points. In this
802 example, you automatic beams can only end on a dotted quarter note. 
803 @example
804 \property Voice.autoBeamSettings \override
805     #'(begin * * * *) = #(make-moment 3 8)
806 @end example
807 In 4/4 time signature, this means that automatic beams could end only on
808 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
809 3/8 has passed within the measure).
810
811 You can also restrict rules to specific time signatures. A rule that
812 should only be applied in @var{N}/@var{M} time signature is formed by
813 replacing the first asterisks by @var{N} and @var{M}. For example, a
814 rule for 6/8 time exclusively looks like
815 @example
816 \property Voice.autoBeamSettings \override
817     #'(begin 6 8 * *) =  ... 
818 @end example
819
820 If you want a rule to apply to certain types of beams, you can use the
821 second pair of asterisks. Beams are classified according to the shortest
822 note they contain. For a beam ending rule that only applies to beams
823 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
824 32)}.
825
826 [say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8] 
827
828 Automatic beams can not be put on the last note in a score.
829
830 @cindex automatic beam generation
831 @cindex autobeam
832 @cindex @code{Voice.noAutoBeaming}
833
834 Automatic beaming is on by default, but it can switched off by setting
835 @code{Voice.noAutoBeaming} to true.  You you may find this necessary for
836 a melody that goes with lyrics.
837
838 @refbugs
839
840 It is not possible to specify beaming for beams with mixed durations,
841 that differs from the beaming of all separate durations, ie, you'll
842 have to specify manual beams to get:
843 @lilypond[fragment,singleline,relative]
844   \property Voice.autoBeamSettings
845     \override #'(end * * * *) = #(make-moment 3 8)
846   \time 12/8; c'8 c c  c16 c c c c c  [c c c c] c8 c  c4
847 @end lilypond
848
849
850 @c .    {Manual beams}
851 @cindex Automatic beams
852 @subsection Manual beams
853 @cindex beams, manual
854 @cindex @code{]}
855 @cindex @code{[}
856
857 In some cases it may be necessary to override LilyPond's automatic
858 beaming algorithm.  For example, the auto beamer will not beam over
859 rests or bar lines, so if you want that, specify the begin and end point
860 manually using @code{[} and @code{]}:
861
862 @lilypond[fragment,relative,verbatim]
863   \context Staff {
864     r4 [r8 g'' a r8] r8 [g | a] r8
865   }
866 @end lilypond
867 Whenever an manual beam is busy, the auto beam will not produce
868 anything.
869
870 @cindex @code{stemLeftBeamCount}
871
872 If you have specific wishes for the number of beams, you can fully
873 control the number of beams through the properties
874 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
875
876 @lilypond[fragment,relative,verbatim]
877   \context Staff {
878     [f'8 r16 f g a]
879     [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
880   }
881 @end lilypond
882 @cindex @code{stemRightBeamCount}
883
884 The beam symbol can be tweaked through @code{Voice.Beam}'s
885 grob-properties @code{height} and @code{staff-position},
886 in staff-spaces.
887
888 Set @code{height} to zero, to get horizontal beams:
889
890 @lilypond[fragment,relative,verbatim]
891   \property Voice.Beam \set #'direction = #1
892   \property Voice.Beam \set #'height = #0
893   [a''8 e' d c]
894 @end lilypond
895
896 Here's how you'd specify a weird looking beam that instead of being
897 horizontal, falls two staff spaces:
898
899 @lilypond[fragment,relative,verbatim]
900   \property Voice.Beam \set #'staff-position = #2
901   \property Voice.Beam \set #'height = #-2
902   [c'8 c] 
903 @end lilypond
904 @cindex @code{default-neutral-direction}
905
906 @node Expressive marks
907 @section Expressive marks
908
909 @c .   {Slur}
910 @menu
911 * Slur ::                       
912 * Phrasing slur::               
913 * Breath marks::                
914 * Tempo::                       
915 * Text spanner::                
916 @end menu
917
918 @node Slur 
919 @subsection Slur
920 @cindex slur
921
922 A slur indicates that notes are to be played bound or @emph{legato}.  In
923 lilypond, they are entered using parentheses:
924 @lilypond[fragment,verbatim,center]
925   f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
926 @end lilypond
927
928
929 Slurs avoid crossing stems, and are attached to note heads whenever
930 possible.  In some instances involving beams slurs may be attached to a
931 stem end.  If you want to override this layout you can do this through
932 @code{Voice.Slur}'s grob-property @code{attachment}:
933
934 Maybe reinclude other slur features and move back to tricks?  Esp. the
935 second example, how to fix, can be very helpful.
936
937 @lilypond[fragment,relative,verbatim]
938   \property Voice.Slur \set #'direction = #1
939   \property Voice.Stem \set #'length = #5.5
940   g''8(g)g4
941   \property Voice.Slur \set #'attachment = #'(stem . stem)
942   g8(g)g4
943 @end lilypond
944
945 If a slur would strike through a stem or beam, the slur will be moved
946 away upward or downward. If this happens, attaching the slur to the
947 stems might look better:
948
949 @lilypond[fragment,relative,verbatim]
950   \property Voice.Stem \set #'direction = #1
951   \property Voice.Slur \set #'direction = #1
952   d'32( d'4 )d8..
953   \property Voice.Slur \set #'attachment = #'(stem . stem)
954   d,32( d'4 )d8..
955 @end lilypond
956
957
958 Similarly, the curvature of a slur is adjusted to stay clear of note
959 heads and stems.  When that would increase the curvature too much, the
960 slur is reverted to its default shape.  The threshold for this decision
961 is in @code{Voice.Slur}'s grob-property @code{beautiful}.  It is loosely
962 related to the enclosed area between the slur and the notes.  Usually,
963 the default setting works well, but in some cases you may prefer a
964 curved slur when LilyPond decides for a vertically moved one.  You can
965 express this by increasing the @code{beautiful} value:
966
967 @lilypond[verbatim,singleline,relative]
968   \property Voice.Beam \override #'direction = #-1
969   \property Voice.Slur \override #'direction = #1
970   c'16( a' f' a a f a, )c,
971   c( a' f' a a f d, )c
972   \property Voice.Slur \override #'beautiful = #5.0
973   c( a' f' a a f d, )c
974 @end lilypond
975
976 @refbugs
977
978 The definition for @code{beautiful} is vague, the default setting is
979 experimental computer science.
980
981 @cindex Adusting slurs
982
983 @node Phrasing slur
984 @subsection Phrasing slur
985
986 @cindex phrasing slur
987 @cindex phrasing mark
988
989 A phrasing slur (or phrasing mark) connects chords and is used to
990 indicate a musical sentence. It is entered using @code{\(} and
991 @code{\)}.
992
993 @lilypond[fragment,verbatim,center,relative]
994   \time 6/4; c''\((d)e f(e)\)d
995 @end lilypond
996
997 Typographically, the phrasing slur behaves almost exactly like a normal
998 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
999
1000 @node Breath marks
1001 @subsection Breath marks
1002
1003 Breath marks are entered using @code{\breathe}:
1004
1005 @lilypond[fragment,relative]
1006 c'4 \breathe d4
1007 @end lilypond
1008
1009 Currently, only tick marks are supported, comma style breath marks are
1010 not. The grob for this object is called @code{Voice.BreathingSign}.
1011
1012
1013 @refbugs
1014
1015   Currently, only tick marks are supported, comma style breath marks are
1016 not.
1017
1018
1019 @c .  {Tempo}
1020 @node Tempo
1021 @subsection Tempo
1022 @cindex Tempo
1023 @cindex beats per minute
1024 @cindex metronome marking
1025
1026 @cindex @code{\tempo}
1027 @example
1028   \tempo @var{duration} = @var{perminute} @code{;}
1029 @end example
1030
1031 Used to specify the tempo.  For example, @code{\tempo 4 = 76;} requests
1032 output with 76 quarter notes per minute.
1033   
1034 @refbugs
1035   
1036 The tempo setting is not printed, but is currently only used in the MIDI
1037 output.
1038   
1039
1040
1041 @node Text spanner
1042 @subsection Text spanner
1043 @cindex Text spanner
1044
1045 Some textual indications, e.g. rallentando, accelerando, often extend
1046 over a many measures. This is indicated by following the text with a
1047 dotted line.   You can create such texts in LilyPond using 
1048 text spanners. The syntax is as follows: 
1049 @example
1050 \spanrequest \start "text"
1051 \spanrequest \stop "text"
1052 @end example
1053 LilyPond will respond by creating a @code{Voice.TextSpanner} grob.  The
1054 string to be printed, as well as the style is set through grob
1055 properties.
1056
1057 An application---or rather, a hack---is to fake octavation indications.
1058 @lilypond[fragment,relative,verbatim]
1059  \relative c' {  a'''' b c a
1060   \property Voice.TextSpanner \set #'type = #'dotted-line
1061   \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1062   \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1063   \property Staff.centralCPosition = #-13
1064   a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1065 @end lilypond
1066
1067
1068 @c .  {Ornaments}
1069 @node Ornaments
1070 @section Ornaments
1071 @cindex Ornaments
1072 @menu
1073 * Articulation::                
1074 * Text scripts::                
1075 * Grace notes::                 
1076 * Glissando ::                  
1077 * Dynamics::                    
1078 @end menu
1079
1080 @c .   {Articulation}
1081 @node Articulation
1082 @subsection Articulation
1083 @cindex Articulation
1084
1085 @cindex articulations
1086 @cindex scripts
1087 @cindex ornaments
1088
1089 A variety of symbols can appear above and below notes to indicate
1090 different characteristics of the performance.  These symbols can be
1091 added to a note with `@var{note}@code{-\}@var{name}'.  Numerous symbols
1092 are defined in @file{script.ly} and @file{script.scm}.  Symbols can be
1093 forced to appear above or below the note by writing
1094 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1095 respectively.  Here is a chart showing symbols above notes, with the
1096 name of the corresponding symbol appearing underneath.
1097
1098 @lilypond[]
1099   \score {
1100     < \notes {
1101         \property Score.LyricSyllable \override #'font-family =
1102 #'typewriter
1103         \property Score.LyricSyllable \override #'font-shape = #'upright
1104         c''-\accent      c''-\marcato      c''-\staccatissimo c''-\fermata 
1105         c''-\stopped     c''-\staccato     c''-\tenuto        c''-\upbow
1106         c''-\downbow     c''^\lheel        c''-\rheel         c''^\ltoe
1107         c''-\rtoe        c''-\turn         c''-\open          c''-\flageolet
1108         c''-\reverseturn c''-\trill        c''-\prall         c''-\mordent
1109         c''-\prallprall  c''-\prallmordent c''-\upprall       c''-\downprall
1110         c''-\thumb       c''-\segno        c''-\coda
1111       }
1112       \context Lyrics \lyrics {
1113         accent__      marcato__      staccatissimo__ fermata
1114         stopped__     staccato__     tenuto__        upbow
1115         downbow__     lheel__        rheel__         ltoe
1116         rtoe__        turn__         open__          flageolet
1117         reverseturn__ trill__        prall__         mordent
1118         prallprall__  prallmordent__ uprall__        downprall
1119         thumb__       segno__        coda
1120       }
1121     >
1122     \paper {
1123       linewidth = 5.875\in;          
1124       indent    = 0.0;
1125     }
1126   }
1127 @end lilypond
1128
1129 To save typing work, some shorthands are available:
1130 @lilypond[singleline]
1131   \score {
1132     \notes \context Voice {
1133       \property Voice.TextScript \set #'font-family = #'typewriter
1134       \property Voice.TextScript \set #'font-shape = #'upright
1135       c''4-._"c-."      s4
1136       c''4--_"c-{}-"    s4
1137       c''4-+_"c-+"      s4
1138       c''4-|_"c-|"      s4
1139       c''4->_"c->"      s4
1140       c''4-^_"c-\\^{ }" s4
1141     }
1142   }
1143 @end lilypond
1144
1145 @cindex fingering
1146
1147 Fingering instructions can also be entered in  this shorthand.
1148 @lilypond[verbatim, singleline, fragment]
1149       c'4-1 c'4-2 c'4-3 c'4-4
1150 @end lilypond
1151
1152
1153 @cindex @code{\script}
1154 @cindex scripts
1155 @cindex superscript
1156 @cindex subscript
1157
1158 @example
1159   \script @var{alias}
1160 @end example
1161
1162 Defines a script printing request.  The argument is a string which
1163 points into the script-alias table defined in @file{scm/script.scm}.
1164 Usually the @code{\script} keyword is not used directly.  Various
1165 helpful identifier definitions appear in @file{script.ly}.
1166
1167 For information on how to add scripts, consult @file{scm/script.scm}.
1168
1169
1170 @refbugs
1171
1172 All of these note ornaments appear in the printed output but have no
1173 effect on the MIDI rendering of the music.
1174
1175 Unfortunately, there is no support adding fingering instructions or
1176 ornaments to individual note heads. Some hacks exist, though. See
1177 @file{input/test/script-horizontal.ly}.
1178
1179
1180 @c .  {Text scripts}
1181 @node Text scripts
1182 @subsection Text scripts
1183 @cindex Text scripts
1184
1185 In addition, it is possible to place arbitrary strings of text or markup
1186 text (see @ref{Text markup}) above or below notes by using a string:
1187 @code{c^"text"}.  The text is typeset in italic by default.
1188
1189 The amount of space taken by these indications by default does not
1190 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1191 take the widths into account.  The identifier @code{\fattext} is defined
1192 in the standard  includes.
1193 @lilypond[fragment,singleline,verbatim]
1194 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1195 @end lilypond
1196
1197 Text scripts are created in form of @code{Voice.TextScript} grobs.
1198
1199 For purposes of defining identifiers, a more verbose form also exists:
1200
1201 @example
1202   \textscript @var{text} 
1203 @end example
1204
1205 Defines a text to be printed over or under a note.  @var{text} is a
1206 string or  a markup text.
1207 @quotation
1208
1209 @example 
1210 foo = \textscript #'(finger "6")
1211   [..]
1212 c4-\foo
1213 @end example 
1214
1215 @end quotation
1216
1217 This is equivalent to @code{c4-6 c4-"foo"}.  
1218
1219
1220 @c .   {Grace notes}
1221 @node Grace notes
1222 @subsection Grace notes
1223
1224
1225
1226
1227
1228
1229
1230 @cindex Grace music
1231 @cindex @code{\grace}
1232 @cindex ornaments
1233 @cindex grace notes
1234 @cindex @code{graceAlignPosition}
1235
1236 Grace notes are ornaments that are written out, but do not take up  any
1237 logical time in a measure. LilyPond has limited support for grace notes.
1238 The syntax is as follows. 
1239 @example
1240   \grace @var{musicexpr}
1241 @end example
1242
1243 When grace music is interpreted, a score-within-a-score is set up:
1244 @var{musicexpr} has its own time bookkeeping, and you could (for
1245 example) have a separate time signature within grace notes.  While in
1246 this score-within-a-score, you can create notes, beams, slurs, etc.
1247 Unbeamed eighth notes and shorter by default have a slash through the
1248 stem.  This behavior can be controlled with the
1249 @code{Stem}.@code{flag-style} property.
1250
1251 @lilypond[fragment,verbatim]
1252 \relative c'' {
1253   \grace c8 c4 \grace { [c16 c16] } c4
1254   \grace { \property Grace.Stem \override #'flag-style = #'() c16 } c4
1255 }
1256 @end lilypond
1257
1258
1259 At present, nesting @code{\grace} notes is not supported. The following
1260 may cause run-time errors:
1261 @example
1262   @code{\grace @{ \grace c32 c16 @} c4}
1263 @end example
1264 Since the meaning of such a construct is unclear, we don't consider this
1265 a loss.  Similarly, juxtaposing two @code{\grace} sections is
1266 syntactically valid, but makes no sense and may cause runtime errors.
1267 Ending a staff or score with grace notes may also generate a run-time
1268 error, since there will be no main note to attach the grace notes to.
1269
1270
1271 A grace note expression has duration 0; the next real note is assumed to
1272 be the main note. If you want the note to appear after the main note,
1273 set @code{Voice.graceAlignPosition} to @code{1}.
1274
1275 @refbugs
1276
1277 The present implementation of grace notes is not robust and generally
1278 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1279 also be implemented.
1280
1281
1282
1283 @menu
1284 * Glissando ::                  
1285 * Dynamics::                    
1286 @end menu
1287
1288
1289
1290 @c .   {Glissando}
1291 @node Glissando 
1292 @subsection Glissando
1293 @cindex Glissando 
1294
1295 @cindex @code{\glissando}
1296
1297 A glissando line can be requested by attaching a @code{\glissando} to a
1298 note:
1299
1300 @lilypond[fragment,relative,verbatim]
1301   c'' \glissando c'
1302 @end lilypond
1303
1304 @refbugs
1305
1306 Printing of an additional text (such as @emph{gliss.}) must be done
1307 manually.
1308
1309
1310
1311 @c .   {Dynamics}
1312 @node Dynamics
1313 @subsection Dynamics
1314 @cindex Dynamics
1315
1316
1317
1318 @cindex @code{\ppp}
1319 @cindex @code{\pp}
1320 @cindex @code{\p}
1321 @cindex @code{\mp}
1322 @cindex @code{\mf}
1323 @cindex @code{\f}
1324 @cindex @code{\ff}
1325 @cindex @code{\fff}
1326 @cindex @code{\ffff}
1327 @cindex @code{\fp}
1328 @cindex @code{\sf}
1329 @cindex @code{\sff}
1330 @cindex @code{\sp}
1331 @cindex @code{\spp}
1332 @cindex @code{\sfz}
1333 @cindex @code{\rfz}
1334
1335
1336 Absolute dynamic marks are specified by using an identifier after a
1337 note: @code{c4-\ff}.  The available dynamic marks are: @code{\ppp},
1338 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1339 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1340 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1341
1342 @lilypond[verbatim,singleline,fragment,relative]
1343   c''\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1344   c2\sf c\rfz
1345 @end lilypond
1346
1347 @cindex Crescendo and Decrescendo
1348 @cindex crescendo
1349 @cindex @code{\cr}
1350 @cindex @code{\rc}
1351 @cindex @code{\decr}
1352 @cindex @code{\rced}
1353 @cindex @code{\<}
1354 @cindex @code{\>}
1355 @cindex @code{\"!}
1356
1357
1358 A crescendo mark is started with @code{\cr} and terminated with
1359 @code{\rc} (the textual reverse of @code{cr}).  A decrescendo mark is
1360 started with @code{\decr} and terminated with @code{\rced}.  There are
1361 also shorthands for these marks.  A crescendo can be started with
1362 @code{\<} and a decrescendo can be started with @code{\>}.  Either one
1363 can be terminated with @code{\!}.  Note that @code{\!}  must go before
1364 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1365 after the last note.  Because these marks are bound to notes, if you
1366 want to get several marks during one note, you must use spacer notes.
1367
1368 @lilypond[fragment,verbatim,center]
1369   c'' \< \! c''   d'' \decr e'' \rced 
1370   < f''1 { s4 \< \! s2 \> \! s4 } >
1371 @end lilypond
1372
1373 [BUG in \> ! ]
1374
1375 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1376 is an example how to do it:
1377
1378 @lilypond[fragment,relative,verbatim]
1379   \context Voice {
1380     \property Voice.crescendoText = "cresc."
1381     \property Voice.crescendoSpanner = #'dashed-line
1382     a''2\mf\< a a \!a 
1383   }
1384 @end lilypond
1385
1386
1387
1388
1389
1390
1391 @c .  {Repeats}
1392 @node Repeats
1393 @section Repeats
1394
1395
1396 @cindex repeats
1397 @cindex @code{\repeat}
1398
1399 To specify repeats, use the @code{\repeat} keyword.  Since repeats
1400 should work differently when played or printed, there are a few
1401 different variants of repeats.
1402
1403 @table @asis
1404 @item unfolded  
1405 Repeated music is fully written (played) out.  Useful for MIDI
1406 output.
1407
1408 @item volta  
1409 This is the normal notation: Repeats are not written out, but
1410 alternative endings (voltas) are printed, left to right.
1411
1412 @item folded  
1413 Alternative endings are written stacked.  Which is unfortunately not
1414 practical for anything right now.
1415
1416 @item tremolo
1417 Make tremolo beams.
1418
1419 @item percent
1420 Make  measure repeats. These look like percent signs.
1421
1422 @end table  
1423
1424 @menu
1425 * Repeat syntax::               
1426 * Manual repeat commands::      
1427 * Tremolo repeats::             
1428 * Tremolo subdivision::         
1429 * Measure repeats::             
1430 @end menu
1431
1432 @node Repeat syntax
1433 @subsection Repeat syntax
1434
1435 The syntax for repeats is
1436
1437 @example
1438   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1439 @end example
1440
1441 If you have alternative endings, you may add
1442 @cindex @code{\alternative}
1443 @example
1444  \alternative @code{@{} @var{alternative1}
1445             @var{alternative2}
1446             @var{alternative3} @dots{} @code{@}}
1447 @end example
1448 where each @var{alternative} is a music expression.
1449
1450 Normal notation repeats are used like this:
1451 @lilypond[fragment,verbatim]
1452   c'1
1453   \repeat volta 2 { c'4 d' e' f' }
1454   \repeat volta 2 { f' e' d' c' }
1455 @end lilypond
1456
1457 With alternative endings:
1458 @lilypond[fragment,verbatim]
1459   c'1
1460   \repeat volta 2 {c'4 d' e' f'} 
1461   \alternative { {d'2 d'} {f' f} }
1462 @end lilypond
1463
1464 Folded repeats look like this:@footnote{Folded repeats offer little
1465 more over simultaneous music.  However, it is to be expected that
1466 more functionality -- especially for the MIDI backend -- will be
1467 implemented at some point in the future.}
1468
1469 @lilypond[fragment,verbatim]
1470   c'1
1471   \repeat fold 2 {c'4 d' e' f'} 
1472   \alternative { {d'2 d'} {f' f} }
1473
1474 @end lilypond
1475
1476 If you don't give enough alternatives for all of the repeats, then
1477 the first alternative is assumed to be repeated often enough to equal
1478 the specified number of repeats.
1479
1480 @lilypond[fragment,verbatim]
1481 \context Staff {
1482   \relative c' {
1483     \partial 4;
1484     \repeat volta 3 { e | c2 d2 | e2 f2 | }
1485     \alternative { { g4 g g } { a | a a a a | b2. } }
1486   }
1487 }
1488 @end lilypond
1489
1490 @refbugs
1491
1492 As you can see, LilyPond doesn't remember the timing information, nor
1493 are slurs or ties repeated, so you have to reset timing information
1494 after a repeat, e.g. using a bar-check (See @ref{Bar check}),
1495 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1496 after 1.4.
1497
1498 It is possible to nest @code{\repeat}, although it probably is only
1499 meaningful for unfolded repeats.
1500
1501 @node Manual repeat commands
1502 @subsection Manual repeat commands
1503
1504 @cindex @code{repeatCommands}
1505
1506 The property @code{repeatCommands} can be used to control the layout of
1507 repeats. Its value is a Scheme list of repeat commands, where each repeat
1508 command can be
1509
1510 @table @code
1511 @item 'start-repeat
1512  Print a |: bar line
1513 @item 'stop-repeat
1514  Print a :| bar line
1515 @item (volta . @var{text})
1516   Print a volta bracket saying @var{text}.
1517 @item (volta . #f)
1518   Stop a running volta bracket
1519 @end table
1520
1521 @lilypond[verbatim, fragment]
1522  c''4
1523     \property Score.repeatCommands = #'((volta "93") end-repeat)
1524  c4 c4
1525     \property Score.repeatCommands = #'((volta #f))
1526  c4 c4
1527 @end lilypond
1528
1529
1530 @node Tremolo repeats
1531 @subsection Tremolo repeats
1532 @cindex tremolo beams
1533
1534 To place tremolo marks between notes, use @code{\repeat} with tremolo
1535 style.  
1536 @lilypond[verbatim,center,singleline]
1537 \score { 
1538   \context Voice \notes\relative c' {
1539     \repeat "tremolo" 8 { c16 d16 }
1540     \repeat "tremolo" 4 { c16 d16 }    
1541     \repeat "tremolo" 2 { c16 d16 }
1542     \repeat "tremolo" 4 c16
1543   }
1544 }
1545 @end lilypond
1546
1547 @refbugs
1548
1549
1550 At present, the spacing between tremolo beams is not regular, since the
1551 spacing engine does not notice that not all notes are printed.
1552
1553 @node Tremolo subdivision
1554 @subsection Tremolo subdivision
1555 @cindex tremolo marks
1556 @cindex @code{tremoloFlags}
1557
1558 Tremolo marks can be printed on a single note by adding
1559 `@code{:}[@var{length}]' after the note.  The length must be at least 8.
1560 A @var{length} value of 8 gives one line across the note stem.  If the
1561 length is omitted, then then the last value (stored in
1562 @code{Voice.tremoloFlags}) is used.
1563
1564 @lilypond[verbatim,fragment,center]
1565   c'2:8 c':32
1566 @end lilypond
1567 Using this mechanism pays off when you entering many tremolos, since the
1568 default argument saves a lot of typing.
1569
1570 @refbugs
1571
1572
1573 Tremolos in this style do not carry over into the MIDI output.
1574
1575
1576 @node Measure repeats
1577 @subsection Measure repeats
1578
1579 @cindex percent repeats
1580 @cindex measure repeats
1581
1582 In the @code{percent} style, a note pattern can be repeated. It is
1583 printed once, and then the pattern is replaced with a special sign.
1584
1585 @lilypond[verbatim,singleline]
1586  \context Voice { \repeat  "percent" 5  { c'1 } }  
1587 @end lilypond
1588
1589 At present, only repeats of whole measures are supported.
1590
1591 @node Rhythmic music
1592 @section Rhythmic music
1593
1594
1595 @menu
1596 * Rhythmic staffs::             
1597 @end menu
1598
1599 @node Rhythmic staffs
1600 @subsection Rhythmic staffs
1601
1602 Some times you might want to show only the rhythm of a melody.  This can
1603 be done  with the rhythmic staff. All pitches of notes on such a staff
1604 are squashed, and the  staff itself  looks has  a single staff line:
1605
1606 @lilypond[fragment,relative ]
1607   \context RhythmicStaff {
1608       \time 4/4; 
1609       c4 e8 f  g2 | r4 g r2 | g1:32 | r1 |
1610   }
1611 @end lilypond
1612
1613
1614 @c . {Piano music}
1615 @node Piano music
1616 @section Piano music
1617
1618 Piano music is an odd type of notation: two staffs are largely
1619 independent, but sometimes voices can cross between the two staffs.  The
1620 @code{PianoStaff} is especially built to handle this cross-staffing
1621 behavior.  In this section we discuss the @code{PianoStaff} and some
1622 other pianistic peculiarities.
1623
1624 @menu
1625 * Automatic staff changes::     
1626 * Manual staff switches::       
1627 * Pedals::                      
1628 * Arpeggio::                    
1629 * VoiceFollower::               
1630 @end menu 
1631
1632
1633 @c .   {Automatic staff changes}
1634 @node Automatic staff changes
1635 @subsection Automatic staff changes
1636 @cindex Automatic staff changes
1637
1638 Voices can be switched from top to bottom staff automatically. The
1639 syntax for this is
1640 @example
1641         \autochange @var{contexttype} @var{musicexp}
1642 @end example
1643 This will switch notation context of @var{musicexp} between a
1644 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1645 @code{Staff} for @var{contexttype}.  The autochanger switches on basis
1646 of pitch (central C is the turning point), and it looks ahead skipping
1647 over rests to switch rests in advance.
1648         
1649 @lilypond[verbatim,singleline]
1650 \score { \notes \context PianoStaff <
1651   \context Staff = "up" {
1652     \autochange Staff \context Voice = VA < \relative c' {
1653        g4 a  b c d r4 a g } > }
1654   \context Staff = "down" {
1655        \clef bass; 
1656        s1*2
1657 } > }
1658 @end lilypond
1659
1660 Note how spacer rests are used to prevent the bottom staff from
1661 terminating too soon.
1662
1663
1664 @node Manual staff switches
1665 @subsection Manual staff switches
1666
1667 @cindex manual staff switches
1668 @cindex staff switch, manual
1669
1670 Voices can be switched between staffs manually, using the following command:
1671 @example
1672   \translator Staff = @var{which} @var{music}
1673 @end example
1674 The string @var{which} is the name of the staff. Typically it is
1675 @code{"up"} or @code{"down"}. 
1676
1677 Formally, this construct is a music expression indicating that the
1678 context which is a direct child of the a context of type
1679 @var{contexttype} should be shifted to a context of type
1680 @var{contexttype} and the specified name.
1681
1682 @cindex @code{\translator}
1683 @example
1684   \translator @var{contexttype} = @var{name}
1685 @end example
1686
1687
1688 @c .   {Pedals}
1689 @node Pedals
1690 @subsection Pedals
1691 @cindex Pedals
1692
1693 Piano pedal instruction can be expressed using 
1694 @code{\sustainDown}, @code{\sustainUp}, @code{\unaChorda},
1695 @code{\treChorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
1696
1697 These identifiers are shorthands for spanner commands of the types
1698 @code{Sustain}, @code{UnaChorda} and @code{Sostenuto}:
1699
1700 @lilypond[fragment,verbatim]
1701 c''4 \spanrequest \start "Sustain" c''4 c''4 \spanrequest \stop "Sustain"
1702 @end lilypond
1703
1704 The symbols that are printed can be modified by setting
1705 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1706 types. Refer to the generated documentation for more information.
1707
1708 @refbugs
1709
1710
1711 Currently, brackets are not supported, only text markings (ie. *Ped
1712 style).
1713
1714
1715 @c .   {Arpeggio}
1716 @node Arpeggio
1717 @subsection Arpeggio
1718 @cindex Arpeggio
1719
1720 @cindex broken arpeggio
1721 @cindex @code{\arpeggio}
1722
1723 You can specify an arpeggio sign on a chord by attaching an
1724 @code{\arpeggio} to a note of the chord.
1725
1726
1727 @lilypond[fragment,relative,verbatim]
1728   \context Voice <c'\arpeggio e g c>
1729 @end lilypond
1730
1731 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1732 to the chords in both staffs, and set
1733 @code{PianoStaff.connectArpeggios}.
1734
1735 @lilypond[fragment,relative,verbatim]
1736   \context PianoStaff <
1737     \property PianoStaff.connectArpeggios = ##t
1738     \context Voice = one  { <c''\arpeggio e g c> }
1739     \context Voice = other { \clef bass;  <c,,\arpeggio e g>}
1740   >  
1741 @end lilypond
1742
1743 This command creates @code{Arpeggio} grobs. 
1744
1745 @refbugs
1746
1747  It is not possible to mix
1748 connected arpeggios and unconnected arpeggios at the same time.
1749
1750
1751 @c .    {VoiceFollower}
1752 @node  VoiceFollower
1753 @subsection VoiceFollower
1754
1755 @cindex follow voice
1756 @cindex staff switching
1757 @cindex cross staff
1758
1759 @cindex @code{followVoice}
1760
1761 Whenever a voice switches to another staff a line connecting the notes
1762 can be printed automatically. This is enabled if the property
1763 @code{PianoStaff.followVoice} is set to true:
1764
1765 @lilypond[fragment,relative,verbatim]
1766   \context PianoStaff <
1767     \property PianoStaff.followVoice = ##t
1768     \context Staff \context Voice {
1769       c'1
1770       \translator Staff=two
1771       b2 a
1772     }
1773     \context Staff=two {\clef bass; \skip 1*2;}
1774   >  
1775 @end lilypond
1776
1777
1778 @c . {Lyrics}
1779 @node Lyrics
1780 @section Lyrics
1781
1782
1783 @menu
1784 * Lyrics mode::                 
1785 * Printing lyrics::             
1786 * Automatic syllable durations::  
1787 * More stanzas::                
1788 @end menu
1789
1790 @c .  {Lyrics mode}
1791 @node Lyrics mode
1792 @subsection Lyrics mode
1793 @cindex Lyrics mode
1794
1795 To print lyrics in LilyPond, you must first make a music expression from
1796 the lyric text. When they're in a music expression, that music
1797 expression can be printed by selecting an appropriate context.  We shall
1798 discuss lyric printing in this order.
1799
1800
1801 @cindex lyric mode
1802 @cindex @code{\lyrics}
1803
1804 You can enter lyrics in a special input mode of LilyPond. This mode is
1805 called Lyrics mode, and it is introduced by the keyword @code{\lyrics}.
1806 The purpose of this mode is that you can enter lyrics as plain text,
1807 punctuation and accents without any hassle.
1808
1809 The precise definition of this mode is in @ref{Lyrics mode
1810 definition}. The definition itself is ludicrous, and this will remain so
1811 until the authors of LilyPond acquire a deeper understanding of
1812 character encoding, or someone else steps up to fix this.
1813
1814 Syllables are entered like notes, with pitches replaced by text.  For
1815 example, @code{Twin- kle twin- kle} enters four syllables.  Note that
1816 the hyphen has no special meaning for lyrics, and does not introduce
1817 special symbols.
1818
1819 Spaces can be introduced into a lyric either by using quotes
1820 (@code{"}) or by using an underscore without quotes: @code{He_could4
1821 not4}.  All unquoted underscores are converted to spaces.
1822
1823 @c .  {Printing lyrics}
1824 @node Printing lyrics
1825 @subsection Printing lyrics
1826 @cindex lyrics
1827
1828 Normally, you will want to have notes and syllables matched
1829 automatically. This is accomplished using @code{\addlyrics}, which is
1830 documented in @ref{Automatic syllable durations}. Setting
1831 @code{automaticMelismata} in the melody staff, will cause slurs to be
1832 interpreted as melismata. Lyric syllables must be interpreted within a
1833 @code{Lyrics} context in order to printing them.
1834
1835 @lilypond[verbatim,singleline]
1836 \addlyrics \notes \relative c' {
1837         \time 7/4;
1838         \property Staff.automaticMelismata = ##t
1839         d'2 c4 b2 a2
1840         b2 c4 b4 ()  a4 g2 }
1841     \context Lyrics \lyrics { 
1842        Join us now and
1843        share the so -- ftware; }
1844 @end lilypond
1845
1846 @cindex extender
1847 @cindex lyric extender
1848 @cindex melisma
1849
1850 As you can see, extender lines are entered as @code{__}.  This will
1851 create an extender, a line that extends over the entire duration of the
1852 lyric.  This line will run all the way to the start of the next lyric,
1853 so you may want to shorten it by using a blank lyric (using @code{_}).
1854
1855 @cindex hyphen
1856
1857 If you want to have hyphens centered between syllables (rather than
1858 attached to the end of the first syllable) you can use the special
1859 `@code{-}@code{-}' lyric as a separate word between syllables.  This
1860 will result in a hyphen which length varies depending on the space
1861 between syllables, and which will be centered between the syllables. 
1862
1863 @cindex Lyric hyphen
1864
1865 @node Automatic syllable durations
1866 @subsection Automatic syllable durations
1867 @cindex Automatic syllable durations
1868
1869 @cindex automatic lyric durations
1870 @cindex @code{\addlyrics}
1871
1872 If you have lyrics that are set to a melody, you can import the rhythm
1873 of that melody into the lyrics using @code{\addlyrics}.  The syntax for
1874 this is
1875 @example
1876   \addlyrics @var{musicexpr1 musicexpr2}
1877 @end example
1878
1879 This means that both @var{musicexpr1} and @var{musicexpr2} are
1880 interpreted, but that every non-command atomic music expression
1881 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1882 of @var{musicexpr1}.
1883 @cindex @code{automaticMelismata}
1884
1885 If the property @code{automaticMelismata} is set in the
1886 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1887 notes.
1888
1889 @lilypond[verbatim,fragment]
1890 \addlyrics
1891 \transpose c'' {
1892   \property Voice.automaticMelismata = ##t
1893   c8 () cis d8. e16 f2
1894 }
1895 \context Lyrics \lyrics {
1896  do4 re mi fa }
1897 @end lilypond
1898
1899 If you want the lyric lines to be above the melody staff, or in some
1900 other, more complex configuration, then build that configuration first
1901 using simultaneous music, and use @code{\addlyrics} after that.
1902
1903 @lilypond[verbatim, singleline]
1904 \notes <
1905   \context Lyrics = LA { s1 }
1906   \context Staff = SA { s1 }
1907   \addlyrics
1908         \context Staff = SA \relative c' { c4 e g g }
1909         \context Lyrics  = LA \lyrics { geen ge -- don -- der } >
1910 @end lilypond
1911
1912 For @code{\addlyrics} you should use a single rhythm melody, and single
1913 rhythm lyrics (a constant duration is the obvious choice).  If you do
1914 not, you can get undesired effects when using multiple stanzas:
1915
1916 @lilypond[verbatim,fragment]
1917 \addlyrics
1918 \transpose c'' {
1919   c8 () cis d8. e16 f2
1920 }
1921 \context Lyrics \lyrics
1922 < { do4 re mi fa }
1923   { do8 re mi fa } >
1924 @end lilypond
1925
1926 It is valid (but probably not very useful) to use notes instead of
1927 lyrics for @var{musicexpr2}.
1928
1929 @node More stanzas
1930 @subsection More stanzas
1931
1932 @cindex phrasing
1933
1934 If you have multiple stanzas printed underneath each other, the separate
1935 syllables should be aligned around punctuation. LilyPond can do this if
1936 you explain it which lyric lines belong to which melody.
1937
1938 To this end, give the Voice context an identity, and set the LyricsVoice
1939 to name starting with that identity. In the following example, the Voice
1940 identity is @code{duet}, and the identities of the LyricsVoices are
1941 @code{duet-1} and @code{duet-2}.
1942
1943
1944 @lilypond[singleline,verbatim]
1945 \score {
1946 \addlyrics
1947   \notes \relative c'' \context Voice = duet { \time 3/4;
1948      g2 e4 a2 f4 g2.  }
1949   \lyrics \context Lyrics <
1950   \context LyricsVoice = "duet-1" {
1951     \property LyricsVoice . stanza = "Bert"
1952     Hi, my name is bert.    }
1953   \context LyricsVoice = "duet-2" {
1954     \property LyricsVoice . stanza = "Ernie" 
1955     Ooooo, ch\'e -- ri, je t'aime. }
1956   >
1957 }
1958 @end lilypond
1959
1960 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1961 first system) and @code{LyricsVoice.stz} for the following systems.
1962
1963 @cindex stanza numbering
1964
1965
1966 @c . {Chords}
1967 @node Chords
1968 @section Chords
1969 @cindex Chords
1970
1971 LilyPond has support for both entering and printing chords.  Chords are
1972 a harmonic device that is characterized by a set of pitches. It is
1973 something different from simultaneous music, although you can express a
1974 chord using simultaneous music. In fact, chords are internally stored as
1975 simultaneous music expressions. This means you can enter chords by name,
1976 and print them as note head, or enter as notes and print as chord names:
1977
1978
1979 @lilypond[verbatim,singleline]
1980 twoWays = \notes \transpose c'' {
1981   \chords {
1982     c1 f:sus4 bes/f
1983   }
1984   <c e g>
1985   <f bes c'>
1986   <f bes d'>
1987   }
1988
1989 \score {
1990    < \context ChordNames \twoWays
1991      \context Staff \twoWays > }
1992 @end lilypond
1993
1994 Note that this example also shows that the LilyPond chord does not
1995 attempt to be intelligent, if you enter @code{f bes d}, it does no
1996 attempt to find out whether it this is an inversion.
1997
1998 @menu
1999 * Chords mode::                 
2000 * Printing named chords::       
2001 @end menu
2002
2003 @c .  {Chords mode}
2004 @node Chords mode
2005 @subsection Chords mode
2006 @cindex Chords mode
2007
2008 Chord mode is a mode where you can input sets of pitches using common
2009 names.  It is introduced by the keyword @code{\chords}.  It is similar
2010 to note mode, but words are also looked up in a chord modifier table
2011 (containing @code{maj}, @code{dim}, etc).
2012
2013 Dashes and carets are used to indicate chord additions and subtractions,
2014 so articulation scripts can not be entered in Chord mode.
2015
2016 The syntax for named chords is as follows:
2017 @example
2018
2019   @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2020 @end example
2021
2022 @var{tonic} should be the tonic note of the chord, and @var{duration}
2023 is the chord duration in the usual notation.  There are two kinds of
2024 modifiers.  One type is @emph{chord additions}, which are obtained by
2025 listing intervals separated by dots.  An interval is written by its
2026 number with an optional @code{+} or @code{-} to indicate raising or
2027 lowering by half a step.  Chord additions has two effects: It adds
2028 the specified interval and all lower odd numbered intervals to the
2029 chord, and it may lower or raise the specified interval.  Intervals
2030 must be separated by a dot (@code{.}).
2031
2032 Throughout these examples, chords have been shifted around the staff
2033 using @code{\transpose}.
2034
2035 @lilypond[fragment,verbatim]
2036 \transpose c'' {
2037   \chords {
2038     c1  c:3-       c:7     c:8
2039     c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
2040   }
2041 }
2042 @end lilypond
2043
2044 @cindex @code{aug}
2045 @cindex @code{dim}
2046 @cindex @code{maj}
2047 @cindex @code{sus}
2048
2049 The second type of modifier that may appear after the @code{:} is a
2050 named modifier.  Named modifiers are listed in the file
2051 @file{chord-modifiers.ly}.  The available modifiers are @code{m} and
2052 @code{min} which lower the 3rd half a step, `@code{aug}' which
2053 raises the 5th, `@code{dim}' which lowers the 5th,
2054 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2055 which replaces the 5th with a 4th.
2056
2057 @lilypond[fragment,verbatim]
2058 \transpose c'' {
2059   \chords {
2060     c1:m c:min7 c:maj c:aug c:dim c:sus
2061   }
2062 }
2063 @end lilypond
2064  
2065
2066 Chord subtractions are used to eliminate notes from a chord.  The
2067 notes to be subtracted are listed after a @code{^} character,
2068 separated by dots.
2069
2070 @lilypond[fragment,verbatim,center]
2071   \transpose c'' {
2072     \chords {
2073       c1^3 c:7^5.3 c:8^7
2074     }
2075   }
2076 @end lilypond 
2077 @cindex @code{/}
2078
2079 Chord inversions can be specified by appending `@code{/}' and the name
2080 of a single note to a chord.  In a chord inversion, the inverted note is
2081 transposed down until it is the lowest note in the chord.  If the
2082 specified note is not in the chord, a warning will be printed.
2083
2084 @lilypond[fragment,verbatim,center]
2085   \transpose c''' {
2086     \chords {
2087       c1 c/e c/g c:7/e
2088     }
2089   }
2090
2091 @end lilypond 
2092 @cindex @code{/+}
2093
2094 Bass notes can be added by `@code{/+}' and
2095 the name of a single note to a chord.  This has the effect of
2096 adding the specified note to the chord, lowered by an octave,
2097 so it becomes the lowest note in the chord.
2098
2099 @lilypond[fragment,verbatim,center]
2100   \transpose c''' {
2101     \chords {
2102       c1 c/+c c/+g c:7/+b
2103     }
2104   }
2105
2106 @end lilypond 
2107
2108
2109
2110
2111 @c .  {Printing named chords}
2112 @node Printing named chords
2113 @subsection Printing named chords
2114
2115 @cindex printing chord names
2116 @cindex chord names
2117 @cindex chords
2118 @cindex @code{ChordNames}
2119
2120
2121 For displaying printed chord names, use the @code{ChordNames} context.
2122 The chords may be entered either using the notation described above, or
2123 directly using simultaneous music.
2124
2125 @lilypond[verbatim,singleline]
2126 scheme = \notes {
2127   \chords {a1 b c} <d f g>  <e g b>
2128 }
2129 \score {
2130   \notes<
2131     \context ChordNames \scheme
2132     \context Staff \transpose c'' \scheme
2133   >
2134 }
2135 @end lilypond
2136
2137 You can make the chord changes stand out by setting property
2138 @code{ChordNames.chordChanges} to true.  This will only display chord
2139 names when there's a change in the chords scheme and at the start of the
2140 line.
2141
2142 @lilypond[verbatim]
2143 scheme = \chords {
2144   c1:m \break c:m c:m c:m d
2145 }
2146
2147 \score {
2148   \notes <
2149     \context ChordNames {
2150         \property ChordNames.chordChanges = ##t
2151         \scheme }
2152     \context Staff \transpose c'' \scheme
2153   > }
2154 @end lilypond
2155
2156 LilyPond examines chords specified as lists of notes to determine a name
2157 to give the chord. LilyPond will not try to identify chord inversions or
2158 added base, which may result in strange chord names when chords are
2159 entered as a list of pitches:
2160
2161 [base vs. bass ?]
2162
2163 @lilypond[verbatim,center,singleline]
2164 scheme = \notes {
2165   <c'1 e' g'>
2166   <e' g' c''>
2167   <e e' g' c''>
2168 }
2169
2170 \score {
2171   <
2172     \context ChordNamesVoice \scheme
2173     \context Staff \scheme
2174   >
2175 }
2176 @end lilypond
2177
2178
2179 By default LilyPond uses chord name system proposed by Harald Banter
2180 (See @ref{Literature}). The system is is unambiguous and has a logical
2181 structure.  Typical American style chord names may be selected by
2182 setting the @code{style} property of the @code{ChordNames.ChordName}
2183 grob to @code{'american}. Similarly @code{'jazz} selects Jazz
2184 chordnames.
2185
2186 Routines that determine the names to be printed are written in Scheme,
2187 and may be customized by the user.  The code can be found in
2188 @file{scm/chord-name.scm}.
2189
2190 [3 short examples showing differences between american, banter and jazz]
2191
2192 @node Writing parts
2193 @section Writing parts
2194
2195 Orchestral music involves some special notation, both in the full score,
2196 as in the individual parts. This section explains how to tackle common
2197 problems in orchestral music.
2198
2199
2200 @c .  {Transpose}
2201 @menu
2202 * Rehearsal marks::             
2203 * Bar numbers::                 
2204 * Instrument names::            
2205 * Transpose::                   
2206 * Sound output for transposing instruments::  
2207 * Multi measure rests::         
2208 * Automatic part combining::    
2209 * Hara-kiri staffs::            
2210 @end menu
2211
2212 @c .   {Rehearsal marks}
2213 @node Rehearsal marks
2214 @subsection Rehearsal marks
2215 @cindex Rehearsal marks
2216 @cindex mark
2217 @cindex @code{\mark}
2218 @cindex @code{Mark_engraver}
2219
2220 @example
2221   \mark @var{unsigned};
2222   \mark @var{string};
2223   \mark ; 
2224 @end example
2225
2226 With this command, you can print a rehearsal mark above the system. You
2227 can provide a number, a string or a markup text as argument. If there is
2228 no argument, the property @code{rehearsalMark} is used and automatically
2229 incremented.
2230
2231 @lilypond[fragment,verbatim]
2232 \relative c'' {
2233   c1 \mark "A2";
2234   c1 \mark ; 
2235   c1 \mark ; 
2236   c1 \mark "12";
2237   c1 \mark #'(music "scripts-segno") ;
2238   c1
2239 }
2240 @end lilypond
2241
2242 @node Bar numbers
2243 @subsection Bar numbers
2244
2245 Bar numbers are printed at the start of the line by default. This is
2246 done by the @code{Bar_number_engraver} in the Score context.
2247
2248 @refbugs
2249
2250 It is currently not possible to make boxed bar numbers, or print them at
2251 regular intervals.
2252
2253
2254 @node Instrument names
2255 @subsection Instrument names
2256
2257 You can specify an instrument name for a staff by setting
2258 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2259 before the start of the staff. For the first start, @code{instrument} is
2260 used, for the next ones @code{instr} is used.
2261
2262 @lilypond[verbatim,singleline]
2263 \score { \notes {
2264   \property Staff.instrument = "ploink " { c''4 } }
2265   \paper { 
2266     \translator { \StaffContext
2267     \consists "Instrument_name_engraver"; } } }
2268 @end lilypond
2269
2270 This requires  that you add the @code{Instrument_name_engraver} to the
2271 staff context.
2272
2273
2274 @node Transpose
2275 @subsection Transpose
2276 @cindex Transpose
2277 @cindex transposition of pitches
2278 @cindex @code{\transpose}
2279
2280 A music expression can be transposed with @code{\transpose}.  The syntax
2281 is
2282 @example
2283   \transpose @var{pitch} @var{musicexpr}
2284 @end example
2285
2286 This means that middle C in @var{musicexpr} is transposed to
2287 @var{pitch}.
2288
2289 @code{\transpose} distinguishes between enharmonic pitches: both
2290 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2291 a tone.  The first version will print sharps and the second version
2292 will print flats.
2293
2294 @lilypond[fragment,verbatim]
2295 \context Staff {
2296   \clef "F";
2297   { \key e \major; c d e f }
2298   \clef "G";
2299   \transpose des'' { \key e \major; c d e f }
2300   \transpose cis'' { \key e \major; c d e f }
2301 }
2302 @end lilypond
2303
2304 If you want to use both @code{\transpose} and @code{\relative}, then
2305 you must use @code{\transpose} first.  @code{\relative} will have no
2306 effect music that appears inside a @code{\transpose}.
2307
2308 @node Sound output for transposing instruments
2309 @subsection Sound output transposing instruments
2310
2311 When you want to play a score containing transposed and untransposed
2312 instruments, you have to instruct LilyPond the pitch offset (in
2313 semitones) for the transposed instruments. This is done using the
2314 @code{transposing} property. It does not affect printed output.
2315
2316 @cindex @code{transposing}
2317
2318 @example
2319         \property Staff.instrument = #"Cl. in B-flat"
2320         \property Staff.transposing = #-2
2321 @end example
2322
2323
2324 @c .  {Multi measure rests}
2325 @node  Multi measure rests
2326 @subsection Multi measure rests
2327 @cindex Multi measure rests
2328
2329 @cindex @code{R}
2330
2331 Multi measure rests are entered using `@code{R}'. It is specifically
2332 meant for entering parts: the rest can expand to fill a score with
2333 rests, or it can be printed as a single multimeasure rest This expansion
2334 is controlled by the property @code{Score.skipBars}. If this is set to true,
2335 Lily will not expand empty measures, and the appropriate number is added
2336 automatically.
2337
2338 @lilypond[fragment,verbatim]
2339  \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17  R2.*4
2340 @end lilypond
2341
2342 Currently, there is  no way to condense multiple rests into a single
2343 multimeasure rest.
2344
2345 @cindex condensing rests
2346
2347 @node Automatic part combining
2348 @subsection Automatic part combining
2349 @cindex automatic part combining
2350 @cindex part combiner
2351
2352 Automatic part combining is used to merge two parts of music onto on
2353 staff in an intelligent way.  It is aimed primarily at typesetting Hymns
2354 and orchestral scores.  When the two parts are identical for a period of
2355 time, only one is shown.  In places where the two parts differ, stem
2356 directions are set automatically.  Also, soli and @emph{a due} parts can be
2357 identified and marke.
2358
2359 The syntax for part combining is
2360
2361 @example
2362   \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2363 @end example
2364
2365 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2366 combined into one context @var{context}.  The names of the music
2367 expressions must start with the prefixes @code{one} and @code{two}.
2368
2369 [Name of music expressions?  is that context name? ]
2370
2371 The most useful function of the part combiner to combining threads into
2372 one voice, as common for wind parts in orchestral scores:
2373
2374 @lilypond[verbatim,singleline,fragment]
2375   \context Staff <
2376     \context Voice=one \partcombine Voice
2377       \context Thread=one \relative c'' {
2378         g a b r
2379       }
2380       \context Thread=two \relative c'' {
2381         g r2 f4
2382       }
2383   >
2384 @end lilypond
2385
2386 Notice that the first @code{g} appears only once, although it was
2387 specified twice (once in each Thread). Also note that stem, slur and tie
2388 directions are set automatically, depending whether there is a solo or
2389 unisono. The Thread called @code{one} always gets up stems, and "solo",
2390 while @code{two} always gets down stems and "Solo II".
2391
2392 If you just want the splitting of Threads and setting of directions, and
2393 not the textual markings, you may set the property @var{soloADue} to
2394 false.  This mode can be used to set hymns:
2395
2396 @lilypond[verbatim,singleline,fragment]
2397   \context Staff <
2398     \property Staff.soloADue = ##f
2399     \context Voice=one \partcombine Voice
2400       \context Thread=one \relative c'' {
2401         b4 a c g
2402       }
2403       \context Thread=two \relative c'' {
2404         d,2 a4 g'
2405       }
2406   >
2407 @end lilypond
2408
2409 There are a number of other properties that you can use to tweak
2410 the behavior of part combining, refer to the automatically generated
2411 documentation. Look for @code{Thread_devnull_engraver}
2412 @code{Voice_devnull_engraver} and @code{A2_engraver}. 
2413
2414 @refbugs
2415
2416 In @code{soloADue} mode, when the two voices play the same notes on and
2417 off, the part combiner may typeset @code{a2} more than once in a
2418 measure.
2419
2420 @lilypond[fragment,singleline]
2421   \context Staff <
2422     \context Voice=one \partcombine Voice
2423       \context Thread=one \relative c'' {
2424         c b c b c a c a
2425       }
2426       \context Thread=two \relative c'' {
2427         b b b b f a f a
2428       }
2429   >
2430 @end lilypond
2431
2432 @cindex @code{Thread_devnull_engraver}
2433 @cindex @code{Voice_engraver}
2434 @cindex @code{A2_engraver}
2435
2436 @node Hara-kiri staffs
2437 @subsection Hara-kiri staffs
2438
2439 In orchestral scores, staffs that only have rests are usually removed.
2440 This saves some space.  LilyPond also supports this through the
2441 hara-kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide
2442 of the Japanese Samourai warriors.} staff. This staff commits suicide
2443 when it finds itself to be empty after the line-breaking process---note
2444 that it will not disappear when it contains normal rests, you must use
2445 multi measure rests.
2446
2447 The hara kiri staff is specialized version of the Staff context. It is
2448 available as the context identifier @code{\HaraKiriStaffContext}.
2449 Observe how the second staff in this example disappears in the second
2450 line.
2451
2452 @lilypond[verbatim]
2453 \score  {
2454   \notes \relative c' <
2455     \context Staff = SA { e4 f g a \break c1 }
2456     \context Staff = SB { c4 d e f \break R1 }
2457   >
2458   \paper {
2459     linewidth = 6.\cm ; 
2460     \translator { \HaraKiriStaffContext }
2461   }
2462 }
2463 @end lilypond
2464
2465
2466
2467 @c . {Custodes}
2468 @node Custodes
2469 @section Custodes
2470 @cindex Custos
2471 @cindex Custodes
2472
2473 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2474 staff context symbol that appears at the end of a staff line.  It
2475 anticipates the pitch of the first note(s) of the following line and
2476 thus helps the player or singer to manage line breaks during
2477 performance, thus enhancing readability of a score.
2478
2479 @lilypond[verbatim]
2480 \score {
2481   \notes { c'1 d' e' d' \break c' d' e' d' }
2482   \paper {
2483     \translator {
2484       \StaffContext
2485       \consists Custos_engraver;
2486       Custos \override #'style = #'mensural;
2487     }
2488   }
2489 }
2490 @end lilypond
2491
2492 Custodes were frequently used in music notation until the 16th century.
2493 There were different appearences for different notation styles.
2494 Nowadays, they have survived only in special forms of musical notation
2495 such as via the @emph{editio vaticana} dating back to the beginning of
2496 the 20th century.
2497
2498 For typesetting custodes, just put a @code{Custos_engraver} into the
2499 @code{StaffContext} when declaring the @code{\paper} block.  In this
2500 block, you can also globally control the appearance of the custos symbol
2501 by setting the custos @code{style} property.  Currently supported styles
2502 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2503 @code{mensural}.
2504
2505 @example
2506 \paper @{
2507   \translator @{
2508       \StaffContext
2509       \consists Custos_engraver;
2510       Custos \override #'style = #'mensural;
2511   @}
2512 @}
2513 @end example
2514
2515 The property can also be set locally, for example in a @code{\notes}
2516 block:
2517
2518 @example
2519 \notes @{
2520   \property Staff.Custos \override #'style = #'vaticana
2521   c'1 d' e' d' \break c' d' e' d'
2522 @}
2523 @end example
2524
2525 @c . {Tuning output}
2526 @node Tuning output
2527 @section Tuning output
2528
2529 LilyPond tries to take as much formatting as possible out of your
2530 hands. Nevertheless, there are situations where it needs some help, or
2531 where you want to override its decisions. In this section we discuss
2532 ways to do just that.
2533
2534 Notation output is specified in so called grobs (graphic objects). Each
2535 grob carries with it a set of properties (grob properties) specific to
2536 that object.  For example, a stem grob has properties that specify its
2537 direction, length and thickness.
2538
2539
2540 The most common way of tuning the output is to alter the values of these
2541 properties. There are two ways of doing that: first, you can temporarily
2542 change the definition of a certain type of grob, thus affecting a whole
2543 set of objects.  Second, you can select one specific object, and set a 
2544 grob property.
2545
2546 @menu
2547 * Tuning groups of grobs ::     
2548 * Tuning per grob ::            
2549 * What to tune?::               
2550 * Font selection::              
2551 * Text markup::                 
2552 @end menu
2553
2554 @node Tuning groups of grobs 
2555 @subsection Tuning groups of grobs 
2556
2557 @cindex grob description
2558
2559 A grob definition is a Scheme association list, that is stored in a context
2560 property.  By assigning to that property (using plain @code{\property}),
2561 you can change the resulting grobs.
2562
2563 @lilypond[verbatim, fragment]
2564 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2565 @end lilypond
2566
2567 The @code{\property} statement effectively empties the definition of the
2568 Stem object. One of the effects is that property specifying how it
2569 should be printed is erased, with the effect of rendering it invisible.
2570
2571 @cindex \override
2572 @cindex \revert
2573 @cindex \set
2574
2575 This mechanism is fairly crude, since you can only set, but not modify,
2576 the definition of a grob. For this reason, there is a more advanced
2577 mechanism: you can add a property on top of an existing definition, or
2578 remove a property: @code{\override} adds a settings, @code{\revert}
2579 removes that setting.
2580
2581 @lilypond[verbatim]
2582 c'4 \property Voice.Stem \override #'thickness = #4.0
2583 c'4 \property Voice.Stem \revert #'thickness
2584 c'4
2585 @end lilypond
2586
2587 For the digirati, the grob description is an Scheme association
2588 list. Since it is singly linked, we can treat it as a stack, and
2589 @code{\override} and @code{\revert} are just push and pop
2590 operations. This pushing and popping is also used for overriding automatic
2591 beaming settings.
2592
2593 If you revert a setting which was not set in the first place, then it
2594 has no effect. However, if the setting was set as a system default, it
2595 may remove the default value, and this may give surprising results,
2596 including crashes.  In other words, if you use @code{\override} and
2597 @code{\revert}, be sure to balance the overrides and reverts.
2598
2599 If balancing them is too much work, use the @code{\set} shorthand. It
2600 performs a revert followed by an override:
2601 @example
2602 \property Voice.Stem \set #'thickness = #2.0
2603 @end example
2604
2605 Formally the syntax for these constructions is
2606 @example
2607 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2608 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2609 \property @var{context}.@var{grobname} \revert @var{symbol}
2610 @end example
2611 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2612 and @var{grobname} are strings and @var{value} is a Scheme expression.
2613
2614 @refbugs
2615
2616 LilyPond will hang or crash if @var{value} contains cyclic references.
2617
2618
2619
2620 @node Tuning per grob 
2621 @subsection Tuning per grob 
2622
2623 @cindex \outputproperty
2624
2625 A second way of tuning grobs is the more arcane @code{\outputproperty}
2626 feature.
2627 Syntax is as follows
2628 @example
2629 \outputproperty @var{predicate} @var{symbol} = @var{value}
2630 @end example
2631 Here @code{predicate} is a Scheme function taking a grob argument, and
2632 returning a boolean.  This statement is processed by the
2633 @code{Output_property_engraver}.  It instructs the engraver to feed all
2634 grobs that it sees to @var{predicate}. Whenever the predicate returns
2635 true, the grob property @var{symbol} will be set to @var{value}.
2636
2637 You will need to combine this statement with @code{\context} to select
2638 the appropriate context to apply this to.
2639
2640 If possible, avoid this feature: the semantics are not very clean, and
2641 the syntax and semantics are up for rewrite.
2642
2643 Here are some random examples:
2644
2645 @lilypond[fragment,verbatim,singleline]
2646 \relative c'' { c4
2647   \context Staff \outputproperty
2648   #(make-type-checker 'note-head-interface)
2649   #'extra-offset = #'(0.5 . 0.75)
2650   <c8 e g> }
2651 @end lilypond
2652
2653 @cindex @code{extra-offset}
2654
2655 This selects all note heads occurring at current staff level, and sets
2656 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2657 them up and right.
2658
2659 Move the text "m.d.", but not the fingering instruction "2".
2660 @lilypond[verbatim,singleline]
2661 #(define (make-text-checker text)
2662    (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
2663
2664 \score {    
2665   \notes\relative c''' {
2666     \property Voice.Stem \set #'direction = #1
2667     \outputproperty #(make-text-checker "m.d.")
2668       #'extra-offset = #'(-3.5 . -4.5)
2669     a^2^"m.d."    
2670   }
2671 }
2672 @end lilypond
2673
2674
2675
2676
2677 @node What to tune?
2678 @subsection What to tune?
2679
2680 This all tells you how to tune grobs, but what variables are there? The
2681 question is not  answered in this manual (although you may encounter
2682 some examples.).
2683
2684 Grob properties are tied directly to the implementation of LilyPond, and
2685 they are thus a moving target. Documentation of such variables are part
2686 of the generated documentation: this documentation is generated from the
2687 sourcecode of lily for each version, so it is usually mch more up to
2688 date  than this manual. It should be available from the same place where
2689 you got this manual.
2690
2691 To decide how to tune a grob, you need to find the following information
2692 @itemize @bullet
2693 @item
2694 which grob to modify
2695 @item
2696 which property to modify
2697 @item
2698 which context the grob comes from.
2699 @end itemize
2700
2701 Included with the automatically generated documentation is a master list
2702 of grobs. Each one can be clicked, taking you to a overview of the
2703 available properties.
2704
2705 There is also a master list of contexts. Clicking each takes you to an
2706 overview of the context, listing which grob types are created there.
2707
2708
2709 @node Font selection
2710 @subsection Font selection
2711
2712 Most graphics in LilyPond are composed of characters of fonts.  You can
2713 alter the characteristics of the font by setting certain grob
2714 properties. The mechanism that is used for this resembles LaTeX's New
2715 Font Selection Scheme. Within this scheme, a font is entirely
2716 characterized by its font name.
2717
2718 For each grob that uses fonts (in other words, each grob that supports
2719 @code{font-interface}) a font-name must be selected before it can be
2720 printed.  The font name is selected by looking at a number of grob
2721 properties:
2722
2723 @table @code
2724 @item font-family
2725   The general class of the typeface.  Supported are roman (Computer
2726 Modern), braces (for piano staff braces), music (the standard music
2727 font), dynamic (font for dynamic signs) and typewriter
2728
2729 @item font-shape
2730   A symbol indicating the shape of the font, a finer gradation than
2731   font-family. Choices are italic and upright
2732 @item font-series
2733   Symbol indicating the serie of the font.  Series form a finer gradation
2734   than font-shape. Choices are medium and bold.
2735
2736 @item font-relative-size
2737   A number indicating the size relative the standard size.  For example,
2738   with 20pt staff height, relative size -1  corresponds to 16pt staff
2739   height, and relative size +1 corresponds to 23 pt staff height.
2740
2741 @item font-design-size
2742 A number indicating  the design size of the font. 
2743
2744 This is a feature of the Computer Modern Font: each point size has a
2745 slightly different design. Smaller design sizes are relatively wider,
2746 which enhances readability. Scalable type faces such TrueType and Adobe
2747 Type1 usually come as ``one design fits all sizes''.
2748
2749 @item font-name
2750   The name of the font, without the design size, eg. @code{cmr},
2751 @code{cmti}, etc. Setting this overrides font-family, font-shape and
2752 font-series.
2753
2754 @end table
2755
2756 The font is selected by taking the first font that satisfies all
2757 qualifiers specified. You can override any of these fields through
2758 @code{\override} and @code{\revert}. The special value @code{*} matches
2759 any value for that qualifier.
2760
2761 @example
2762   \property Lyrics.LyricText \override #'font-series = #'bold
2763   \property Lyrics.LyricText \override #'font-shape = #'*
2764 @end example
2765
2766 @cindex @code{font-style}
2767
2768 There are also pre-cooked font selection qualifiers. These are selected
2769 through the grob property @code{font-style}.  For example, the style
2770 @code{finger} selects family @code{number} and relative size @code{-3}.
2771 Styles available include: volta, finger, tuplet, timesig, mmrest,
2772 script, large, Large and dynamic.
2773
2774 The style sheets and tables for selecting fonts are located in
2775 @file{scm/font.scm}. Refer to this file for more information.
2776
2777 @refbugs
2778
2779 Relative size is not linked to any real size.  There is no mechanism to
2780 select magnifications of fonts, meaning that you can not scale fonts
2781 continuoussly. There is no style sheet provided for other fonts besides
2782 the @TeX{} family.
2783
2784 @cindex font selection
2785 @cindex font magnification
2786 @cindex @code{font-interface}
2787
2788
2789 @node Text markup
2790 @subsection Text markup
2791 @cindex text markup
2792 @cindex markup text
2793
2794 LilyPond has an internal mechanism to typeset texts. You can
2795 form text markup expressions by composing scheme expressions
2796 in the following way.
2797
2798 @lilypond[verbatim, singleline]
2799  \relative c' {
2800     \fatText
2801     a^#"upright"
2802     b_#'(bold "bold")
2803     c^#'(italic "italic")
2804     d_#'((bold italic) "ff")
2805     e^#'(dynamic "ff")
2806     f_#'(lines "one" (bold "two"))
2807     g^#'(music "noteheads-2" "flags-u3")
2808   }
2809 @end lilypond
2810
2811 Normally, the Scheme markup text is stored in the @code{text} property
2812 of a grob.  Formally, it is defined as follows:
2813
2814 @example
2815 text: string | (head? text+)
2816 head: markup | (markup+)
2817 markup-item: property | abbrev
2818 property: (@var{key} . @var{value})
2819 abbrev: @code{rows lines roman music bold italic named super sub text}
2820         @code{finger volta timesig mmrest mark script large Large dynamic}
2821 @end example
2822
2823 The markup is broken down and converted into a list of grob properties,
2824 which are prepended to the property list.  The @var{key}-@var{value}
2825 pair is a grob property.
2826
2827 The following abbreviations are currently defined:
2828
2829 @table @code
2830 @item rows
2831 horizontal mode: set all text on one line (default)
2832 @item lines
2833  vertical mode: set every text on new line
2834 @item roman
2835  select roman font
2836 @item music
2837  select feta font
2838 @item bold
2839  select bold series
2840 @item italic
2841  select italic shape
2842 @item named
2843  lookup by character name
2844 @item text
2845  plain text lookup (by character value)
2846 @item super
2847  superscript
2848 @item sub
2849  subscript
2850 @item finger
2851  select fingering number fontstyle
2852 @item volta
2853  select volta number fontstyle
2854 @item timesig
2855  select time signature number fontstyle
2856 @item mmrest
2857  select multi measure rest number fontstyle
2858 @item mark
2859  select mark number fontstyle
2860 @item script
2861  select scriptsize roman fontstyle
2862 @item large
2863  select large roman fontstyle
2864 @item Large
2865  select Large roman fontstyle
2866 @item dynamic
2867  select dynamics fontstyle
2868 @end table
2869
2870 It is possible to use @TeX{} commands in the strings, but this should be
2871 avoided because this makes it impossible for LilyPond to compute the
2872 exact length of the string, which may lead to collisions.  Also, @TeX{}
2873 commands won't work with direct postscript output.
2874
2875 @c . {Page layout}
2876 @node Page layout
2877 @section Page layout
2878 @cindex Page layout
2879
2880 @menu
2881 * Paper block::                 
2882 * Paper variables::             
2883 * Font Size::                   
2884 * Paper size::                  
2885 * Line break::                  
2886 * Page break::                  
2887 @end menu
2888
2889 @c .  {Paper block}
2890 @node Paper block
2891 @subsection Paper block
2892 @cindex Paper block
2893
2894 The most important output definition is the @code{\paper} block, for
2895 music notation.  The syntax is
2896
2897 @example
2898   @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2899 @end example
2900
2901 where each of the items is one of
2902
2903 @itemize @bullet
2904   @item  An assignment.  The assignment must be terminated by a
2905        semicolon.  
2906
2907   @item  A context definition.  See @ref{Notation Contexts} for
2908        more information on context definitions.
2909
2910   @item  \stylesheet  declaration.  Its syntax is
2911        @example
2912                 \stylesheet @var{alist}
2913        @end example
2914
2915         See @file{scm/font.scm} for details of @var{alist}.
2916   @item an \elementdescriptions declaration.
2917         @example
2918                 \elementdescriptions @var{alist}
2919         @end example
2920         See @file{scm/grob-description.scm} for details of @var{alist}.
2921
2922 @end itemize
2923
2924 @c .  {Paper variables}
2925 @node Paper variables
2926 @subsection Paper variables 
2927 @cindex Paper variables
2928
2929 The paper block has some variables you may want to use or change:
2930
2931 @table @code
2932 @cindex @code{indent}
2933   @item @code{indent}  
2934     The indentation of the first line of music.
2935 @cindex @code{staffspace}
2936
2937   @item @code{staffspace}
2938     The distance between two staff lines, calculated from the center
2939     of the lines.  If you want scale independent output, then you should
2940 use either this or @code{stafflinethickness}
2941     as a unit for distances you modify.
2942   
2943 @cindex @code{linewidth}
2944   @item @code{linewidth}  
2945     Sets the width of the lines.
2946
2947 If set to a negative value, a single unjustified line is produced.
2948 @c rename to singleLinePaper ?
2949 The shorthand @code{\singleLine} defines a default paper block that
2950 produces a single line.
2951
2952 @cindex @code{textheight}
2953
2954   @item @code{textheight}  
2955     Sets the total height of the music on each page. Only used by
2956 @code{ly2dvi}.
2957
2958 @cindex @code{interscoreline}
2959
2960   @item @code{interscoreline}  
2961     Sets the spacing between systems.
2962 Not set by default.
2963 @cindex @code{interscorelinefill}
2964
2965
2966
2967   @item @code{interscorelinefill}  
2968     If set to a positive number, the distance between the score 
2969     lines will stretch in order to fill the full page. In that
2970     case @code{interscoreline} specifies the minimum spacing.
2971
2972         Not set by default.
2973
2974
2975 @cindex @code{stafflinethickness}
2976
2977   @item @code{stafflinethickness}  
2978     Determines the thickness of staff lines, and also acts as a scaling
2979     parameter for other line thicknesses.
2980 @end table
2981
2982
2983
2984 @c .  {Font size}
2985 @node Font Size
2986 @subsection Font size
2987 @cindex font size
2988
2989 The Feta font provides musical symbols at six different sizes.  These
2990 fonts are 11 point, 13 point, 16 point, 20 point,
2991 23 point, and 26 point.  The point size of a font is the
2992 height of the five lines in a staff when displayed in the font.
2993
2994 Definitions for these sizes are the files @file{paperSZ.ly}, where
2995 @code{SZ} is one of 11, 13, 16, 20, 23 and 26.  If you include any of
2996 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2997 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2998 @code{paperTwentysix} are defined respectively.  The default
2999 @code{\paper} block is also set.
3000
3001 The font definitions are generated using a Scheme function. For more
3002 details, see the file @file{font.scm}.
3003
3004
3005
3006 @c .  {Paper size}
3007 @node Paper size
3008 @subsection Paper size
3009 @cindex Paper size
3010
3011 @cindex paper size
3012 @cindex page size
3013 @cindex @code{papersize}
3014
3015 To change the paper size, you must first set the
3016 @code{papersize} variable at top level.  Set it to
3017 the strings @code{a4}, @code{letter}, or @code{legal}.  After this
3018 specification, you must set the font as described above.  If you want
3019 the default font, then use the 20 point font.  The new paper size will
3020 not take effect if the font is not loaded and selected afterwards.
3021
3022 @example
3023         papersize = "a4"
3024         \include "paper16.ly"
3025
3026         \score @{
3027                 ...
3028                 \paper @{ \paperSixteen @}
3029         @}
3030 @end example
3031
3032 The file @code{paper16.ly}  will now include a file named @file{a4.ly}, which
3033 will set the paper variables @code{hsize} and @code{vsize} (used by
3034 @code{ly2dvi})
3035
3036
3037
3038
3039
3040
3041
3042 @c .  {Line break}
3043 @node Line break
3044 @subsection Line break
3045
3046 @cindex line breaks
3047 @cindex breaking lines
3048
3049 Line breaks are normally computed automatically. They are chosen such
3050 that the resulting spacing has low variation, and looks neither cramped
3051 nor loose.
3052
3053 Occasionally you might want to override the automatic breaks; you can do
3054 this by specifying @code{\break}. This will force a line break at this
3055 point. Do remember that line breaks can only occur at places where there
3056 are barlines.  If you want to have a line break where there is no
3057 barline, you can force an invisible barline by entering @code{\bar "";}.
3058
3059 Similarly, @code{\noBreak} forbids a  line break at a certain point.
3060
3061 @cindex @code{\penalty}
3062
3063 The @code{\break} and @code{\noBreak} commands are defined in terms of
3064 the penalty command:
3065 @example
3066   \penalty @var{int} @code{;}
3067 @end example
3068
3069 This encourages or discourages LilyPond to make a line break at this
3070 point.
3071
3072 @refbugs
3073
3074 The scaling of the @code{\penalty} argument is not well-defined.  The
3075 command is rather kludgy, and slated for rewriting.
3076
3077 @c .  {Page break}
3078 @node Page break
3079 @subsection Page break
3080
3081 @cindex page breaks
3082 @cindex breaking pages
3083
3084
3085 Page breaks are normally computed by @TeX{}, so they are not under
3086 direct control of LilyPond.  However, you can insert a commands into the
3087 @file{.tex} output to instruct @TeX{} where to break pages. For more
3088 details, see the example file @file{input/test/between-systems.ly}
3089
3090
3091
3092
3093
3094 @c . {Sound}
3095 @node Sound
3096 @section Sound
3097 @cindex Sound
3098
3099 LilyPond can produce MIDI output.  The performance lacks lots of
3100 interesting effects, such as swing, articulation, slurring, tieing,
3101 etc., but it is good enough for proof-hearing the music you enter.
3102
3103 Dynamics and tempo changes are interpreted.
3104
3105 [TODO: mention volume control/Instrument Equaliser]
3106
3107
3108 @refbugs
3109
3110 It is currently not possible to use the percussion channel (generally
3111 channel 10 of a MIDI file).
3112
3113 @menu
3114 * MIDI block::                  
3115 * MIDI instrument names::       
3116 @end menu
3117
3118 @c .  {MIDI block}
3119 @node MIDI block
3120 @subsection MIDI block
3121 @cindex MIDI block
3122
3123
3124 The MIDI block is analogous to the paper block, but it is somewhat
3125 simpler.  The @code{\midi} block can contain:
3126 @cindex MIDI block
3127
3128 @itemize @bullet
3129   @item  a @code{\tempo} definition
3130   @item  context definitions
3131 @end itemize
3132
3133 Assignments in the @code{\midi} block are not allowed.
3134
3135
3136
3137 @cindex context definition
3138
3139 Context definitions follow precisely the same syntax as within the
3140 \paper block.  Translation modules for sound are called performers.
3141 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3142
3143
3144 @node MIDI instrument names
3145 @subsection MIDI instrument names
3146
3147 @cindex instrument names
3148 @cindex @code{Staff.midiInstrument}
3149 @cindex @code{Staff.instrument}
3150
3151 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3152 property or, if that property is not set, the @code{Staff.instrument}
3153 property.  The instrument name should be chosen from the list in
3154 @ref{MIDI instruments}.
3155
3156 @refbugs
3157
3158 If the selected string does not exactly match, then LilyPond uses the
3159 default piano. It is not possible to select an instrument by number.
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169 @c . {Music entry}
3170 @node Music entry
3171 @section Music entry
3172 @cindex Music entry
3173 @menu
3174 * Relative::                    
3175 * Bar check::                   
3176 * Point and click::             
3177 @end menu
3178
3179 One of the applications of LilyPond is to enter music from existing
3180 written or printed material. When you're doing this kind of copying
3181 work, you can easily make mistakes.  This section deals with tricks and
3182 features that help you enter music, and find and correct mistakes.
3183
3184 @c .  {Relative}
3185 @node Relative
3186 @subsection Relative
3187 @cindex Relative
3188 @cindex relative octave specification
3189
3190 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3191 When you copy existing music, it is easy to accidentally put a pitch in
3192 the wrong octave and hard to find such an error.  To prevent these
3193 errors, LilyPond features octave entry.
3194
3195 @cindex @code{\relative}
3196 @example
3197   \relative @var{startpitch} @var{musicexpr}
3198 @end example
3199
3200 The octave of notes that appear in @var{musicexpr} are calculated as
3201 follows: If no octave changing marks are used, the basic interval
3202 between this and the last note is always taken to be a fourth or less.
3203   The octave changing marks @code{'} and @code{,} can then
3204 be added to raise or lower the pitch by an extra octave.  Upon entering
3205 relative mode, an absolute starting pitch must be specified that will
3206 act as the predecessor of the first note of @var{musicexpr}.
3207
3208 This distance is determined without regarding accidentals: a
3209 @code{fisis} following a @code{ceses} will be put above the
3210 @code{ceses}.
3211
3212 Entering music that changes octave frequently  is easy in relative mode.
3213 @lilypond[fragment,singleline,verbatim,center]
3214   \relative c'' {
3215     b c d c b c bes a 
3216   }
3217 @end lilypond
3218
3219 And octave changing marks are used for intervals greater than a fourth.
3220 @lilypond[fragment,verbatim,center]
3221   \relative c'' {
3222     c g c f, c' a, e'' }
3223 @end lilypond
3224
3225 If the preceding item is a chord, the first note of the chord is used
3226 to determine the first note of the next chord.  But other notes
3227 within the second chord are determined by looking at the immediately
3228 preceding note.
3229
3230 @lilypond[fragment,verbatim,center]
3231   \relative c' {
3232     c <c e g> 
3233     <c' e g>
3234     <c, e' g>
3235   }
3236 @end lilypond 
3237 @cindex @code{\notes}
3238
3239 The pitch after the @code{\relative} contains a notename.  To parse
3240 the pitch as a notename, you have to be in note mode, so there must
3241 be a surrounding @code{\notes} keyword (which is not
3242 shown here).
3243
3244 The relative conversion will not affect @code{\transpose},
3245 @code{\chords} or @code{\relative} sections in its argument.  If you
3246 want to use relative within transposed music, you must place an
3247 additional @code{\relative} inside the @code{\transpose}.
3248
3249
3250 @c .  {Bar check}
3251 @node Bar check
3252 @subsection Bar check
3253 @cindex Bar check
3254
3255 @cindex bar check
3256 @cindex @code{barCheckNoSynchronize}
3257 @cindex @code{|}
3258
3259
3260 Whenever a bar check is encountered during interpretation, a warning
3261 message is issued if it doesn't fall at a measure boundary.  This can
3262 help you find errors in the input.  Depending on the value of
3263 @code{barCheckNoSynchronize}, the beginning of the measure will be
3264 relocated, so this can also be used to shorten measures.
3265
3266 A bar check is entered using the bar symbol, @code{|}
3267
3268
3269
3270 @c .  {Point and click}
3271 @node Point and click
3272 @subsection Point and click
3273
3274 Point and click lets you find notes in the input by clicking on them in
3275 the Xdvi window. This makes it very easy to find input that causes some
3276 error in the sheet music.
3277
3278 To use it, you need the following software
3279
3280 @itemize
3281 @item 
3282 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,plain
3283 Xdvi} version 22.36 or newer.
3284
3285   Note that most @TeX{} distributions ship with xdvik, which is a
3286   different and less well maintained program. To find out which xdvi you
3287   are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
3288 @item emacs
3289 @end itemize
3290
3291
3292 Add one these lines to the top of your .ly file. The first one is for
3293 line location only. The second one is more convenient, but requires
3294 patching @code{emacsclient}.
3295
3296 @example
3297 #(set! point-and-click line-location)
3298 #(set! point-and-click line-column-location)
3299 @end example
3300
3301 In the emacs startup file (usually @file{~/.emacs}), add the following
3302 @example
3303 (server-start)
3304 @end example
3305
3306 If you want emacs to jump to the exact spot (and not just the line) on a
3307 click, you must enable column positioning. To do so, you need to patch
3308 emacsclient. Apply @file{emacsclient.patch} (included with the source
3309 package) to @file{emacsclient.c} and @file{server.el} from the emacs
3310 source code. Recompile and stick the recompiled emacsclient into a bin
3311 directory, and put @file{server.el} into a elisp directory
3312 (eg. @file{~/usr/share/emacs/}). Add the following to your @file{.emacs}
3313 init file, before invoking server-start.
3314
3315 @example
3316  (setq load-path (cons "~/usr/share/emacs" load-path))
3317 @end example
3318
3319
3320 Xdvi must be configured to use the emacs editor.  Before starting, set
3321 the environment variable @code{XEDITOR} to
3322 @example
3323 emacsclient --no-wait +%c:%l %f
3324 @end example
3325 Xdvi also must be configured to find the fonts. Refer to the
3326 xdvi documentation for more information.
3327
3328 When viewing, control-mousebutton 1 will take you to the originating
3329 line and column. Control-mousebutton 2 will show all clickable boxes.
3330
3331 @refbugs
3332
3333 When you convert the TeX file to PostScript using dvips, dvips
3334 will complain about not finding @code{src:X:Y} files. Those complaints are
3335 harmless, and can be ignored.
3336
3337
3338 @c . {Using LilyPond}
3339 @node Using LilyPond
3340 @section Using LilyPond
3341 @cindex Using LilyPond
3342 @cindex Generating output
3343
3344 @c slaat dit ergens op?
3345
3346 @c direct postscript?
3347
3348 @table @code
3349 @item plain lilypond
3350 @example
3351 lilypond foo.ly
3352 @end example
3353 For more information on how to use lilypond see
3354 @ifnottex
3355 @ref{Invoking LilyPond}.
3356 @end ifnottex
3357 @iftex
3358 the online manual.
3359 @end iftex
3360
3361 @item ly2dvi
3362 Ly2dvi produces titling from @code{\header} fields.
3363 @example
3364 ly2dvi foo.ly
3365 @end example
3366 For more information on how to use ly2dvi see
3367 @ifnottex
3368 @ref{ly2dvi}.
3369 @end ifnottex
3370 @iftex
3371 the online manual.
3372 @end iftex
3373
3374 @item lilypond-book
3375 Lilypond-book supports interleaving text and music.
3376 @example
3377 lilypond-book foo.doc
3378 @end example
3379 For more information on how to use lilypond-book see
3380 @ifnottex
3381 @ref{lilypond-book}.
3382 @end ifnottex
3383 @iftex
3384 the online manual.
3385 @end iftex
3386 @end table
3387
3388
3389 An emacs mode for LilyPond is included with the source archive as
3390 @file{lilypond-mode.el} and @file{lilypond-font-lock.el}.  If you have
3391 an RPM, it is in @file{/usr/share/doc/lilypond-X/}.  You have to install
3392 it yourself.
3393
3394 Add this to your ~/.emacs or ~/.emacs.el:
3395 @example 
3396     (load-library "lilypond-mode.el")
3397     (setq auto-mode-alist
3398       (cons '("\\.ly$" . LilyPond-mode) auto-mode-alist))
3399     (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock)))
3400 @end example
3401
3402 If you have the latest LilyPond-1.3.x Debian package, LilyPond-mode
3403 is automatically loaded, so you need not modify your ~/.emacs file.
3404
3405 @menu
3406 * Pre-cooked makefile::         
3407 @end menu
3408
3409 @node Pre-cooked makefile
3410 @subsection Pre-cooked makefile
3411
3412 @c waar deze info?  is uiteindelijk wel handig, schat ik.
3413 [TODO: cut blabla]
3414 If you have a big music project, or just a lot of LilyPond input files,
3415 all generated output from LilyPond, @TeX{} and metafont will clutter
3416 your working directory.  LilyPond comes with a one-size-fits-all
3417 pre-cooked makefile that helps you manage producing ouptut.  It will
3418 produce all output in @file{out}, generate and track dependencies.
3419 Also, it helps in preparing your submission to the @ref{Mutopia
3420 project}.
3421
3422 @file{make/ly.make}
3423 @example
3424 mkdir my-project
3425 cd my-project
3426 cp /usr/share/lilypond/make/ly.make GNUmakefile
3427 cp /usr/share/doc/lilypond/examples/input/tutorial/menuet.ly .
3428 make menuet
3429 [..]
3430 Generated out/menuet.ps for target menuet.
3431 @end example
3432
3433 Type @samp{make help} to see possible targets.
3434
3435 [TODO]
3436 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
3437
3438
3439 @node Interpretation context
3440 @section Interpretation context
3441
3442 @menu
3443 * Notation Contexts::           
3444 * Creating contexts::           
3445 * Default contexts::            
3446 * Context properties::          
3447 * Changing context definitions::  
3448 * Defining new contexts::       
3449 @end menu
3450
3451
3452 @c .  {Notation Contexts}
3453 @node Notation Contexts
3454 @subsection Notation Contexts
3455
3456 @cindex notation contexts
3457
3458 Notation contexts are objects that only exist during a run of LilyPond.
3459 During the interpretation phase of LilyPond (when it prints
3460 "interpreting music"), the music expresiion in a @code{\score} block is
3461 interpreted in time order. This is the same order that humans hear and
3462 play music.
3463
3464 During this interpretation, the notation context is holds the state for
3465 the current point within the music. It contains information like
3466
3467 @itemize @bullet
3468   @item What notes are playing at this point?
3469   @item What symbols will be printed at this point?
3470   @item What is the current key signature, time signature, point within
3471        the measure, etc.?
3472 @end itemize
3473
3474 Contexts are grouped hierarchically: A @code{Voice} context is
3475 contained in a @code{Staff} context (because a staff can contain
3476 multiple voices at any point), a @code{Staff} context is contained in
3477 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3478 these can all contain multiple staffs).
3479
3480
3481 Contexts associated with sheet music output are called @emph{notation
3482 contexts}, those for sound output are called performance contexts.
3483
3484
3485 @node Creating contexts
3486 @subsection Creating contexts
3487
3488 @cindex @code{\context}
3489 @cindex context selection
3490
3491 Contexts for a music expression can be selected manually, using the
3492 following music expression.
3493
3494 @example
3495   \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3496 @end example
3497
3498 This instructs lilypond to interpret @var{musicexpr} within the context
3499  of type @var{contexttype} and with name @var{contextname}.  If this
3500 context does not exist, it will be created.  
3501
3502 @lilypond[verbatim,singleline]
3503 \score {
3504   \notes \relative c'' {
3505     c4 <d4 \context Staff = "another" e4> f
3506   }
3507 }
3508
3509 @end lilypond
3510
3511 In this example, the @code{c} and @code{d} are printed on the
3512 default staff.  For the @code{e}, a context Staff called
3513 @code{another} is specified; since that does not exist, a new
3514 context is created.  Within @code{another}, a (default) Voice context
3515 is created for the @code{e4}.  When all music referring to a
3516 context is finished, the context is ended as well.  So after the
3517 third quarter, @code{another} is removed.
3518
3519
3520
3521 @node Default contexts
3522 @subsection Default contexts
3523
3524 Most music expressions don't need @code{\context}: they inherit the
3525 notation context from their parent. Each note is a music expression, and
3526 as you can see in the following example, only the sequential music
3527 enclosing the three notes has an explicit context. 
3528
3529 @lilypond[verbatim,singleline]
3530 \score { \notes \context Voice = goUp { c'4 d' e' } } 
3531 @end lilypond
3532
3533 There are some quirks that you must keep in mind when dealing with
3534 defaults:
3535
3536 First, every top-level music is interpreted by the Score context, in other
3537 words, you may think of @code{\score} working like
3538 @example
3539         \score @{
3540                 \context Score @var{music}
3541         @}
3542 @end example
3543
3544 Second, sequential music follows the contexts of its
3545 ``children''. Consider the following  example.
3546
3547 @lilypond[verbatim, singleline]
3548 \score { \context Score \notes { c'4 (  d' )e' } }
3549 @end lilypond
3550
3551 The sequential music is interpreted by the Score context initially
3552 (notice that the @code{\context} specification is redundant), but when a
3553 note is encountered, contexts are setup to accept that note. In this
3554 case, a Thread, Voice and Staff are created. The rest of the sequential
3555 music is also interpreted with the same Thread, Voice and Staff context,
3556 putting the notes on the same staff, in the same voice.
3557
3558 This is a convenient mechanism, but do not expect opening chords to work
3559 without @code{\context}. For every note, a separate staff is
3560 instantiated.
3561
3562 @lilypond[verbatim, singleline]
3563 \score { \notes <c'4 es'> } 
3564 @end lilypond
3565
3566 Of course, if the chord is preceded by a normal note in sequential
3567 music, the chord will be interpreted by the Thread of the preceding
3568 note:
3569 @lilypond[verbatim,singleline]
3570 \score { \notes { c'4 <c'4 es'> }  }
3571 @end lilypond
3572
3573
3574
3575 @node Context properties
3576 @subsection Context properties
3577
3578 Notation contexts can be modified from within the @file{.ly} file. The
3579 following music expression does that job:
3580
3581 @cindex @code{\property}
3582 @example
3583   \property @var{contextname}.@var{propname} =  @var{value}
3584 @end example
3585
3586 Sets the @var{propname} property of the context @var{contextname} to the
3587 specified Scheme expression @var{value}.  All @var{propname} and
3588 @var{contextname} are strings, which are typically unquoted.
3589
3590 Properties that are set in one context are inherited by all of the
3591 contained contexts.  This means that a property valid for the
3592 @code{Voice} context can be set in the @code{Score} context (for
3593 example) and thus take effect in all @code{Voice} contexts.
3594
3595 Properties can be unset using the following expression:
3596 @example
3597   \property @var{contextname}.@var{propname} \unset
3598 @end example
3599
3600 This removes the definition of @var{propname} in @var{contextname}. If
3601 @var{propname} was not defined in @var{contextname} (but was inherited
3602 from a higher context), then this has no effect.
3603
3604
3605 @refbugs
3606
3607 @code{\property \unset} is not the inverse of @code{\property \set}
3608
3609
3610
3611
3612 @c .  {Context definitions}
3613 @node Changing context definitions
3614 @subsection Changing context definitions
3615
3616 @cindex context definition
3617 @cindex translator definition
3618
3619 The most common way to define a context is by extending an existing
3620 context.  You can change an existing context from the paper block, by
3621 first initializing a translator with an existing context identifier:
3622 @example
3623 \paper @{
3624   \translator @{
3625     @var{context-identifier}
3626   @} @}
3627 @end example
3628 Then you can add engravers, remove engravers.
3629 The syntax for these operations are respectively
3630 @example
3631  \remove @var{engravername}
3632  \consists @var{engravername}
3633 @end example
3634
3635
3636 Here @var{engravername} is a string, the name of an engraver in the
3637 system.
3638 @example
3639  @var{propname} = @var{value} 
3640 @end example
3641
3642
3643 @lilypond[verbatim,singleline]
3644 \score {  \notes {
3645         c'4 c'4 }
3646   \paper {
3647     \translator  { \StaffContext
3648         \remove Clef_engraver;
3649        } } }
3650 @end lilypond
3651
3652 @cindex engraver
3653
3654 You can also set properties in a translator definition. The syntax is as
3655 follows:
3656
3657 @var{propname} is a string and @var{value} is a Scheme
3658 expression.
3659 @example
3660  @var{propname} = @var{value}
3661  @var{propname} \set  @var{symbol} = @var{value}
3662  @var{propname} \override @var{symbol} =  @var{value}
3663  @var{propname} \revert @var{symbol} 
3664
3665 @end example
3666
3667 These type of property assignments happen before interpretation starts,
3668 so a @code{\property} expression will override any predefined settings.
3669
3670
3671  To simplify editing translators, all standard contexts have standard
3672 identifiers called @var{name}@code{Context}, e.g. @code{StaffContext},
3673 @code{VoiceContext}.
3674
3675 @node Defining new contexts
3676 @subsection Defining new contexts
3677
3678 If you want to build a context from scratch, you must also supply the
3679 following extra information:
3680 @itemize @bullet
3681   @item  A name, specified by @code{\name @var{contextname};}.
3682
3683   @item A cooperation module. This is specified by   @code{\type
3684 @var{typename};}.
3685 @end itemize
3686
3687 This is an example:
3688 @example
3689 \translator @code{
3690   \type "Engraver_group_engraver";
3691   \name "SimpleStaff";
3692   \alias "Staff";
3693   \consists "Staff_symbol_engraver";
3694   \consists "Note_head_engraver";
3695   \consistsend "Axis_group_engraver";
3696 }@
3697 @end example
3698
3699 Basic building blocks of translation are called engravers; they are
3700 special C++ classes.
3701
3702 The argument of @code{\type} is the name for a special engraver that
3703 handles cooperation between simple engravers such as
3704 @code{Note_head_engraver} and @code{Staff_symbol_engraver}. Alternatives
3705 for this engraver are the following:
3706 @table @code
3707 @cindex @code{Engraver_group_engraver}
3708   @item @code{Engraver_group_engraver}  
3709     The standard cooperation engraver.
3710
3711 @cindex @code{Score_engraver}
3712
3713   @item @code{Score_engraver}  
3714     This is cooperation module that should be in the top level context,
3715 and only the toplevel context.
3716
3717 @cindex @code{Grace_engraver_group}
3718
3719   @item @code{Grace_engraver_group}  
3720     This is a special cooperation module (resembling
3721     @code{Score_engraver}) that is used to created an embedded
3722     `miniscore'.
3723 @end table 
3724
3725 Other modifiers   are
3726
3727 @itemize @bullet
3728   @item @code{\alias} @var{alternate-name} @code{;}
3729     This specifies a different name. In the above example,
3730 @code{\property Staff.X = Y} will also work on @code{SimpleStaff}s
3731
3732   @item  @code{\consistsend} @var{engravername} @code{;}  
3733     Analogous to @code{\consists}, but makes sure that
3734     @var{engravername} is always added to the end of the list of
3735     engravers.
3736
3737     Some engraver types need to be at the end of the list; this
3738     insures they are put there, and stay there, if a user adds or
3739     removes engravers.  This command is usually not needed for
3740     end-users.
3741     
3742   @item  @code{\accepts} @var{contextname} @code{;}  
3743     Add @var{contextname} to the list of  context this context can
3744     contain.  The first listed context is the context to create by
3745     default.
3746
3747   @item @code{\denies}. The opposite of @code{\accepts}. Added for
3748 completeness, but is never used in practice.
3749  
3750   
3751   @item  @code{\name} @var{contextname} @code{;}  
3752     This sets name of the context, e.g. @code{Staff}, @code{Voice}.  If
3753     the name is not specified, the translator won't do anything.
3754 @end itemize
3755
3756 In the @code{\paper} block, it is also possible to define translator
3757 identifiers.  Like other block identifiers, the identifier can only
3758 be used as the very first item of a translator.  In order to define
3759 such an identifier outside of @code{\score}, you must do
3760
3761 @quotation
3762 @example 
3763 \paper @{
3764   foo = \translator @{ @dots{} @}
3765 @}
3766 \score @{
3767   \notes @{
3768     @dots{}
3769   @}
3770   \paper @{
3771     \translator @{ \foo @dots{} @}
3772   @}
3773 @} 
3774 @end example 
3775
3776 @end quotation
3777
3778
3779 @cindex paper types, engravers, and pre-defined translators
3780
3781       
3782
3783
3784
3785
3786 @c . {Syntactic details}
3787 @node Syntactic details
3788 @section Syntactic details
3789 @cindex Syntactic details
3790
3791 This section describes details that were too boring to be put elsewhere.
3792
3793 @menu
3794 * Top level::                   
3795 * Identifiers::                 
3796 * Music expressions::           
3797 * Manipulating music expressions::  
3798 * Assignments::                 
3799 * Lexical modes::               
3800 * Ambiguities::                 
3801 @end menu
3802
3803 @c .  {Top level}
3804 @node Top level
3805 @subsection Top level
3806 @cindex Top level
3807
3808 This section describes what you may enter at top level.
3809
3810
3811 @c .   {Score}
3812 @subsubsection Score
3813 @cindex Score
3814
3815 @cindex score definition
3816
3817 The output is generated combining a music expression with an output
3818 definition.  A score block has the following syntax:
3819
3820 @example
3821   \score @{ @var{musicexpr} @var{outputdefs} @}
3822 @end example
3823
3824 @var{outputdefs} are zero or more output definitions.  If none is
3825 supplied, the default @code{\paper} block will be added.
3826
3827
3828
3829 @c .   {Default output}
3830 @subsubsection Default output
3831
3832 Default values for the @code{\paper} and @code{\midi} block are set by
3833 entering such a block at top-level.
3834
3835 @c .   {Header}
3836 @subsubsection Header
3837 @cindex Header
3838 @cindex @code{\header}
3839
3840
3841 A header describes bibilographic information of the file's contents.  It
3842 can also appear in a @code{\score} block.  Tools like @code{ly2dvi} can
3843 use this information for generating titles.  Key values that are used by
3844 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3845 metre, arranger, piece and tagline.
3846
3847 @cindex @code{ly2dvi}
3848
3849 The syntax is
3850 @example
3851   \header @{ @var{key1} = @var{val1};
3852              @var{key2} = @var{val2}; @dots{} @}
3853 @end example
3854
3855 It is customary to put the @code{\header} at the top of the file.
3856
3857 @subsubsection Default output
3858
3859 A @code{\midi} or @code{\paper} block at top-level sets the default
3860
3861 paper block for all scores that lack an explicit paper block.
3862
3863 @c .  {Identifiers}
3864 @node Identifiers
3865 @subsection Identifiers
3866 @cindex  Identifiers
3867
3868 All of the information in a LilyPond input file, is represented as a
3869 Scheme value. In addition to normal Scheme data types (such as pair,
3870 number, boolean, etc.), LilyPond has a number of specialized data types,
3871
3872 @itemize @bullet
3873 @item Input
3874 @item c++-function
3875 @item Music
3876 @item Identifier
3877 @item Translator_def
3878 @item Duration
3879 @item Pitch
3880 @item Score
3881 @item Music_output_def
3882 @item Moment (rational number)
3883 @end itemize
3884
3885 LilyPond also includes some transient object types. Objects of these
3886 types are built during a LilyPond run, and do not `exist' per se within
3887 your input file. These objects are created as a result of your input
3888 file, so you can include commands in the input to manipulate them,
3889 during a lilypond run.
3890
3891 @itemize @bullet
3892 @item Grob: short for Graphical object. See @ref{Grobs}. 
3893 @item Molecule: device-independent page output object,
3894 including dimensions.  Produced by some Grob functions
3895 See @ref{Molecules}
3896 @item Translator: object that produces audio objects or Grobs. This is
3897 not yet user accessible.
3898 @item Font_metric: object representing a font. (See @ref{Font metrics})
3899
3900 @end itemize
3901
3902
3903 @node Music expressions
3904 @subsection Music expressions
3905
3906 @cindex music expressions
3907
3908 Music in LilyPond is entered as a music expression.  Notes, rests, lyric
3909 syllables are music expressions, and you can combine music expressions
3910 to form new ones, for example by enclosing a list of expressions in
3911 @code{\sequential @{ @}} or @code{< >}.  In the following example, a
3912 compound expression is formed out of the quarter note @code{c} and a
3913 quarter note @code{d}:
3914
3915 @example 
3916 \sequential @{ c4 d4 @} 
3917 @end example 
3918
3919 @cindex Sequential music
3920 @cindex @code{\sequential}
3921 @cindex sequential music
3922 @cindex @code{<}
3923 @cindex @code{>}
3924 @cindex Simultaneous music
3925 @cindex @code{\simultaneous}
3926
3927 The two basic compound  music expressions are simultaneous  and
3928 sequential music.
3929
3930 @example
3931   \sequential @code{@{} @var{musicexprlist} @code{@}}
3932   \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3933 @end example
3934 For both, there is a shorthand:
3935 @example
3936   @code{@{} @var{musicexprlist} @code{@}}
3937 @end example
3938 for sequential and
3939 @example
3940   @code{<} @var{musicexprlist} @code{>}
3941 @end example
3942 for simultaneous music.
3943 In principle, the way in which you nest sequential and simultaneous to
3944 produce music is not relevant.  In the following example, three chords
3945 are expressed in two different ways:
3946
3947 @lilypond[fragment,verbatim,center]
3948   \notes \context Voice {
3949     <a c'> <b  d' > <c' e'>
3950     < { a b  c' } { c' d' e' } >
3951   }
3952 @end lilypond
3953
3954
3955 Other compound music expressions include
3956 @example
3957  \repeat @var{expr}
3958  \transpose @var{pitch} @var{expr}
3959  \apply @var{func} @var{expr}
3960  \context @var{type} = @var{id} @var{expr}
3961  \times @var{fraction} @var{expr}
3962 @end example
3963
3964
3965 @c . {Manipulating music expressions}
3966 @node Manipulating music expressions
3967 @subsection  Manipulating music expressions
3968
3969 The @code{\apply} mechanism gives you access to the internal
3970 representation of music. You can write Scheme-functions that operate
3971 directly on it. The syntax is 
3972 @example
3973         \apply #@var{func} @var{music}
3974 @end example
3975 This means that @var{func} is applied to @var{music}.  The function
3976 @var{func} should return a music expression.
3977
3978 This example replaces the text string of a script. It also shows a dump
3979 of the music it processes, which is useful if you want to know more
3980 about how music is stored.
3981 @lilypond[verbatim]
3982 #(define (testfunc x)
3983         (if (equal? (ly-get-mus-property x 'text) "foo")
3984                 (ly-set-mus-property x 'text "bar"))
3985         ;; recurse
3986         (ly-set-mus-property x 'elements
3987           (map testfunc (ly-get-mus-property x 'elements)))
3988         (display x)
3989         x        
3990 )
3991 \score { \notes
3992   \apply #testfunc { c4_"foo" }
3993
3994 @end lilypond
3995
3996 For more information on what is possible, see the @ref{Tricks} and the
3997 automatically generated documentation.
3998
3999
4000 Directly accessing internal representations is dangerous: the
4001 implementation is subject to changes, so you should avoid this feature
4002 if possible.
4003   
4004   
4005
4006 @c .   {Span requests}
4007 @menu
4008 * Span requests::               
4009 @end menu
4010
4011 @node Span requests
4012 @subsubsection Span requests
4013 @cindex Span requests
4014
4015 Notational constructs that start and end on different notes can be
4016 entered using span requests. The syntax is as follows:
4017
4018
4019 @example
4020   \spanrequest @var{startstop} @var{type}
4021 @end example
4022
4023
4024 @cindex @code{\start}
4025 @cindex @code{\stop}
4026
4027 This defines a spanning request. The @var{startstop} parameter is either
4028 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
4029 describes what should be started.  Much of the syntactic sugar is a
4030 shorthand for @code{\spanrequest}, for example,
4031
4032 @lilypond[fragment,verbatim,center]
4033   c'4-\spanrequest \start "slur"
4034   c'4-\spanrequest \stop "slur"
4035 @end lilypond
4036
4037 Among the supported types are @code{crescendo}, @code{decrescendo},
4038 @code{beam}, @code{slur}. This is an internal command.  Users are
4039 encouraged to use the shorthands which are defined in the initialization
4040 file @file{spanners.ly}.
4041
4042
4043 @c .   {Assignments}
4044 @node Assignments
4045 @subsection Assignments
4046 @cindex Assignments
4047
4048 Identifiers allow objects to be assigned to names during the parse
4049 stage.  To assign an identifier, you use @var{name}@code{=}@var{value}
4050 and to refer to an identifier, you preceed its name with a backslash:
4051 `@code{\}@var{name}'.  @var{value} is any valid Scheme value or any of
4052 the input-types listed above.  Identifier assignments can appear at top
4053 level in the LilyPond file, but also in @code{\paper} blocks.
4054
4055 Semicolons are forbidden after top level assignments, but mandatory in
4056 other places. The rules about semicolons and assignments are very
4057 confusing, but when LilyPond input evolves more towards Scheme, we hope
4058 that this problem will grow smaller.
4059
4060 An identifier can be created with any string for its name, but you will
4061 only be able to refer to identifiers whose names begin with a letter,
4062 being entirely alphabetical.  It is impossible to refer to an identifier
4063 whose name is the same as the name of a keyword.
4064
4065 The right hand side of an identifier assignment is parsed completely
4066 before the assignment is done, so it is allowed to redefine an
4067 identifier in terms of its old value, e.g.
4068
4069 @example
4070 foo = \foo * 2.0
4071 @end example
4072
4073 When an identifier is referenced, the information it points to is
4074 copied.  For this reason, an identifier reference must always be the
4075 first item in a block.
4076 @example
4077 \paper  @{
4078   foo = 1.0
4079   \paperIdent % wrong and invalid
4080 @}
4081
4082 \paper @{
4083   \paperIdent % correct
4084   foo = 1.0 @}
4085 @end example
4086
4087
4088 @c .  {Lexical modes}
4089 @node Lexical modes
4090 @subsection Lexical modes
4091 @cindex Lexical modes
4092 @cindex input mode
4093 @cindex mode, input 
4094 @cindex @code{\notes}
4095 @cindex @code{\chords}
4096 @cindex @code{\lyrics}
4097
4098 To simplify entering notes, lyrics, and chords, LilyPond has three
4099 special input modes on top of the default mode: note, lyrics and chords
4100 mode.  These input modes change the way that normal, unquoted words are
4101 interpreted: for example, the word @code{cis} may be interpreted as a
4102 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4103 respectively.
4104
4105 A mode switch is entered as a compound music expressions
4106 @example
4107 @code{\notes} @var{musicexpr}
4108 @code{\chords} @var{musicexpr}
4109 @code{\lyrics}  @var{musicexpr}.
4110 @end example
4111
4112 In each of these cases, these expressions do not add anything to the
4113 meaning of their arguments.  They are just a way to indicate that the
4114 arguments should be parsed in indicated mode.  The modes are treated in
4115 more detail in the @ref{Note entry}, @ref{Lyrics} and
4116 @ref{Chords}.
4117
4118 You may nest different input modes.
4119
4120 @c .  {Ambiguities}
4121 @node Ambiguities
4122 @subsection Ambiguities
4123 @cindex ambiguities
4124 @cindex grammar
4125
4126
4127 The grammar contains a number of ambiguities. We hope to resolve them at
4128 some time.
4129
4130 @itemize @bullet
4131   @item  The assignment
4132
4133          @example 
4134 foo = bar 
4135 @end example 
4136
4137        can be interpreted as making a string identifier @code{\foo}
4138        containing @code{"bar"}, or a music identifier @code{\foo}
4139        containing the syllable `bar'.
4140
4141   @item  The assignment
4142
4143          @example 
4144 foo = -6 
4145 @end example 
4146
4147        can be interpreted as making an integer identifier
4148        containing -6, or a Request identifier containing the
4149        fingering `6' (with neutral direction).
4150
4151   @item  If you do a nested repeat like
4152
4153        @quotation
4154
4155 @example 
4156 \repeat @dots{}
4157 \repeat @dots{}
4158 \alternative 
4159 @end example 
4160
4161        @end quotation
4162
4163        then it is ambiguous to which @code{\repeat} the
4164        @code{\alternative} belongs.  This is the classic if-then-else
4165        dilemma.  It may be solved by using braces.
4166
4167   @item  (an as yet unidentified ambiguity :-)
4168 @end itemize
4169
4170
4171 @c .  {Lexical details}
4172 @node Lexical details
4173 @section Lexical details
4174
4175 Even more boring details, now on lexical side of the input parser.
4176
4177 @menu
4178 * Comments::                    
4179 * Direct Scheme::               
4180 * Keywords::                    
4181 * Integers::                    
4182 * Reals::                       
4183 * Strings::                     
4184 * Main input::                  
4185 * File inclusion::              
4186 * Version information::         
4187 @end menu
4188
4189
4190 @node Comments
4191 @subsection Comments
4192
4193 @cindex comments
4194 @cindex block comment
4195 @cindex line comment
4196
4197 @cindex @code{%}
4198
4199 A one line comment is introduced by a @code{%} character. 
4200 Block comments are started by @code{%@{} and ended by @code{%@}}. 
4201 They cannot be nested.
4202
4203 @node Direct Scheme
4204 @subsection Direct Scheme
4205
4206 @cindex Scheme
4207 @cindex GUILE
4208 @cindex Scheme, in-line code
4209
4210
4211 LilyPond contains a Scheme interpreter (the GUILE library) for
4212 internal use. In some places Scheme expressions also form valid syntax:
4213 whereever it is allowed,
4214 @example
4215   #@var{scheme}
4216 @end example
4217 evaluates the specified Scheme code. If this is used at toplevel, then
4218 the result is discarded. Example:
4219 @example
4220   \property Staff.TestObject \override #'foobar =  #(+ 1 2)
4221 @end example
4222
4223 @code{\override} expects two Scheme expressions, so there are two Scheme
4224 expressions. The first one is a symbol (@code{foobar}), the second one
4225 an integer (namely, 3).
4226
4227 Scheme is a full-blown programming language, and a full discussion is
4228 outside the scope of this document. Interested readers are referred to
4229 the website @uref{http://www.schemers.org/} for more information on
4230 Scheme.
4231
4232
4233 @node Keywords
4234 @subsection Keywords
4235 @cindex Keywords
4236
4237
4238 Keywords start with a backslash, followed by a number of lower case
4239 alphabetic characters.  These are all the keywords.
4240
4241 @example
4242 apply arpeggio autochange spanrequest commandspanrequest
4243 simultaneous sequential accepts alternative bar breathe
4244 char chordmodifiers chords clef cm consists consistsend
4245 context denies duration dynamicscript elementdescriptions
4246 font grace header in lyrics key mark pitch
4247 time times midi mm name pitchnames notes outputproperty
4248 override set revert partial paper penalty property pt
4249 relative remove repeat addlyrics partcombine score
4250 script stylesheet skip textscript tempo translator
4251 transpose type
4252 @end example
4253
4254 @node Integers
4255 @subsection Integers
4256
4257 @cindex integers
4258 @cindex @code{+}
4259 @cindex @code{-}
4260 @cindex @code{*}
4261 @cindex @code{/}
4262
4263 Formed from an optional minus sign followed by digits.  Arithmetic
4264 operations cannot be done with integers, and integers cannot be mixed
4265 with reals.
4266
4267 @node Reals
4268 @subsection Reals
4269 @cindex real numbers
4270
4271
4272
4273
4274
4275 Formed from an optional minus sign and a sequence of digits followed
4276 by a @emph{required} decimal point and an optional exponent such as
4277 @code{-1.2e3}.  Reals can be built up using the usual operations:
4278 `@code{+}', `@code{-}', `@code{*}', and
4279 `@code{/}', with parentheses for grouping.
4280
4281 @cindex @code{\mm},
4282 @cindex @code{\in}
4283 @cindex @code{\cm}
4284 @cindex @code{\pt}
4285 @cindex dimensions
4286
4287 A real constant can be followed by one of the dimension keywords:
4288 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4289 points, inches and centimeters, respectively.  This converts the number
4290 a number that is the internal representation of that dimension.
4291
4292
4293 @node Strings
4294 @subsection Strings
4295 @cindex string
4296 @cindex concatenate
4297
4298 Begins and ends with the @code{"} character.  To include a @code{"}
4299 character in a string write @code{\"}.  Various other backslash
4300 sequences have special interpretations as in the C language.  A string
4301 that contains no spaces can be written without the quotes.  See
4302 @ref{Lexical modes} for details on unquoted strings; their
4303 interpretation varies depending on the situation.  Strings can be
4304 concatenated with the @code{+} operator.
4305
4306 The tokenizer accepts the following commands. They have no grammatical
4307 function, hence they can appear anywhere in the input.
4308
4309
4310 @node Main input
4311 @subsection Main input
4312 @cindex Main input
4313
4314 @cindex @code{\maininput}
4315
4316 The @code{\maininput} command is used in init files to signal that the
4317 user file must be read. This command cannot be used in a user file.
4318
4319 @node File inclusion
4320 @subsection File inclusion
4321 @cindex @code{\include}
4322 @example
4323   \include @var{filename}
4324 @end example
4325
4326 Include @var{filename}.  The argument @var{filename} may be a quoted string (an
4327 unquoted string will not work here!) or a string identifier.  The full
4328 filename including the @file{.ly} extension must be given,
4329
4330
4331 @node Version information
4332 @subsection Version information 
4333 @cindex @code{\version}
4334 @example
4335   \version @var{string} ;
4336 @end example
4337
4338 Specify the version of LilyPond that a file was written for.  The
4339 argument is a version string in quotes, for example @code{"1.2.0"}. 
4340 This is used to detect invalid input, and to aid
4341 @code{convert-ly}  a tool that automatically upgrades input files. See
4342 See @ref{convert-ly} for more information on @code{convert-ly}.
4343
4344 @cindex convert-ly
4345
4346
4347
4348
4349
4350
4351 @c .{Local emacs vars}
4352 @c Local variables:
4353 @c mode: texinfo
4354 @c minor-mode: font-lock
4355 @c minor-mode: outline
4356 @c outline-layout: (-1 : 0)
4357 @c outline-use-mode-specific-leader: "@c \."
4358 @c outline-primary-bullet: "{"
4359 @c outline-stylish-prefixes: nil
4360 @c outline-override-protect: t
4361 @c End:
4362