]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/refman.itely
release: 1.3.103
[lilypond.git] / Documentation / user / refman.itely
1 @c TODO: 
2 @c - Reinsert subsection commands that were lost in the
3 @c   ancient conversion from YODL!  /MB
4 @c - Restructure! Separate internal commands from user level commands. /MB
5 @c - Add some words about Guile.  /MB
6 @c - Fix indexing (keyindex) so it doesn't add line breaks  /MB
7
8 @node Reference Manual, ,  , Top
9 @menu
10 * Overview::                      Overview
11 * Top level::                     Top level
12 * notenames::                     notenames
13 * Lexical conventions::           Lexical conventions
14 * Other languages::                      notelang
15 * modes::                         modes
16 * Types::                         Types
17 * Music expressions::             Music expressions
18 * Atomic music expressions::      Atomic music expressions
19 * Note specification::                      notedesc
20 * barlines::                      barlines
21 * Manual beams::                  Manual beam
22 * stem tremolo::                       tremolo
23 * Compound music expressions::    Compound music expressions
24 * relative::                      relative
25 * Repeats::                       Repeats       
26 * transpose::                     transpose
27 * Ambiguities::                   Ambiguities
28 * Notation conversion specifics:: Notation conversion specifics
29 * autobeam::                      autobeam
30 * lyricprint::                    lyricprint
31 * Notation Contexts::             Notation Contexts
32 * Properties::                    Changing formatting
33 * Notation output definitions::   Notation output definitions
34 * paper::                         paper
35 * Paper variables::                     papervars
36 * contextdefs::                   contextdefs
37 * engravers::                     engravers
38 * Sound output::                  Sound output
39 * midilist::                      midilist
40 * Pre-defined Identifiers::       Pre-defined Identifiers
41 @end menu
42
43 @chapter Reference Manual
44
45
46
47 @node Overview, , , Reference Manual
48 @section Overview
49
50 This document@footnote{This document has been revised for
51 LilyPond 1.2.} describes the the GNU LilyPond input format, which is
52 a language for defining music.  We call this language @emph{Music
53 Definition Language} or @emph{Mudela}, for short.@footnote{If anybody
54 comes up with a better name, we'd gladly take this.  Gourlay already
55 uses a ``Musical Description Language,'' ISO standard 10743 defines a
56 ``Standard Music Description Language.''  We're not being original
57 here.}
58
59 @emph{Mudela} is a language that allows you to
60
61 @itemize @bullet
62   @item  create musical expressions by combining pitches, durations 
63   @item  output those musical expressions to various formats
64   @item  give those musical expressions and output definitions names, so
65        you can enter them in manageable chunks.
66 @end itemize
67
68 @emph{Mudela} aims to define a piece of music completely, both from
69 typesetting and from a performance point of view.
70
71
72
73 @node Top level, , , Reference Manual
74 @section Top level
75
76 @cindex top level
77
78 This section describes what you may enter at top level.
79
80
81
82 @cindex score definition
83
84 The output is generated combining a music expression with an output
85 definition.  A score block has the following syntax:
86
87 @example
88   \score @{ @var{musicexpr} @var{outputdefs} @}
89 @end example
90
91 @var{outputdefs} are zero or more output definitions.  If no output
92 definition is supplied, the default @code{\paper} block will be added.
93
94
95
96 @cindex header
97
98 @keyindex{header}
99
100 The syntax is
101
102 @example
103   \header @{ @var{key1} = @var{val1};
104              @var{key2} = @var{val2}; @dots{} @}
105 @end example
106
107 A header describes the file's contents.  It can also appear in a
108 @code{\score} block.  Tools like @code{ly2dvi}@indexcode{ly2dvi} can use this
109 information for generating titles.  Key values that are used by
110 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
111 metre, arranger, piece and tagline.
112
113 It is customary to put the @code{\header} at the top of the file.
114
115
116 @node notenames, , ,  Reference Manual
117
118 Note name tables can be specified using
119
120 @example
121    \notenames@keyindex{notenames}
122   @{ @var{assignmentlist} @}
123 @end example
124
125 @var{assignmentlist} is a list of definitions of the form
126
127 @example
128   @var{name} = @var{pitch}
129 @end example
130
131 Chord modifiers can be set analogously, with
132 @code{\chordmodifiers}@keyindex{chordmodifiers}.
133
134 A @code{\paper} block at top level sets the default paper block.  A
135 @code{\midi} block at top level works similarly.
136
137
138
139 LilyPond contains a Scheme interpreter (the GUILE library) for
140 internal use.  The following commands access the interpreter
141 directly.
142
143 @example
144   #@var{scheme}
145 @end example
146
147 Evaluates the specified Scheme code.  The result is discarded.
148
149 Identifier assignments may appear at top level.  Semicolons are
150 forbidden after top level assignments.
151
152
153
154 @node Lexical conventions, , ,  Reference Manual
155 @section Lexical conventions
156
157 @cindex lexical conventions
158
159
160
161 @cindex comment
162
163 @indexcode{%}
164
165
166 A one line comment is introduced by a `@code{%}' character. 
167 Block comments are started by `@code{%@{}' and ended by `@code{%@}}'. 
168 They cannot be nested.
169
170
171
172 @cindex keyword
173
174 Keywords start with a backslash, followed by a number of lower case
175 alphabetic characters.  These are all the keywords.
176
177 [FIXME]
178
179 @example
180   \accepts
181   \addlyrics
182   \alternative
183   \bar
184   \breathe
185   \chordmodifiers
186   \chords
187   \clef
188   \cm
189   \consists
190   \consistsend
191   \context
192   \duration
193   \font
194   \grace
195   \header
196   \in
197   \key
198   \keysignature
199   \lyrics
200   \mark
201   \midi
202   \mm
203   \musicalpitch
204   \name
205   \notenames
206   \notes
207   \paper
208   \partial
209   \penalty
210   \property
211   \pt
212   \relative
213   \remove
214   \repeat
215   \repetitions
216   \scm
217   \scmfile
218   \score
219   \script
220   \sequential
221   \simultaneous
222   \skip
223   \spanrequest
224   \tempo
225   \textscript
226   \time
227   \times
228   \translator
229   \transpose
230   \type
231 @end example
232
233
234
235
236 @cindex integer
237
238 Formed from an optional minus sign followed by digits.  Arithmetic
239 operations cannot be done with integers, and integers cannot be mixed
240 with reals.
241
242
243
244 @cindex real
245  
246
247 Formed from an optional minus sign and a sequence of digits followed
248 by a @emph{required} decimal point and an optional exponent such as
249 @code{-1.2e3}.  Reals can be built up using the usual operations:
250 `@code{+}@indexcode{+}', `@code{-}@indexcode{-}', `@code{*}@indexcode{*}', and
251 `@code{/}@indexcode{/}', with parentheses for grouping.
252
253 A real constant can be followed by one of the dimension
254 keywords:
255 @cindex dimensions
256  @code{\mm}@keyindex{mm},
257 @code{\pt}@keyindex{pt}, @code{\in}@keyindex{in}, or
258 @code{\cm}@keyindex{cm}, for millimeters, points, inches and
259 centimeters, respectively.  This converts the number to a real that
260 is the internal representation of dimensions.
261
262
263
264 @cindex string
265  
266
267 Begins and ends with the `@code{"}' character.  To include a `@code{"}'
268 character in a string write `@code{\"}'.  Various other backslash
269 sequences have special interpretations as in the C language.  A
270 string that contains no spaces can be written without the quotes. 
271 See section XREF-modes [FIXME] for details on unquoted strings; their
272 interpretation varies depending on the situation.  Strings can be
273 concatenated with the `@code{+}' operator.
274
275
276 The tokenizer accepts the following commands.  They can appear
277 anywhere.
278
279 @example
280   \maininput@keyindex{maininput}
281 @end example
282
283 This command is used in init files to signal that the user file must
284 be read. This command cannot be used in a user file.
285
286 @example
287   \include@keyindex{include} @var{file}
288 @end example
289
290 Include @var{file}.  The argument @var{file} may be a quoted string (an
291 unquoted string will not work here!) or a string identifier.  The full
292 filename including the @file{.ly} extension must be given,
293
294 @example
295   \version@keyindex{version} @var{string} ;
296 @end example
297
298 Specify the version of LilyPond that a file was written for.  The
299 argument is a version string in quotes, for example @code{"1.2.0"}. 
300 This is used to detect invalid input, and to aid
301 @code{convert-mudela}, a tool that automatically upgrades input files.
302
303
304
305 @cindex other languages
306
307 @node Other languages, , ,  Reference Manual
308
309 Note name definitions have been provided in various languages. 
310 Simply include the language specific init file.  For example:
311 `@code{\include "english.ly"}'.  The available language files and the
312 names they define are:
313
314 @example 
315                         Note Names               sharp       flat
316 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
317 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
318 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
319 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
320 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
321 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
322 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b 
323 @end example 
324
325 Pitch names can be redefined using the
326 @code{\notenames}@keyindex{notenames} command, see
327 subsection XREF-notenames [FIXME].
328
329
330
331 @cindex lexical modes
332
333 @cindex modes
334
335 @node modes, , ,  Reference Manual
336
337 To simplify entering notes, lyrics, and chords, @emph{Mudela} has three
338 special input modes on top of the default mode.  In each mode, words
339 are identified on the input.  If @code{"word"} is encountered, it is
340 treated as a string.  If @code{\word} is encountered, it is treated as
341 a keyword or as an identifier.  The behavior of the modes differs in
342 two ways: Different modes treat unquoted words differently, and
343 different modes have different rules for deciding what is a word.
344
345 @table @samp
346   @item Normal mode.
347 @cindex mode!normal
348  
349     At the start of parsing, @emph{Mudela} is in Normal mode.  In Normal
350     mode, a word is an alphabetic character followed by alphanumeric
351     characters.  If @code{word} is encountered on the input it is
352     treated as a string.
353
354   @item Note mode.
355 @cindex mode!note
356
357     Note mode is introduced by the keyword
358     @code{\notes}@keyindex{notes}.  In Note mode, words can only
359     contain alphabetic characters.  If @code{word} is encountered,
360     LilyPond first checks for a notename of @code{word}.  If no
361     notename is found, then @code{word} is treated as a string.
362
363     Since combinations of numbers and dots are used for indicating
364     durations, it is not possible to enter real numbers in this mode.
365
366   @item Chord mode.
367 @cindex mode!chord
368
369     Chord mode is introduced by the keyword
370     @code{\chords}@keyindex{chords}.  It is similar to Note mode, but
371     words are also looked up in a chord modifier table (containing
372     @code{maj}, @code{dim}, etc).
373
374     Since combinations of numbers and dots are used for indicating
375     durations, you can not enter real numbers in this mode.  Dashes
376     and carets are used to indicate chord additions and subtractions,
377     so scripts can not be entered in Chord mode.
378
379   @item Lyrics mode. 
380 @cindex mode!lyric
381
382     Lyrics mode is introduced by the keyword
383     @code{\lyrics}@keyindex{lyrics}.  This mode has rules that make it
384     easy to include punctuation and diacritical marks in words.  A
385     word in Lyrics mode begins with: an alphabetic character,
386     `@code{_}', `@code{?}', `@code{!}', `@code{:}', `@code{'}', the
387     control characters @code{^A} through @code{^F}, @code{^Q} through
388     @code{^W}, @code{^Y}, @code{^^}, any 8-bit character with ASCII code
389     over 127, or a two-character combination of a backslash followed
390     by one of `@code{`}', `@code{'}', `@code{"}', or
391     `@code{^}'.@footnote{The purpose of Lyrics mode is that you can
392     enter lyrics in @TeX{} format or a standard encoding without
393     needing quotes.  The precise definition of this mode indeed is
394     ludicrous.  This will remain so until the authors of LilyPond
395     acquire a deeper understanding of character encoding, or someone
396     else steps up to fix this.}
397
398     Subsequent characters of a word can be any character that is not
399     a digit and not white space.  One important consequence of this
400     is that a word can end with `@code{@}}', which may be confusing if
401     you thought the closing brace was going to terminate Lyrics
402     mode.@footnote{LilyPond will issue a warning, though.}  Any
403     `@code{_}' character which appears in an unquoted word is
404     converted to a space.  This provides a mechanism for introducing
405     spaces into words without using quotes.  Quoted words can also be
406     used in Lyrics mode to specify words that cannot be written with
407     the above rules.  Here are some examples.  Not all of these words
408     are printable by @TeX{}.
409
410 @example 
411 Ah!             % a word
412 2B_||_!2B       % not a word because it starts with a digit
413 ``Hello''       % not a word because it starts with `
414 _ _ _ _         % 4 words, each one a space 
415 @end example 
416
417     Since combinations of numbers and dots are used for indicating
418     durations, you can not enter real numbers in this mode.
419 @end table
420
421 It is possible to create words that break the rules by prefixing them
422 with the dollar sign `@code{$}@indexcode{$}'.  Regardless of the context, a
423 word beginning with `@code{$}' extends until the next white space
424 character.  Such words can contain numbers (even in Note mode), or
425 other forbidden characters.  The dollar sign can be used to create
426 and access identifiers that could not otherwise be used.@footnote{Use
427 of `@code{$}' hampers readability and portability to future LilyPond
428 versions, thus the use of the dollar sign is discouraged.}
429
430
431
432 @node Types, , ,  Reference Manual
433 @section Types
434
435 @cindex types and identifiers
436
437 @emph{Mudela} has a limited set of types:
438
439 @itemize @bullet
440   @item  integers
441   @item  reals
442   @item  strings
443   @item  music expressions
444   @item  durations of notes and rests (specified with
445        @code{\notenames}@keyindex{notenames})
446   @item  note name tables
447   @item  context definitions, part of output definitions.  See
448        section XREF-contextdefs [FIXME] for more information
449   @item  output definitions (like @code{\paper}@keyindex{paper} blocks
450        and @code{\midi}@keyindex{midi} blocks)
451   @item  score definitions (@code{\score}@keyindex{score} blocks)
452 @end itemize
453
454 Type is a syntactical property: @emph{Mudela} has no real type system,
455 so there is no support for generic expressions, functions, or user
456 defined types.  For the same reason, it is not possible to mix reals
457 and integers in arithmetic expressions, and ``type
458 errors''
459 @cindex type error
460  (e.g., using a string identifier to
461 initialize a @code{\paper}@keyindex{paper} block) will yield a ``parse
462 error''.
463
464 Identifiers allow objects to be assigned to names.  To assign an
465 identifier, you use `@var{name}=@var{value}' and to refer to an
466 identifier, you preceed its name with a backslash:
467 `@code{\}@var{name}'.  Identifier assignments must appear at top level
468 in the @emph{Mudela} file.  Semicolons are forbidden after assignments
469 appearing at top level but they are obligatory after assignments
470 appearing in the @code{\paper} block, see Section XREF-paper [FIXME].
471
472 @var{value} is any of the types listed above.
473
474 An identifier can be created with any string for its name, but you
475 will only be able to refer to identifiers whose names begin with a
476 letter, being entirely alphanumeric.  It is impossible to refer to an
477 identifier whose name is the same as the name of a keyword.
478
479 The right hand side of an identifier assignment is parsed completely
480 before the assignment is done, so it is allowed to redefine an
481 identifier in terms of its old value, e.g.
482
483 @example
484   foo = \foo * 2.0
485 @end example
486
487 When an identifier is referenced, the information it points to is
488 copied.  Therefore it only makes sense to put identifiers for
489 translators, output definitions, and @code{\score}@keyindex{score}
490 blocks as the first item in a block.  For this reason, if you
491 reference a @code{\foo} variable in a @code{\foo} block, it must be the
492 first item in the list following @code{\foo}.@footnote{@code{\paper@{\one
493 \two@}} does not make sense, because the information of @code{\two}
494 would overwrite the information of @code{\one}, thereby making the
495 reference to the first identifier useless.}
496
497
498
499 @node Music expressions, , ,  Reference Manual
500 @section Music expressions
501
502 @cindex music expressions
503
504 Music in @emph{Mudela} is entered as a music expression.  Notes, rests,
505 lyric syllables are music expressions (the atomic
506 expressions)
507 @cindex atomic music expressions
508 , and you can combine
509 music expressions to form new ones.  This example forms a compound
510 expressions out of the quarter @code{c} note and a @code{d}
511 note:
512
513 @example 
514 \sequential @{ c4 d4 @} 
515 @end example 
516
517 The meaning of this compound expression is to play the `@code{c}'
518 first, and then the `@code{d}' (as opposed to playing them
519 simultaneously, for instance).
520
521 Atomic music expression are discussed in
522 subsection XREF-atomicmusic [FIXME].  Compound music expressions are
523 discussed in subsection XREF-compoundmusic [FIXME].
524
525
526
527 @node Atomic music expressions, , ,  Reference Manual
528 @section Atomic music expressions
529
530
531
532
533 @cindex pitch
534
535 @cindex duration
536  
537
538 The syntax for pitch specification is
539
540
541 @example
542   \musicalpitch@keyindex{musicalpitch} @{ @var{octave} @var{note} @var{shift} @}
543 @end example
544
545 @var{octave} is specified by an integer, zero for the octave
546 containing middle C.  @var{note} is a number from 0 to 7, with 0
547 corresponding to C and 7 corresponding to B.  The shift is zero for a
548 natural, negative to add flats, or positive to add sharps.
549
550 In Note and Chord mode, pitches may be designated by names.  See
551 section XREF-notelang [FIXME] for pitch names in different languages.
552
553 The syntax for duration specification is
554
555 @example
556  \duration@keyindex{duration}
557    @{ @var{length} @var{dotcount} @}
558 @end example
559
560 @var{length} is the negative logarithm (base 2) of the duration:
561 1 is a half note, 2 is a quarter note, 3 is an eighth
562 note, etc.  The number of dots after the note is given by
563 @var{dotcount}.
564
565 In Note, Chord, and Lyrics mode, durations may be designated by
566 numbers and dots.  See Section XREF-notelang [FIXME] for details.
567
568
569 @node Note specification, , ,  Reference Manual
570
571 @cindex note specification
572
573 @cindex pitches
574
575 @cindex entering notes
576
577 A note specification has the form
578
579 @example
580   @var{pitch}[@var{octavespec}][!][?][@var{duration}]
581 @end example
582
583 The pitch of the note is specified by the note's name.
584
585
586 The default names are the Dutch note names.  The notes are specified
587 by the letters `@code{c}' through `@code{b}', where `@code{c}' is an
588 octave below middle C and the letters span the octave above that C. 
589 In Dutchcindex(notenames!Dutch), a sharp is formed by adding
590 `@code{-is}' to the end of a pitch name.  A flat is formed by adding
591 `@code{-es}'. Double sharps and double flats are obtained by adding
592 `@code{-isis}' or `@code{-eses}'.  `@code{aes}' and `@code{ees}' are
593 contracted to `@code{as}' and `@code{es}' in Dutch, but both forms will
594 be accepted.
595
596 LilyPond has predefined sets of notenames for various languages.  See
597 section XREF-notelang [FIXME] for details.
598
599
600 The optional octave specification takes the form of a series of
601 single quote (`@code{'}@indexcode{'}') characters or a series of comma
602 (`@code{,}@indexcode{,}') characters.  Each @code{'} raises the pitch by one
603 octave; each @code{,} lowers the pitch by an octave.
604
605 @mudela[fragment,verbatim,center]
606   c' d' e' f' g' a' b' c''
607 @end mudela
608
609 @mudela[fragment,verbatim,center]
610   cis' dis' eis' fis' gis' ais' bis'
611 @end mudela
612
613 @mudela[fragment,verbatim,center]
614   ces' des' es' fes' ges' as' bes'
615 @end mudela
616
617 @mudela[fragment,verbatim,center]
618   cisis' eisis' gisis' aisis' beses'
619 @end mudela
620
621 @mudela[fragment,verbatim,center]
622   ceses' eses' geses' ases' beses'
623 @end mudela
624
625 Whenever a C-sharp is desired,  you must specify a C-sharp.  LilyPond
626 will determine what accidentals to typeset depending on the key and
627 context.  A reminder accidental 
628 @cindex reminder accidental
629  can be
630 forced by adding an exclamation mark `@code{!}' after the pitch.  A
631 cautionary accidental, 
632 @cindex cautionary accidental
633  i.e., an
634 accidental within parentheses can be obtained by adding the question
635 mark `@code{?}@indexcode{?}' after the pitch.
636
637 @mudela[fragment,verbatim,center]
638   cis' d' e' cis'  c'? d' e' c'!
639 @end mudela
640
641
642 @cindex duration
643
644 Durations are entered as their reciprocal values.  For notes longer
645 than a whole note, use identifiers.
646
647 @quotation
648
649 @example 
650 c'\longa c'\breve  
651 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 
652 @end example 
653
654 @end quotation
655
656 @quotation
657
658 @mudela[]
659 \score {
660   \notes \relative c'' {
661     a\longa a\breve  
662     a1 a2 a4 a8 a16 a32 a64 a64 
663   }
664   \paper {
665 %{    \translator {
666       \StaffContext
667         \remove "Clef_engraver";
668         \remove "Staff_symbol_engraver";
669     } %}
670   }
671 }
672 @end mudela
673 @end quotation
674
675 @quotation
676
677 @example 
678 r\longa r\breve  
679 r1 r2 r4 r8 r16 r32 r64 r64 
680 @end example 
681
682 @end quotation
683
684 @quotation
685
686 @mudela[]
687 \score {
688   \notes \relative c'' {
689     r\longa r\breve  
690     r1 r2 r4 r8 r16 r32 r64 r64 
691   }
692   \paper {
693     loose_column_distance = 2.5 * \staffspace;
694     linewidth = -1.0;
695     \translator {
696         \StaffContext
697         \remove "Clef_engraver";
698         \remove "Staff_symbol_engraver";
699         \remove "Bar_engraver";
700     }
701   }
702 }
703 @end mudela
704 @end quotation
705
706 If the duration is omitted then it is set equal to the previous
707 duration.  If there is no previous duration, a quarter note is
708 assumed.  The duration can be followed by a dot (`@code{.}@indexcode{.}')
709 to obtain dotted note lengths.
710
711 @mudela[fragment,verbatim,center]
712   a'4. b'4.
713 @end mudela
714
715 You can alter the length of duration by writing
716 `@code{*}@var{fraction}' after it.  This will not affect the
717 appearance of note heads or rests.
718
719
720 Rests are entered like notes, with note name `@code{r}@indexcode{r}',
721 or `@code{R}@indexcode{R}'.  There is also a note name
722 `@code{s}@indexcode{s}', which produces a space of the specified
723 duration.  `@code{R}' is specifically meant for entering parts: the
724 @code{R} rest can expand to fill a score with rests, or it can be
725 printed as a single multimeasure rest.
726
727 You can control the expansion by setting the property
728 @code{Score.skipBars}. If this is set to true, Lily will not expand
729 empty measures, and the multimeasure rests automatically adds the
730 appropriate number.
731
732
733 @cindex lyrics expressions
734
735 Syllables are entered like notes, with pitches replaced by text.  For
736 example, `@code{Twin-4 kle4 twin-4 kle4}' enters four syllables, each
737 with quarter note duration.  Note that the hyphen has no special
738 meaning for lyrics, and does not introduce special symbols.  See
739 section XREF-modes [FIXME] for a description of what is interpreted as
740 lyrics.
741
742 Spaces can be introduced into a lyric either by using quotes
743 (`@code{"}') or by using an underscore without quotes: `@code{He_could4
744 not4}'.  All unquoted underscores are converted to spaces.  Printing
745 lyrics is discussed in section XREF-lyricprint [FIXME].
746
747
748
749 @cindex properties
750
751 @example
752   \property@keyindex{property}
753     @var{contextname}.@var{propname} =  @var{value}
754 @end example
755
756 Sets the @var{propname} property of the context @var{contextname} to
757 the specified @var{value}.  All three arguments are strings. 
758 Depending on the context, it may be necessary to quote the strings or
759 to leave space on both sides of the dot.
760
761
762
763 @cindex translator switches
764
765 @example
766   \translator@keyindex{translator}
767     @var{contexttype} = @var{name}
768 @end example
769
770 A music expression indicating that the context which is a direct
771 child of the a context of type @var{contexttype} should be shifted to
772 a context of type @var{contexttype} and the specified name.
773
774 Usually this is used to switch staffs in Piano music, e.g.
775
776 @example
777   \translator Staff = top @var{Music}
778 @end example
779
780
781 @cindex output properties
782
783
784 These allow you to tweak what is happening in the back-end
785 directly. If you want to control every detail of the output
786 formatting, this is the feature to use. The downside to this is that
787 you need to know exactly how the backend works. Example:
788
789
790 @mudela[fragment,verbatim]
791 \relative c'' { c4
792         \context Staff \outputproperty
793                 #(make-type-checker 'Note_head)
794                 #'extra-offset = #'(5.0 . 7.5)
795 <c8 e g> }
796 @end mudela
797
798 This selects all note heads occurring at current staff level, and sets
799 the extra-offset of those heads to (5,7.5), shifting them up and
800 right.
801
802 Use of this feature is entirely on your own risk: if you use this, the
803 result will depend very heavily on the implentation of the backend,
804 which we change unscrupulously.
805
806
807
808
809 @cindex commands
810
811 Commands are music expressions that have no duration.   
812
813
814 @example
815
816   @code{\key}@keyindex{key} @var{pitch} @var{type} @code{;}
817 @end example
818
819 Change the key signature.  @var{type} should be
820 @code{\major}@keyindex{major} or @code{\minor}@keyindex{minor} to get
821 @var{pitch}-major or @var{pitch}-minor, respectively.  The second
822 argument is optional; the default is major keys.  The @var{\context}
823 argument can also be given as an integer, which tells the number of
824 semitones that should be added to the pitch given in the subsequent
825 @code{\key}@keyindex{key} commands to get the corresponding major key,
826 e.g., @code{\minor}@keyindex{minor} is defined as 3.  The standard
827 mode names @code{\ionian}@keyindex{ionian},
828 @code{\locrian}@keyindex{locrian}, @code{\aeolian}@keyindex{aeolian},
829 @code{\mixolydian}@keyindex{mixolydian}, @code{\lydian}@keyindex{lydian},
830 @code{\phrygian}@keyindex{phrygian}, and @code{\dorian}@keyindex{dorian}
831 are also defined.
832
833 @example
834
835   @code{\keysignature}@keyindex{keysignature} @var{pitchseq} @code{;}
836 @end example
837
838 Specify an arbitrary key signature.  The pitches from @var{pitch} will
839 be printed in the key signature in the order that they appear on the
840 list.
841
842         
843 @example
844   \mark@keyindex{mark} @var{unsigned};
845   \mark @var{string};
846 @end example
847
848 Prints a mark over or under (depending on the
849 @code{markDirection}@indexcode{markDirection} property) the staff.  You must add
850 @code{Mark_engraver}@indexcode{Mark_engraver} to either the Score or Staff context for
851 this to work.
852
853 @node barlines, , ,  Reference Manual
854
855 @example
856   \bar@keyindex{bar} @var{bartype};
857 @end example
858
859 This is a request to print a special bar symbol. It replaces the 
860 regular bar symbol with a special
861 symbol.  The argument @var{bartype} is a string which specifies the
862 kind of bar to print.  Options are @code{":|"}
863 @cindex "|A@@@code{:|}
864 ,
865 @code{"|:"}
866 @cindex "|B@@@code{|:}
867 , @code{":|:"}
868 @cindex "|C@@@code{:|:}
869 ,
870 @code{"||"}
871 @cindex "|D@@@code{||}
872 , @code{"|."}
873 @cindex "|E@@@code{|.}
874 ,
875 @code{".|"}
876 @cindex "|F@@@code{.|}
877 , and @code{".|."}
878 @cindex "|G@@@code{.|.}
879
880 These produce, respectively, a right repeat, a left repeat, a double
881 repeat, a double bar, a start bar, an end bar, and a thick double
882 bar.  If @var{bartype} is set to @code{"empty"} then nothing is
883 printed, but a line break is allowed at that spot.
884
885 You are encouraged to use @code{\repeat} for repetitions.
886 See section XREF-sec-repeats [FIXME].
887
888  
889
890
891 @example
892
893   \time@keyindex{time} @var{numerator}@code{/}@var{denominator} @code{;}
894 @end example
895
896 Change the time signature.  The default time signature is 4/4. 
897 The time signature is used to generate bar lines.
898
899 @example
900
901   \tempo@keyindex{tempo} @var{duration} = @var{perminute} @code{;}
902 @end example
903
904 Used to specify the tempo.  For example, `@code{\tempo 4 = 76;}'
905 requests output with 76 quarter notes per minute.
906
907 @example
908
909   \partial@keyindex{partial} @var{duration} @code{;}
910 @end example
911
912 @cindex anacrusis
913
914 @cindex upstep
915
916 This creates an incomplete measure (anacrusis, upbeat) at the start of 
917 the music, e.g., `@code{\partial 8*2;}' creates a starting measure 
918 lasting two eighth notes.
919
920 @example
921
922   @code{|}@indexcode{|}
923 @cindex bar check
924
925 @end example
926
927 @cindex shorten measures
928
929 @cindex upstep
930
931 `@code{|}' is a bar check.  Whenever a bar check is encountered during
932 interpretation, a warning message is issued if it doesn't fall at a
933 measure boundary.  This can help you finding errors in the input. 
934 The beginning of the measure will be relocated, so this can also
935 be used to shorten measures.
936
937
938 @example
939
940   \penalty@keyindex{penalty} @var{int} @code{;}
941 @end example
942
943 Discourage or encourage line breaks.  See identifiers
944 @code{\break}@keyindex{break} and @code{\nobreak}@keyindex{nobreak} in
945 section [on identifiers] [FIXME].
946
947 @example
948
949   \clef@keyindex{clef} @var{clefname} @code{;}
950 @end example
951
952 Music expression that sets the current clef.  The argument is a
953 string which specifies the name of the clef.  Several clef names are
954 supported.  If `@code{_8}' or `@code{^8}' is added to the end of a clef
955 name, then the clef lowered or raised an octave will be generated. 
956 Here are the supported clef names with middle C shown in each
957 clef:
958
959 @quotation
960
961 @mudela[]
962 \score {
963   \notes {
964     \cadenzaOn
965     %\property Voice.textStyle = typewriter
966     \clef subbass;     c'4-"\kern -5mm subbass" 
967     \clef bass;        c'4^"\kern -2mm bass"
968     \clef baritone;    c'4_"\kern -5mm baritone"
969     \clef varbaritone; c'4^"\kern -6mm varbaritone"
970     \clef tenor;       c'4_"\kern -3mm tenor"
971     \clef "G_8";       c'4^"\kern -2mm G\\_8" 
972   }  
973   \paper {
974     linewidth = -1.0;
975   }
976 }
977 @end mudela
978 @end quotation
979
980 @quotation
981
982 @mudela[]
983 \score {
984   \notes {
985         \cadenzaOn
986     \clef alto;         c'4_"\kern -2mm alto"
987     \clef mezzosoprano; c'4^"\kern -9mm mezzosoprano"
988     \clef soprano;      c'4_"\kern -6mm soprano"
989     \clef treble;       c'4^"\kern -4mm treble"
990     \clef french;       c'4_"\kern -4mm french"
991   }
992   \paper {
993     linewidth = 4.5 \in;
994   }
995 }
996 @end mudela
997 @end quotation
998
999 The three clef symbols can also be obtained using the names `@code{G}', 
1000 `@code{C}' or `@code{F}', optionally followed by an integer which 
1001 indicates at which note line the clef is located. An as example, the 
1002 @code{mezzosoprano} clef can also be given as `@code{C2}'.
1003
1004 @example
1005
1006   \skip@keyindex{skip} @var{duration} @code{;}
1007 @end example
1008
1009 Skips the amount of time specified by @var{duration}.  If no other
1010 music is played, a gap will be left for the skipped time with no
1011 notes printed.  It works in Note Mode or Lyrics Mode.  In Note mode,
1012 this has the same effect as the space rest `@code{s}'.
1013
1014
1015 @cindex beams
1016
1017 @node Manual beams, , ,  Reference Manual
1018
1019 A beam is specified by surrounding the beamed notes with brackets
1020 `@code{[}@indexcode{[}' and `@code{]}@indexcode{]}'.  
1021
1022 @mudela[fragment,verbatim,center]
1023   [a'8 a'] [a'16 a' a' a']
1024 @end mudela
1025
1026 Some more elaborate constructions:
1027
1028 @mudela[fragment,verbatim,center]
1029   [a'16 <a' c''> c'' <a' c''>]
1030   \times 2/3 { [e'8 f' g'] }
1031 @end mudela
1032
1033 Beaming can be generated automatically; see section XREF-autobeam [FIXME].
1034
1035 [OUTDATED, FIXME]
1036
1037 To place tremolo marks between notes, use @code{\repeat} with tremolo
1038 style.
1039 @cindex tremolo beams
1040   To create tremolo beams on a single note, simply attach
1041 `@code{:}@var{length}' to the note itself (see also section
1042 XREF-tremolo [FIXME]).
1043   
1044
1045 @mudela[fragment,verbatim,center]
1046   \repeat "tremolo" 8 { c16 d16 }
1047   \repeat "tremolo" 4 { c16 d16 }    
1048 @end mudela
1049
1050 @mudela[fragment,verbatim,center]
1051   c'4:32
1052 @end mudela
1053
1054
1055 @cindex --@@@code{-}@code{-}
1056
1057 @indexcode{__}
1058
1059 @cindex extender
1060
1061 @cindex hyphen
1062
1063 The syntax for an extender mark is `@code{__}'.  This syntax can only
1064 be used within lyrics mode.  The syntax for a spanning hyphen (i.e.,
1065 a hyphen that will be printed between two lyric syllables) is
1066 `@code{-}@code{-}'.
1067
1068
1069 @cindex ties
1070
1071 A tie connects two adjacent note heads of the same pitch.  When used
1072 with chords, it connects all of the note heads whose pitches match.
1073 Ties are indicated using the tilde symbol `@code{~}@indexcode{~}'.
1074 If you try to tie together chords which have no common pitches, a
1075 warning message will appear and no ties will be created.
1076
1077 @mudela[fragment,verbatim,center]
1078   e' ~ e' <c' e' g'> ~ <c' e' g'>
1079 @end mudela
1080
1081
1082
1083 [TODO: explain Requests]
1084
1085
1086 @cindex articulations
1087
1088 @cindex scripts
1089
1090 @cindex ornaments
1091
1092 A variety of symbols can appear above and below notes to indicate
1093 different characteristics of the performance.  These symbols can be
1094 added to a note with `@var{note}@code{-\}@var{name}'.  Numerous symbols
1095 are defined in @file{script.ly} and @file{script.scm}.  Symbols can be
1096 forced to appear above or below the note by writing
1097 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1098 respectively.  Here is a chart showing symbols above notes, with the
1099 name of the corresponding symbol appearing underneath.
1100
1101 @mudela[]
1102
1103   \score {
1104     < \notes {
1105         c''-\accent      c''-\marcato      c''-\staccatissimo c''-\fermata 
1106         c''-\stopped     c''-\staccato     c''-\tenuto        c''-\upbow
1107         c''-\downbow     c''^\lheel        c''-\rheel         c''^\ltoe
1108         c''-\rtoe        c''-\turn         c''-\open          c''-\flageolet
1109         c''-\reverseturn c''-\trill        c''-\prall         c''-\mordent
1110         c''-\prallprall  c''-\prallmordent c''-\upprall       c''-\downprall
1111         c''-\thumb       c''-\segno        c''-\coda
1112       }
1113       \context Lyrics \lyrics {  
1114         accent__      marcato__      staccatissimo__ fermata
1115         stopped__     staccato__     tenuto__        upbow
1116         downbow__     lheel__        rheel__         ltoe
1117         rtoe__        turn__         open__          flageolet
1118         reverseturn__ trill__        prall__         mordent
1119         prallprall__  prallmordent__ uprall__        downprall
1120         thumb__       segno__        coda
1121       }
1122     >
1123     \paper {
1124       linewidth = 5.875\in;          
1125       indent    = 0.0;
1126     }
1127   }
1128
1129 @end mudela
1130
1131 In addition, it is possible to place arbitrary strings of text or
1132 @TeX{} above or below notes by using a string instead of an
1133 identifier: `@code{c^"text"}'.  Fingerings 
1134 @cindex fingering
1135  can be
1136 placed by simply using digits.  All of these note ornaments appear in
1137 the printed output but have no effect on the MIDI rendering of the
1138 music.
1139
1140 To save typing, fingering instructions (digits 0 to 9 are
1141 supported) and single characters shorthands exist for a few
1142 common symbols
1143
1144 @mudela[]
1145
1146   \score {
1147     \notes {
1148       \property Voice.textStyle = typewriter
1149       c''4-._"c-."      s4
1150       c''4--_"c-{}-"    s4
1151       c''4-+_"c-+"      s4
1152       c''4-|_"c-|"      s4
1153       c''4->_"c->"      s4
1154       c''4-^_"c-\\^{ }" s4
1155       c''4-1_"c-1"      s4
1156       c''4-2_"c-2"      s4
1157       c''4-3_"c-3"      s4
1158       c''4-4_"c-4"      s4
1159     }
1160     \paper {
1161       linewidth = 5.875 \in;
1162       indent    = 0.0;
1163     }
1164   }
1165
1166 @end mudela
1167
1168 Dynamic marks are specified by using an identifier after a note:
1169 `@code{c4-\ff}' (the dash is optional for dynamics: `@code{c4 \ff})'.  
1170 The available dynamic marks are:
1171 @code{\ppp}@keyindex{ppp},
1172 @code{\pp}@keyindex{pp}, @code{\p}@keyindex{p}, @code{\mp}@keyindex{mp},
1173 @code{\mf}@keyindex{mf}, @code{\f}@keyindex{f}, @code{\ff}@keyindex{ff},
1174 @code{\fff}@keyindex{fff}, @code{\fff}@keyindex{ffff},
1175 @code{\fp}@keyindex{fp}, @code{\sf}@keyindex{sf},
1176 @code{\sff}@keyindex{sff}, @code{\sp}@keyindex{sp},
1177 @code{\spp}@keyindex{spp}, @code{\sfz}@keyindex{sfz}, and
1178 @code{\rfz}@keyindex{rfz}.
1179
1180
1181 @example
1182
1183   \textscript@keyindex{textscript} @var{text} @var{style}
1184 @end example
1185
1186 Defines a text to be printed over or under a note.  @var{style} is a
1187 string that may be one of @code{roman}, @code{italic}, @code{typewriter}, 
1188 @code{bold}, @code{Large}, @code{large}, @code{dynamic} or @code{finger}.
1189
1190 You can attach a general textscript request using this syntax:
1191
1192 @quotation
1193
1194 @example 
1195 c4-\textscript "6" "finger"
1196 c4-\textscript "foo" "normal" 
1197 @end example 
1198
1199 @end quotation
1200
1201 This is equivalent to `@code{c4-6 c4-"foo"}'.  
1202
1203
1204 @cindex scripts
1205
1206 @example
1207
1208   \script@keyindex{script} @var{alias}
1209 @end example
1210
1211 Prints a symbol above or below a note.  The argument is a string
1212 which points into the script-alias table defined in @file{script.scm}.
1213 The scheme definitions specify whether the symbol follows notes into
1214 the staff, dependence of symbol placement on staff direction, and a
1215 priority for placing several symbols over one note.  Usually the
1216 @code{\script}@keyindex{script} keyword is not used directly.  Various
1217 helpful identifier definitions appear in @file{script.ly}.
1218
1219
1220 @cindex slur
1221
1222 Slurs connects chords and try to avoid crossing stems.  A slur is
1223 started with `@code{(}' and stopped with `@code{)}'.  The
1224 starting `@code{(}' appears to the right of the first note in
1225 the slur.  The terminal `@code{)}' appears to the left of the
1226 first note in the slur.  This makes it possible to put a note in
1227 slurs from both sides:
1228
1229 @mudela[fragment,verbatim,center]
1230   f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1231 @end mudela
1232
1233
1234 @cindex crescendo
1235
1236 A crescendo mark is started with @code{\cr}@keyindex{cr} and terminated
1237 with @code{\rc}@keyindex{rc}.  A decrescendo mark is started with
1238 @code{\decr}@keyindex{decr} and terminated with
1239 @code{\rced}@keyindex{rced}.  There are also shorthands for these
1240 marks.  A crescendo can be started with @code{\<}@keyindex{<} and a
1241 decrescendo can be started with @code{\>}@keyindex{>}.  Either one can
1242 be terminated with @code{\!}@keyindex{"!}.  Note that @code{\!}
1243 must go before the last note of the dynamic mark whereas @code{\rc}
1244 and @code{\rced} go after the last note.  Because these marks are
1245 bound to notes, if you want to get several marks during one note, you
1246 must use spacer notes.
1247
1248 @mudela[fragment,verbatim,center]
1249   c'' \< \! c''   d'' \decr e'' \rced 
1250   < f''1 { s4 \< \! s2 \> \! s4 } >
1251 @end mudela
1252
1253
1254 @example
1255
1256   \spanrequest@keyindex{spanrequest} @var{startstop} @var{type}
1257 @end example
1258
1259 Define a spanning request. The @var{startstop} parameter is either -1
1260 (@code{\start}@keyindex{start}) or 1 (@code{\stop}@keyindex{stop}) and
1261 @var{type} is a string that describes what should be started.
1262 Supported types are @code{crescendo}, @code{decrescendo},
1263 @code{beam}, @code{slur}.  This is an internal command.  Users should
1264 use the shorthands which are defined in the initialization file
1265 @file{spanners.ly}.
1266
1267 You can attach a (general) span request to a note using
1268
1269 @mudela[fragment,verbatim,center]
1270   c'4-\spanrequest \start "slur"
1271   c'4-\spanrequest \stop "slur"
1272 @end mudela
1273
1274 The slur syntax with parentheses is a shorthand for this.
1275
1276
1277
1278 @cindex tremolo marks
1279
1280 @node stem tremolo, , ,  Reference Manual
1281
1282 Tremolo marks can be printed on a single note by adding
1283 `@code{:}[@var{length}]' after the note.  The length must be at
1284 least 8.  A @var{length} value of 8 gives one line across
1285 the note stem.  If the length is omitted, then the last value is
1286 used, or the value of the @code{tremoloFlags}@indexcode{tremoloFlags} property if there was
1287 no last value.
1288
1289 @mudela[verbatim,fragment,center]
1290   c'2:8 c':32
1291 @end mudela
1292
1293
1294
1295 @node Compound music expressions, , ,  Reference Manual
1296 @section Compound music expressions
1297
1298 @cindex compound music expressions
1299
1300 Music expressions are compound data structures.  You can nest music
1301 expressions any way you like.  This simple example shows how three
1302 chords can be expressed in two different ways:
1303
1304 @mudela[fragment,verbatim,center]
1305   \notes \context Staff {
1306     \cadenzaOn
1307     <a c'> <b  d' > <c' e'>
1308     < { a b  c' } { c' d' e' } >
1309   }
1310 @end mudela
1311
1312 @cindex context selection
1313 @c @keyindex{context}
1314
1315 @example
1316   \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
1317 @end example
1318
1319 Interpret @var{musicexpr} within a context of type @var{contexttype}. 
1320 If the context does not exist, it will be created.  The new context
1321 can optionally be given a name.  See
1322 section XREF-contextselection [FIXME] and XREF-contextdefs [FIXME] for more
1323 information on interpretation contexts.
1324
1325
1326
1327 @cindex input modes
1328
1329 @cindex mode switch
1330
1331 Mode switching keywords form compound music expressions: @code{\notes}
1332 @keyindex{notes} @var{musicexpr}, @code{\chords} @keyindex{chords}
1333 @var{musicexpr}, and @code{\lyrics} @keyindex{lyrics} @var{musicexpr}. 
1334 These expressions do not add anything to the meaning of their
1335 arguments.  They are just a way to indicate that the arguments should
1336 be parsed in indicated mode.  See section XREF-modes [FIXME] for more
1337 information on modes.
1338
1339 More information on context selection can be found in
1340 section XREF-contextselection [FIXME].
1341
1342
1343
1344 @cindex sequential music
1345
1346
1347
1348 @example
1349
1350   \sequential@keyindex{sequential}
1351     @code{@{} @var{musicexprlist} @code{@}}
1352 @end example
1353
1354 This means that list should be played or written in sequence, i.e.,
1355 the second after the first, the third after the second.  The duration
1356 of sequential music is the the sum of the durations of the elements. 
1357 There is a shorthand, which leaves out the keyword:
1358
1359 @example
1360
1361   @code{@{} @var{musicexprlist} @code{@}}
1362 @end example
1363
1364
1365
1366 @cindex simultaneous music
1367
1368 @indexcode{<}
1369 @indexcode{>}
1370
1371 @example
1372
1373   \simultaneous@keyindex{simultaneous}
1374     @code{@{} @var{musicexprlist} @code{@}}
1375 @end example
1376
1377 It constructs a music expression where all of its arguments start at
1378 the same moment.  The duration is the maximum of the durations of the
1379 elements.  The following shorthand is a common idiom:
1380
1381 @example
1382
1383   @code{<} @var{musicexprlist} @code{>}
1384 @end example
1385
1386 If you try to use a chord as the first thing in your score, you might
1387 get multiple staffs instead of a chord.
1388
1389 @mudela[verbatim,center]
1390   \score {
1391     \notes <c''4 e''>
1392     \paper {
1393       linewidth = -1.;
1394     }
1395   }
1396 @end mudela
1397
1398 This happens because the chord is interpreted by a score context.
1399 Each time a note is encountered a default Voice context (along with a
1400 Staff context) is created.  The solution is to explicitly instantiate
1401 a Voice context:
1402
1403 @mudela[verbatim,center]
1404   \score {
1405     \notes\context Voice <c''4 e''>
1406     \paper {
1407       linewidth = -1.;
1408     }
1409   }
1410 @end mudela
1411
1412
1413
1414 @cindex relative pitch specification
1415
1416 @node relative, , , Reference Manual
1417
1418 It is easy to get confused by octave changing marks and accidentally
1419 putting a pitch in the wrong octave.  A much better way of entering a
1420 note's octave is `the relative octave' mode.
1421
1422 @example
1423
1424   \relative@keyindex{relative} @var{startpitch} @var{musicexpr}
1425 @end example
1426
1427 The octave of notes that appear in @var{musicexpr} are calculated as
1428 follows: If no octave changing marks are used, the basic interval
1429 between this and the last note is always taken to be a fourth or
1430 less.@footnote{The interval is determined without regarding
1431 accidentals.  A @code{fisis} following a @code{ceses} will be put above
1432 the @code{ceses}.}  The octave changing marks `@code{'}' and `@code{,}'
1433 can then be added to raise or lower the pitch by an extra octave. 
1434 Upon entering relative mode, an absolute starting pitch must be
1435 specified that will act as the predecessor of the first note of
1436 @var{musicexpr}.
1437
1438 Entering scales is straightforward in relative mode.
1439
1440 @mudela[fragment,verbatim,center]
1441   \relative c' {
1442     c d e f g a b c c,
1443   }
1444 @end mudela
1445
1446 And octave changing marks are used for intervals greater than a fourth.
1447
1448 @mudela[fragment,verbatim,center]
1449   \relative c'' {
1450     c g c f, c' a, e'' }
1451 @end mudela
1452
1453 If the preceding item is a chord, the first note of the chord is used
1454 to determine the first note of the next chord.  But other notes
1455 within the second chord are determined by looking at the immediately
1456 preceding note.
1457
1458 @mudela[fragment,verbatim,center]
1459   \relative c' {
1460     c <c e g> 
1461     <c' e g>
1462     <c, e' g>
1463   }
1464 @end mudela 
1465
1466 The pitch after the @code{\relative} contains a notename.  To parse
1467 the pitch as a notename, you have to be in note mode, so there must
1468 be a surrounding @code{\notes}@keyindex{notes} keyword (which is not
1469 shown here).
1470
1471 The relative conversion will not affect @code{\transpose} or
1472 @code{\relative} sections in its argument.  If you want to use
1473 relative within transposed music, you must place an additional
1474 @code{\relative} inside the @code{\transpose}.
1475
1476 It is strongly recommended to use relative pitch mode: less work,
1477 less error-prone, and more readable.
1478
1479
1480
1481 Chord names are a way to generate simultaneous music expressions that
1482 correspond with traditional chord names.  It can only be used in
1483 Chord mode (see section XREF-modes [FIXME]).
1484
1485 @example
1486
1487   @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1488 @end example
1489
1490 @var{tonic} should be the tonic note of the chord, and @var{duration}
1491 is the chord duration in the usual notation.  There are two kinds of
1492 modifiers.  One type is @emph{chord additions}, which are obtained by
1493 listing intervals separated by dots.  An interval is written by its
1494 number with an optional `@code{+}' or `@code{-}' to indicate raising or
1495 lowering by half a step.  Chord additions has two effects: It adds
1496 the specified interval and all lower odd numbered intervals to the
1497 chord, and it may lower or raise the specified interval.  Intervals
1498 must be separated by a dot (`@code{.}').
1499
1500 @quotation
1501
1502 @mudela[fragment,verbatim]
1503 \transpose c'' {
1504   \chords {
1505     c1  c:3-       c:7     c:8
1506     c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1507   }
1508 }
1509
1510 @end mudela
1511 @end quotation
1512
1513 The second type of modifier that may appear after the `@code{:}' is a
1514 named modifier.  Named modifiers are listed in the file
1515 @file{chord-modifiers.ly}.  The available modifiers are `@code{m}' and
1516 `@code{min}' which lower the 3rd half a step, `@code{aug}@indexcode{aug}' which
1517 raises the 5th, `@code{dim}@indexcode{dim}' which lowers the 5th,
1518 `@code{maj}@indexcode{maj}' which adds a raised 7th, and `@code{sus}@indexcode{sus}'
1519 which replaces the 5th with a 4th.
1520
1521 @quotation
1522
1523 @mudela[fragment,verbatim]
1524 \transpose c'' {
1525   \chords {
1526     c1:m c:min7 c:maj c:aug c:dim c:sus
1527   }
1528 }
1529
1530 @end mudela
1531 @end quotation
1532  
1533
1534 Chord subtractions are used to eliminate notes from a chord.  The
1535 notes to be subtracted are listed after a `@code{^}' character,
1536 separated by dots.
1537
1538 @mudela[fragment,verbatim,center]
1539   \transpose c'' {
1540     \chords {
1541       c1^3 c:7^5.3 c:8^7
1542     }
1543   }
1544 @end mudela 
1545
1546 Chord inversions can be specified by appending `@code{/}@indexcode{/}' and
1547 the name of a single note to a chord.  This has the effect of
1548 lowering the specified note by an octave so it becomes the lowest
1549 note in the chord.  If the specified note is not in the chord, a
1550 warning will be printed.
1551
1552 @mudela[fragment,verbatim,center]
1553   \transpose c''' {
1554     \chords {
1555       c1 c/e c/g c:7/e
1556     }
1557   }
1558
1559 @end mudela 
1560
1561 Bass notes can be added by `@code{/+}@indexcode{/+}' and
1562 the name of a single note to a chord.  This has the effect of
1563 adding the specified note to the chord, lowered by an octave,
1564 so it becomes the lowest note in the chord.
1565
1566 @mudela[fragment,verbatim,center]
1567   \transpose c''' {
1568     \chords {
1569       c1 c/+c c/+g c:7/+b
1570     }
1571   }
1572
1573 @end mudela 
1574
1575 Throughout these examples, chords have been shifted around the staff
1576 using @code{\transpose}.
1577
1578 You should not combine @code{\relative} with named chords. 
1579
1580
1581
1582 @cindex tuplets
1583
1584 Tuplets are made out of a music expression by multiplying their
1585 duration with a fraction.
1586
1587 @example
1588
1589   \times@keyindex{times} @var{fraction} @var{musicexpr}
1590 @end example
1591
1592 The duration of @var{musicexpr} will be multiplied by the fraction. 
1593 In print, the fraction's denominator will be printed over the notes,
1594 optionally with a bracket.  The most common tuplet is the triplet in
1595 which 3 notes have the length of 2, so the notes are 2/3 of
1596 their written length:
1597
1598 @mudela[fragment,verbatim,center]
1599   g'4 \times 2/3 {c'4 c' c'} d'4 d'4
1600 @end mudela
1601
1602
1603
1604 @cindex grace notes
1605
1606 @example
1607
1608   \grace@keyindex{grace} @var{musicexpr}
1609 @end example
1610
1611 A grace note expression has duration 0; the next real note is
1612 assumed to be the main note.
1613
1614 You cannot have the grace note after the main note, in terms of
1615 duration, and main notes, but you can typeset the grace notes to the
1616 right of the main note using the property
1617 @code{graceAlignPosition}@indexcode{graceAlignPosition}.
1618
1619 When grace music is interpreted, a score-within-a-score is set up:
1620 @var{musicexpr} has its own time bookkeeping, and you could (for
1621 example) have a separate time signature within grace notes.  While in
1622 this score-within-a-score, you can create notes, beams, slurs, etc.
1623 Unbeamed eighth notes and shorter by default have a slash through the
1624 stem.  This behavior can be controlled with the
1625 @code{flagStyle}@indexcode{flagStyle} property.
1626
1627 @quotation
1628
1629 @mudela[fragment,verbatim]
1630 \relative c'' {
1631   \grace c8 c4 \grace { [c16 c16] } c4
1632   \grace { \property Grace.flagStyle = "" c16 } c4
1633 }
1634
1635 @end mudela
1636 @end quotation
1637
1638 At present, nesting @code{\grace}@keyindex{grace} notes, e.g.
1639
1640 @example
1641
1642   @code{\grace @{ \grace c32 c16 @} c4}
1643 @end example
1644
1645 may result in run-time errors of LilyPond.  Since the meaning of such
1646 a construct is unclear, we don't consider this a loss.  Similarly,
1647 juxtaposing two @code{\grace} sections is syntactically valid, but
1648 makes no sense and may cause runtime errors.
1649
1650 Ending a staff or score with grace notes may also generate a run-time
1651 error, since there will be no main note to attach the grace notes to.
1652
1653
1654
1655 @cindex repeats
1656
1657 @node Repeats, , , Reference Manual
1658
1659 In order to specify repeats, use the @code{\repeat}@keyindex{repeat}
1660 keyword.  Since repeats look and sound differently when played or
1661 printed, there are a few different variants of repeats.
1662
1663 @table @samp
1664   @item unfolded  
1665     Repeated music is fully written (played) out.  Useful for MIDI
1666     output.
1667
1668   @item volta  
1669     This is the normal notation: Repeats are not written out, but
1670     alternative endings (voltas) are printed, left to right.
1671
1672   @item folded  
1673     Alternative endings are written stacked, which is useful for
1674     lyrics.
1675 @end table  
1676
1677 The syntax for repeats is
1678
1679 @example
1680
1681   \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1682 @end example
1683
1684 If you have alternative endings, you may add
1685
1686 @example
1687
1688   \alternative@keyindex{alternative}
1689     @code{@{} @var{alternative1}
1690             @var{alternative2}
1691             @var{alternative3} @dots{} @code{@}}
1692 @end example
1693
1694 where each @var{alternative} is a Music expression.
1695
1696 Normal notation repeats are used like this:
1697
1698 @quotation
1699
1700 @mudela[fragment,verbatim]
1701   c'1
1702   \repeat volta 2 { c'4 d' e' f' }
1703   \repeat volta 2 { f' e' d' c' }
1704
1705 @end mudela
1706 @end quotation
1707
1708 With alternative endings:
1709
1710 @quotation
1711
1712 @mudela[fragment,verbatim]
1713   c'1
1714   \repeat volta 2 {c'4 d' e' f'} 
1715   \alternative { {d'2 d'} {f' f} }
1716
1717 @end mudela
1718 @end quotation
1719
1720 Folded repeats look like this:@footnote{Folded repeats offer little
1721 more over simultaneous music.  However, it is to be expected that
1722 more functionality -- especially for the MIDI backend -- will be
1723 implemented.}
1724
1725 @quotation
1726
1727 @mudela[fragment,verbatim]
1728   c'1
1729   \repeat fold 2 {c'4 d' e' f'} 
1730   \alternative { {d'2 d'} {f' f} }
1731
1732 @end mudela
1733 @end quotation
1734
1735 @quotation
1736
1737 @mudela[fragment,verbatim]
1738 \context Staff {
1739   \relative c' {
1740     \partial 4;
1741     \repeat volta 2 { e | c2 d2 | e2 f2 | }
1742     \alternative { { g4 g g } { a | a a a a | b1 } }
1743   }
1744 }
1745
1746 @end mudela
1747 @end quotation
1748
1749 If you don't give enough alternatives for all of the repeats, then
1750 the first alternative is assumed to be repeated often enough to equal
1751 the specified number of repeats.
1752
1753 @quotation
1754
1755 @mudela[fragment,verbatim]
1756 \context Staff {
1757   \relative c' {
1758     \repeat volta 3 { \partial 4; e | c2 d2 | e2 f2 | }
1759     \alternative { { g4 g g }
1760                    {\partial 1; e4 e e } 
1761                    {\partial 1; a a a a | b1 } }
1762   }
1763 }
1764
1765 @end mudela
1766 @end quotation
1767
1768 It is possible to nest @code{\repeat}.  This is not entirely
1769 supported: the notes will come be in the right places, but the repeat
1770 bars will not.
1771
1772
1773
1774 @cindex transposition of pitches
1775
1776 @node transpose, , , Reference Manual
1777
1778 A music expression can be transposed with
1779 @code{\transpose}@keyindex{transpose}.  The syntax is
1780
1781 @example
1782
1783   \transpose @var{pitch} @var{musicexpr}
1784 @end example
1785
1786 This means that middle C in @var{musicexpr} is transposed to
1787 @var{pitch}.
1788
1789 @code{\transpose} distinguishes between enharmonic pitches: both
1790 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
1791 a tone.  The first version will print sharps and the second version
1792 will print flats.
1793
1794 @quotation
1795
1796 @mudela[fragment,verbatim]
1797 \context Staff {
1798   \clef "F";
1799   { \key e \major; c d e f }
1800   \clef "G";
1801   \transpose des'' { \key e \major; c d e f }
1802   \transpose cis'' { \key e \major; c d e f }
1803 }
1804
1805 @end mudela
1806 @end quotation
1807
1808 If you want to use both @code{\transpose} and @code{\relative}, then
1809 you must use @code{\transpose} first.  @code{\relative} will have no
1810 effect music that appears inside a @code{\transpose}.
1811
1812
1813
1814 @cindex automatic lyric durations
1815
1816 If you have lyrics that are set to a melody, you can import the
1817 rhythm of that melody into the lyrics using @code{\addlyrics}.
1818 @keyindex{addlyrics} The syntax for this is
1819
1820 @example
1821
1822   \addlyrics @var{musicexpr1 musicexpr2}
1823 @end example
1824
1825 This means that both @var{musicexpr1} and @var{musicexpr2} are
1826 interpreted, but that every non-command atomic music expression
1827 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1828 of @var{musicexpr1}.
1829
1830 If the property @code{automaticMelismata}@indexcode{automaticMelismata} is set in the
1831 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1832 notes.
1833
1834 @quotation
1835
1836 @mudela[verbatim,fragment]
1837 \addlyrics
1838 \transpose c'' {
1839   \property Voice.automaticMelismata = ##t
1840   c8 () cis d8. e16 f2
1841 }
1842 \context Lyrics \lyrics {
1843  do4 re mi fa }
1844
1845 @end mudela
1846 @end quotation
1847
1848 You should use a single rhythm melody, and single rhythm lyrics (a
1849 constant duration is the obvious choice).  If you do not, you will get
1850 undesired effects when using multiple stanzas:
1851
1852 @quotation
1853
1854 @mudela[verbatim,fragment]
1855 \addlyrics
1856 \transpose c'' {
1857   c8 () cis d8. e16 f2
1858 }
1859 \context Lyrics \lyrics
1860 < { do4 re mi fa }
1861   { do8 re mi fa } >
1862
1863 @end mudela
1864 @end quotation
1865
1866 It is valid (but probably not very useful) to use notes instead of
1867 lyrics for @var{musicexpr2}.
1868
1869
1870
1871
1872 @node Ambiguities, , ,  Reference Manual
1873 @section Ambiguities
1874
1875 @cindex ambiguities
1876
1877 The grammar contains a number of ambiguities.@footnote{The authors
1878 hope to resolve them at a later time.}
1879
1880 @itemize @bullet
1881   @item  The assignment
1882
1883          @example 
1884 foo = bar 
1885 @end example 
1886
1887        can be interpreted as making a string identifier @code{\foo}
1888        containing @code{"bar"}, or a music identifier @code{\foo}
1889        containing the syllable `bar'.
1890
1891   @item  The assignment
1892
1893          @example 
1894 foo = -6 
1895 @end example 
1896
1897        can be interpreted as making an integer identifier
1898        containing -6, or a Request identifier containing the
1899        fingering `6' (with neutral direction).
1900
1901   @item  If you do a nested repeat like
1902
1903        @quotation
1904
1905 @example 
1906 \repeat @dots{}
1907 \repeat @dots{}
1908 \alternative 
1909 @end example 
1910
1911        @end quotation
1912
1913        then it is ambiguous to which @code{\repeat} the
1914        @code{\alternative} belongs.  This is the classic if-then-else
1915        dilemma.  It may be solved by using braces.
1916
1917   @item  (an as yet unidentified ambiguity :-)
1918 @end itemize
1919
1920
1921
1922 @node Notation conversion specifics, , ,  Reference Manual
1923 @section Notation conversion specifics
1924
1925
1926
1927 @cindex automatic beam generation
1928
1929 @node autobeam, , ,  Reference Manual
1930
1931 By default, LilyPond will generate beams automatically.  This feature
1932 can be disabled by setting the @code{Voice.noAutoBeaming}@indexcode{Voice.noAutoBeaming}
1933 property to 1.  It can be overridden for specific cases by
1934 specifying explicit beams as described in
1935 section XREF-manualbeam [FIXME].
1936
1937 A large number of Voice properties are used to decide how to generate
1938 beams.  Their default values appear in @file{auto-beam-settings.ly}.
1939 In general, beams can begin anywhere, but their ending location is
1940 significant.  Beams can end on a beat, or at durations specified by
1941 the @code{Voice.beamAutoEnd}@indexcode{Voice.beamAutoEnd} property.  To end beams every
1942 quarter note, for example, you could set
1943 @code{Voice.beamAutoEnd}@indexcode{Voice.beamAutoEnd} equal to `@code{"1/4"}'.  To end beams
1944 at every three eighth notes you would set it to `@code{"3/8"}'.  The
1945 same syntax can be used to specify beam starting points using
1946 @code{Voice.beamAutoBegin}@indexcode{Voice.beamAutoBegin}.
1947
1948 To allow different settings for different time signatures, these
1949 property names can start with `@code{time}@var{N}@code{_}@var{M}' to
1950 restrict the definition to `@var{N}@code{/}@var{M}' time.  For example,
1951 to specify beams ending only for 6/8 time you would use the
1952 property @code{Voice.time6_8beamAutoEnd}.  To allow different endings
1953 for notes of different durations, the duration can be tacked onto the
1954 end of the property.  To specify beam endings for beams that contain
1955 32nd notes, you would use @code{Voice.beamAutoEnd_32}.
1956
1957
1958
1959 @cindex chord names
1960
1961 @cindex chords
1962
1963 @cindex printing!chord names
1964
1965 For displaying printed chord names, use the @code{ChordNames}@indexcode{ChordNames}
1966 and @code{ChordNameVoice}@indexcode{ChordNameVoice} contexts.  The chords may be entered
1967 either using the notation described above, or directly using
1968 simultaneous music.
1969
1970 @quotation
1971
1972 @mudela[fragment,verbatim]
1973 <
1974   \context ChordNames {
1975     \chords{a b c} \notes{<d f g>  <e g b>}
1976   }
1977   \context Staff \notes {
1978     a b c' d' e'
1979   }
1980 >
1981
1982 @end mudela
1983 @end quotation
1984
1985 LilyPond examines chords specified as lists of notes to determine a
1986 name to give the chord.  By default, LilyPond will not try to
1987 identify chord inversions:
1988
1989 @mudela[fragment,verbatim,center]
1990   <
1991     \context ChordNameVoice \notes {
1992       <e'1 g' c''>
1993     }
1994     \context Thread \notes {
1995       <e'1 g' c''>
1996     }
1997   >
1998 @end mudela
1999
2000 If you want inversions to be recognized, you must set the property
2001 @code{ChordNames.chordInversion}@indexcode{ChordNames.chordInversion}:
2002
2003 @mudela[fragment,verbatim,center]
2004   <
2005     \property Score.chordInversion = ##t
2006     \context ChordNameVoice \notes {
2007       <e'1 g' c''>
2008     }
2009     \context Thread \notes {
2010       <e'1 g' c''>
2011     }
2012   >
2013 @end mudela
2014
2015
2016
2017 @cindex lyrics
2018
2019 @cindex printing!lyrics
2020
2021 @node lyricprint, , ,  Reference Manual
2022
2023 Lyric syllables must be interpreted within a @code{Lyrics} context
2024
2025 @cindex context!Lyrics
2026  for printing them.
2027
2028 Here is a full example: 
2029
2030 @quotation
2031
2032 @mudela[verbatim]
2033 \score {
2034   <
2035     \notes \transpose c'' {
2036       c d e c | c d e c |
2037       e f g2 | e4 f g2 \bar "|.";
2038     }
2039     \context Lyrics \lyrics { 
2040       Va-4 der Ja- cob Va- der Ja- cob
2041       Slaapt gij nog?2 Slaapt4 gij nog?2
2042     }
2043   >
2044 }
2045
2046 @end mudela
2047 @end quotation
2048
2049 You may want a continuous line after the syllables to show melismata. 
2050 To achieve this effect, add a `@code{__}' lyric as a separate word
2051 after the lyric to be extended.  This will create an extender, a line
2052 that extends over the entire duration of the lyric.  This line will
2053 run all the way to the start of the next lyric, so you may want to
2054 shorten it by using a blank lyric (using `@code{_}').
2055
2056 @quotation
2057
2058 @mudela[verbatim]
2059 \score {
2060   <
2061     \notes \relative c'' {
2062       a4 () b () c () d | c () d () b () a | c () d () b () a
2063     }
2064     \context Lyrics \lyrics {
2065       foo1 __ | bar2. __ _4 | baz1 __
2066     }
2067   >
2068 }
2069
2070 @end mudela
2071 @end quotation
2072
2073      
2074 If you want to have hyphens centered between syllables (rather than
2075 attached to the end of the first syllable) you can use the special
2076 `@code{-}@code{-}' lyric as a separate word between syllables.  This
2077 will result in a hyphen which length varies depending on the space
2078 between syllables, and which will be centered between the syllables. 
2079 For example:
2080
2081 @quotation
2082
2083 @mudela[verbatim]
2084 \score {
2085   <
2086     \notes \transpose c'' {
2087       c d e c | c d e c |
2088       e f g2 | e4 f g2 \bar "|.";
2089     }
2090     \context Lyrics \lyrics {
2091       Va4 -- der Ja -- cob | Va -- der Ja -- cob |
2092       Slaapt gij nog?2 | Slaapt4 gij nog?2
2093     }
2094   >
2095 }
2096
2097 @end mudela
2098 @end quotation
2099
2100
2101
2102 @node Notation Contexts, , ,  Reference Manual
2103 @section Notation Contexts
2104
2105 @cindex notation contexts
2106
2107 Notation contexts are objects that only exist during a run of
2108 LilyPond.  During the interpretation phase of LilyPond, the Music
2109 expression contained in a @code{\score} block is interpreted in time
2110 order.  This is the order in which humans read, play, and write
2111 music.
2112
2113 A context is an object that holds the reading state of the
2114 expression; it contains information like
2115
2116 @itemize @bullet
2117   @item  What notes are playing at this point?
2118   @item  What symbols will be printed at this point?
2119   @item  In what style will they printed?
2120   @item  What is the current key signature, time signature, point within
2121        the measure, etc.?
2122 @end itemize
2123
2124 Contexts are grouped hierarchically: A @code{Voice} context is
2125 contained in a @code{Staff} context (because a staff can contain
2126 multiple voices at any point), a @code{Staff} context is contained in
2127 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
2128 these can all contain multiple staffs).
2129
2130 Contexts associated with sheet music output are called @emph{notation
2131 contexts}, those for sound output are called playing contexts.
2132
2133 Contexts are created either manually or automatically.  Initially,
2134 the top level music expression is interpreted by the top level
2135 context (the @code{Score} context).  When a atomic music expression
2136 (i.e. a note, a rest, @code{\bar}, or @code{\time} commands), a nested
2137 set of contexts is created that can process these atomic expressions,
2138 as in this example:
2139
2140 @example
2141
2142   @example 
2143 \score @{ \notes < c4 > @} 
2144 @end example 
2145
2146 @end example
2147
2148 The sequential music, `@code{@{ c4 @}}' is interpreted by @code{Score}
2149 context. When the note `@code{c4}' itself is interpreted, a set of
2150 contexts is needed that will accept notes.  The default for this is a
2151 @code{Voice} context, contained in a @code{Staff} context.  Creation of
2152 these contexts results in the staff being printed.
2153
2154
2155 @cindex context
2156
2157 You can also create contexts manually, and you probably have to do so
2158 if you want to typeset complicated multiple part material.  If a
2159 `@code{\context} @var{name} @var{musicexpr}' expression is encountered
2160 during the interpretation phase, the @var{musicexpr} argument will be
2161 interpreted with a context of type @var{name}.  If you specify a name,
2162 the specific context with that name is searched.
2163
2164 If a context of the specified type and name can not be found, a new
2165 one is created.  For example,
2166
2167 @quotation
2168
2169 @mudela[verbatim]
2170 \score {
2171   \notes \relative c'' {
2172     c4 <d4 \context Staff = "another" e4> f
2173   }
2174 }
2175
2176 @end mudela
2177 @end quotation
2178
2179 In this example, the @code{c} and @code{d} are printed on the
2180 default staff.  For the @code{e}, a context Staff called
2181 `@code{another}' is specified; since that does not exist, a new
2182 context is created.  Within @code{another}, a (default) Voice context
2183 is created for the @code{e4}.  When all music referring to a
2184 context is finished, the context is ended as well.  So after the
2185 third quarter, @code{another} is removed.
2186
2187 Almost all music expressions inherit their interpretation context
2188 from their parent.  In other words, suppose that the syntax for a
2189 music expression is
2190
2191 @example
2192
2193   \keyword @var{musicexpr1} @var{musicexpr2} @dots{}
2194 @end example
2195
2196 When the interpretation of this music expression starts, the context
2197 for @var{musicexpr1}, @var{musicexpr2}, etc. is that of the total
2198 expression.
2199
2200 Lastly, you may wonder, why this:
2201
2202 @quotation
2203
2204 @example 
2205 \score @{
2206   \notes \relative c'' @{
2207     c4 d4 e4
2208   @}
2209 @} 
2210 @end example 
2211
2212 @end quotation
2213
2214 doesn't result in this:
2215
2216 @mudela[]
2217
2218   \score {
2219     \notes \relative c'' {
2220       <c4> <d4> <e4>
2221     }
2222   }
2223
2224 @end mudela
2225
2226 For the @code{c4}, a default @code{Staff} (with a contained
2227 @code{Voice}) context is created.  After the @code{c4} ends, no
2228 music refers to this default staff, so it would be ended, with the
2229 result shown.  To prevent this inconvenient behavior, the context to
2230 which the sequential music refers is adjusted during the
2231 interpretation.  So after the @code{c4} ends, the context of the
2232 sequential music is also the default @code{Voice} context. 
2233 The @code{d4} gets interpreted in the same context
2234 as @code{c4}.
2235
2236
2237
2238 These are the contexts supplied with the package.  They are defined
2239 in the initialization file @file{ly/engraver.ly}.
2240
2241 @table @samp
2242 @end table
2243
2244
2245
2246 Properties that are set in one context are inherited by all of the
2247 contained contexts.  This means that a property valid for the
2248 @code{Voice} context can be set in the @code{Score} context (for
2249 example) and thus take effect in all @code{Voice} contexts.
2250
2251 Properties can be preset within the @code{\translator} block
2252 corresponding to the appropriate context.  In this case, the syntax
2253 is
2254
2255 @example
2256
2257   @var{propname} @code{=} @var{value}
2258 @end example
2259
2260 This assignment happens before interpretation starts, so a
2261 @code{\property} expression will override any predefined settings.
2262
2263 The @code{\property} expression will create any property you specify.
2264 There is no guarantee that a property will be used.  So if you spell
2265 a property name wrong, there will be no error message.
2266
2267 The property settings are used during the interpretation phase.  They
2268 are read by the LilyPond modules where interpretation contexts are
2269 built of.  These modules are called @emph{translators}.  Translators for
2270 notation are called @emph{engravers}, and translators for sound are
2271 called @emph{performers}.
2272
2273 The precise result of a property is determined by the implementation
2274 of the translator that reads them.  Therefore, the result of a
2275 property can vary, since it is implementation and configuration
2276 dependent.
2277
2278 In order to fully find out what properties are used, you must
2279 currently search the source code for calls to @code{get_property}. 
2280 The rest of the section is devoted to an (incomplete) overview of
2281 available properties.
2282
2283 @mbinclude properties.itely
2284
2285 @node Notation output definitions, , ,  Reference Manual
2286 @section Notation output definitions
2287
2288 @cindex output
2289
2290 @cindex notation output
2291
2292 @cindex output definition
2293
2294 @node paper, , ,  Reference Manual
2295
2296 The most important output definition is the @code{\paper} block, for
2297 music notation.  The syntax is
2298
2299 @example
2300
2301   @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2302 @end example
2303
2304 where each of the items is one of
2305
2306 @itemize @bullet
2307   @item  An assignment.  The assignment must be terminated by a
2308        semicolon.  See section XREF-papervars [FIXME] for information on
2309        paper variables.
2310
2311   @item  A context definition.  See section XREF-contextdefs [FIXME] for
2312        more information on context definitions.
2313
2314   @item
2315         FIXME now in SCM
2316
2317         A margin shape declaration.  The syntax is
2318
2319        @example
2320
2321          \shape @var{indent1}@code{,} @var{width1}@code{,}
2322                       @var{indent2}@code{,} @var{width2} @dots{} @code{;}
2323        @end example
2324
2325        @keyindex{shape}
2326
2327        Each pair of @var{indent} and @var{width} values is a dimension
2328        specifying how far to indent and how wide to make the line. 
2329        The indentation and width of successive lines are specified by
2330        the successive pairs of dimensions.  The last pair of
2331        dimensions will define the characeristics of all lines beyond
2332        those explicitly specified.
2333
2334   @item  \stylesheet  declaration.  Its syntax is
2335
2336        @example
2337                 \stylesheet @var{scm}
2338        @end example
2339
2340
2341         See font.scm for details of @var{scm} 
2342 @end itemize
2343
2344
2345
2346 @cindex changing font size and paper size
2347
2348 The Feta font provides musical symbols at six different sizes.  These
2349 fonts are 11 point, 13 point, 16 point, 20 point,
2350 23 point, and 26 point.  The point size of a font is the
2351 height of the five lines in a staff when displayed in the font.
2352
2353 Definitions for these sizes are the files @file{paperSZ.ly}, where
2354 @code{SZ} is one of 11, 13, 16, 20, 23 and 26.  If you include
2355 any of these files, the identifiers @code{paper_eleven},
2356 @code{paper_thirteen}, @code{paper_sixteen}, @code{paper_twenty},
2357 @code{paper_twentythree}, and @code{paper_twentysix} are defined
2358 respectively.  The default @code{\paper} block is also set.
2359
2360 To change the paper size, you must first set the
2361 @code{papersize}@indexcode{papersize} variable at top level.  Set it to the strings
2362 @code{a4}, @code{letter}, or @code{legal}.  After this specification,
2363 you must set the font as described above.  If you want the default
2364 font, then use the 20 point font.  The new paper size will not
2365 take effect if the font is not loaded and selected afterwards.  Paper
2366 size selection works by loading a file named after the paper size you
2367 select.
2368
2369
2370
2371 @cindex paper variables
2372
2373 @node Paper variables, , ,  Reference Manual
2374
2375 There is a large number of paper variables that are used to control
2376 details of the layout.  These variables control the defaults for the
2377 entire score.  Usually, they do not have to be changed; they are by
2378 default set to values that depend on the font size in use.  The
2379 values are used by the graphic objects while formatting the score;
2380 they are therefore implementation dependent.  Most variables are
2381 accompanied by documentation in the initalization file
2382 @file{params.ly} or @file{paperSZ.ly}, where @code{SZ} is the staff
2383 height in points.
2384
2385 Nevertheless, here are some variables you may want to use or change:
2386
2387 @table @samp
2388   @item @code{indent}@indexcode{indent}  
2389     The indentation of the first line of music.
2390
2391   @item @code{staffspace}@indexcode{staffspace}
2392     The distance between two staff lines, calculated from the center
2393     of the lines.  You should use either this or @code{rulethickness}
2394     as a unit for distances you modify.
2395   
2396   @item @code{linewidth}@indexcode{linewidth}  
2397     Sets the width of the lines.  If set to -1.0, a single
2398     unjustified line is produced.
2399
2400   @item @code{textheight}@indexcode{textheight}  
2401     Sets the total height of the music on each page. Only used by
2402     ly2dvi.
2403
2404   @item @code{interscoreline}@indexcode{interscoreline}  
2405     Sets the spacing between the score lines. Defaults to 16 pt.
2406
2407   @item @code{interscorelinefill}@indexcode{interscorelinefill}  
2408     If set to a positive number, the distance between the score 
2409     lines will stretch in order to fill the full page. In that
2410     case @code{interscoreline} specifies the minimum spacing.
2411     Defaults to 0.
2412
2413   @item @code{stafflinethickness}@indexcode{stafflinethickness}  
2414     Determines the thickness of staff and bar lines. 
2415 @end table
2416
2417
2418 @node contextdefs, , ,  Reference Manual
2419
2420 @cindex context definition
2421
2422 A notation contexts is defined by the following information
2423
2424 @enumerate i
2425   @item  A name.
2426
2427   @item  The LilyPond modules that do the actual conversion of music to
2428        notation.  Each module is a so-called
2429        @emph{engraver}
2430 @cindex engraver
2431 .
2432
2433   @item  How these modules should cooperate, i.e. which ``cooperation
2434        module'' should be used.  This cooperation module is a special
2435        type of engraver.
2436
2437   @item  What other contexts the context can contain,
2438
2439   @item  What properties are defined.
2440 @end enumerate
2441
2442 A context definition has this syntax:
2443
2444 @example
2445
2446   \translator @code{@{}
2447                       @var{translatorinit} @var{translatormodifierlist}
2448                     @code{@}}
2449 @end example
2450
2451 @var{translatorinit} can be an identifier or of the form
2452
2453 @example
2454
2455   \type @var{typename} @code{;}
2456 @end example
2457
2458 @var{typename} is one of
2459
2460 @table @samp
2461   @item @code{Engraver_group_engraver}@indexcode{Engraver_group_engraver}  
2462     The standard cooperation engraver.
2463
2464   @item @code{Score_engraver}@indexcode{Score_engraver}  
2465     This is cooperation module that should be in the top level context.
2466
2467   @item @code{Grace_engraver_group}@indexcode{Grace_engraver_group}  
2468     This is a special cooperation module (resembling
2469     @code{Score_engraver}) that is used to created an embedded
2470     `miniscore'.
2471 @end table 
2472
2473 @var{translatormodifierlist} is a list of items where each item is
2474 one of
2475
2476 @itemize @bullet
2477   @item  @code{\consists} @var{engravername} @code{;}  
2478     Add @var{engravername} to the list of modules in this context. 
2479     Section XREF-engravers [FIXME] contains an overview of the engravers
2480     available.  The order of engravers added with @code{\consists} is
2481     significant.
2482   
2483   @item  @code{\consistsend} @var{engravername} @code{;}  
2484     Analogous to @code{\consists}, but makes sure that
2485     @var{engravername} is always added to the end of the list of
2486     engravers.
2487
2488     Some engraver types need to be at the end of the list; this
2489     insures they are put there, and stay there, if a user adds or
2490     removes engravers.  This command is usually not needed for
2491     end-users.
2492     
2493   @item  @code{\accepts} @var{contextname} @code{;}  
2494     Add @var{contextname} to the list of  context this context can
2495     contain.  The first listed context the context to create by
2496     default.
2497   
2498   @item  @code{\remove} @var{engravername} @code{;}  
2499     Remove a previously added (with @code{\consists}) engraver.
2500   
2501   @item  @code{\name} @var{contextname} @code{;}  
2502     This sets name of the context, e.g. @code{Staff}, @code{Voice}.  If
2503     the name is not specified, the translator won't do anything.
2504
2505   @item  @var{propname} @code{=} @var{value} @code{;}  
2506     A property assignment.  It is allowed to use reals for
2507     @var{value}.
2508 @end itemize
2509
2510 In the @code{\paper} block, it is also possible to define translator
2511 identifiers.  Like other block identifiers, the identifier can only
2512 be used as the very first item of a translator.  In order to define
2513 such an identifier outside of @code{\score}, you must do
2514
2515 @quotation
2516
2517 @example 
2518 \paper @{
2519   foo = \translator @{ @dots{} @}
2520 @}
2521 \score @{
2522   \notes @{
2523     @dots{}
2524   @}
2525   \paper @{
2526     \translator @{ \foo @dots{} @}
2527   @}
2528 @} 
2529 @end example 
2530
2531 @end quotation
2532
2533
2534 @cindex paper types, engravers, and pre-defined translators
2535
2536 Some pre-defined identifiers can simplify modification of
2537 translators.  The pre-defined identifiers are:
2538
2539 @table @samp
2540   @item @code{StaffContext}@indexcode{StaffContext}  
2541     Default Staff context. 
2542
2543   @item @code{RhythmicStaffContext}@indexcode{RhythmicStaffContext}  
2544     Default RhythmicStaff context. 
2545
2546   @item @code{VoiceContext}@indexcode{VoiceContext}  
2547     Default Voice context.  
2548
2549   @item @code{ScoreContext}@indexcode{ScoreContext}  
2550     Default Score context. 
2551
2552   @item @code{ScoreWithNumbers}@indexcode{ScoreWithNumbers}  
2553     Score context with numbering at the Score level.
2554
2555   @item @code{BarNumberingStaffContext}@indexcode{BarNumberingStaffContext}  
2556     Staff context with numbering at the Staff level.
2557
2558   @item @code{HaraKiriStaffContext}@indexcode{HaraKiriStaffContext}  
2559     Staff context that does not print if it only contains rests. 
2560     Useful for orchestral scores.@footnote{Harakiri, also called
2561     Seppuku, is the ritual suicide of the Samourai.}
2562
2563   @item @code{OrchestralPartStaffContext}@indexcode{OrchestralPartStaffContext}
2564
2565   @item @code{OrchestralScoreContext}@indexcode{OrchestralScoreContext}
2566 @end table
2567
2568 Using these pre-defined values, you can remove or add items to the
2569 translator:
2570
2571 @quotation
2572
2573 @example 
2574 \paper @{
2575   \translator @{
2576     \StaffContext
2577     \remove Some_engraver;
2578     \consists Different_engraver;
2579   @}
2580 @} 
2581 @end example 
2582
2583 @end quotation
2584
2585       
2586 @node Sound output, , ,  Reference Manual
2587 @section Sound output
2588
2589
2590
2591 The MIDI block is analogous to the paper block, but it is simpler.
2592 The @code{\midi} block can contain:
2593 @cindex MIDI block
2594
2595 @itemize @bullet
2596   @item  a @code{\tempo} definition
2597   @item  context definitions
2598 @end itemize
2599
2600 Assignments in the @code{\midi} block are not allowed.
2601
2602
2603
2604 @cindex context definition
2605
2606 Context definitions follow precisely the same syntax as within the
2607 \paper block.  Translation modules for sound are called performers.
2608 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2609
2610
2611
2612 @cindex MIDI instrument names
2613
2614 @node midilist, , , Reference Manual
2615
2616 The MIDI instrument name is set by the
2617 @code{Staff.midiInstrument}@indexcode{Staff.midiInstrument} property or,
2618 if that property is not set, the
2619 @code{Staff.instrument}@indexcode{Staff.instrument} property.  The
2620 instrument name should be chosen from the following list.  If the
2621 selected string does not exactly match, then LilyPond uses the default
2622 piano.
2623
2624 @c @quotation
2625
2626 @example 
2627 "acoustic grand"            "contrabass"           "lead 7 (fifths)"
2628 "bright acoustic"           "tremolo strings"      "lead 8 (bass+lead)"
2629 "electric grand"            "pizzicato strings"    "pad 1 (new age)"
2630 "honky-tonk"                "orchestral strings"   "pad 2 (warm)"
2631 "electric piano 1"          "timpani"              "pad 3 (polysynth)"
2632 "electric piano 2"          "string ensemble 1"    "pad 4 (choir)"
2633 "harpsichord"               "string ensemble 2"    "pad 5 (bowed)"
2634 "clav"                      "synthstrings 1"       "pad 6 (metallic)"
2635 "celesta"                   "synthstrings 2"       "pad 7 (halo)"
2636 "glockenspiel"              "choir aahs"           "pad 8 (sweep)"
2637 "music box"                 "voice oohs"           "fx 1 (rain)"
2638 "vibraphone"                "synth voice"          "fx 2 (soundtrack)"
2639 "marimba"                   "orchestra hit"        "fx 3 (crystal)"
2640 "xylophone"                 "trumpet"              "fx 4 (atmosphere)"
2641 "tubular bells"             "trombone"             "fx 5 (brightness)"
2642 "dulcimer"                  "tuba"                 "fx 6 (goblins)"
2643 "drawbar organ"             "muted trumpet"        "fx 7 (echoes)"
2644 "percussive organ"          "french horn"          "fx 8 (sci-fi)"
2645 "rock organ"                "brass section"        "sitar"
2646 "church organ"              "synthbrass 1"         "banjo"
2647 "reed organ"                "synthbrass 2"         "shamisen"
2648 "accordion"                 "soprano sax"          "koto"
2649 "harmonica"                 "alto sax"             "kalimba"
2650 "concertina"                "tenor sax"            "bagpipe"
2651 "acoustic guitar (nylon)"   "baritone sax"         "fiddle"
2652 "acoustic guitar (steel)"   "oboe"                 "shanai"
2653 "electric guitar (jazz)"    "english horn"         "tinkle bell"
2654 "electric guitar (clean)"   "bassoon"              "agogo"
2655 "electric guitar (muted)"   "clarinet"             "steel drums"
2656 "overdriven guitar"         "piccolo"              "woodblock"
2657 "distorted guitar"          "flute"                "taiko drum"
2658 "guitar harmonics"          "recorder"             "melodic tom"
2659 "acoustic bass"             "pan flute"            "synth drum"
2660 "electric bass (finger)"    "blown bottle"         "reverse cymbal"
2661 "electric bass (pick)"      "skakuhachi"           "guitar fret noise"
2662 "fretless bass"             "whistle"              "breath noise"
2663 "slap bass 1"               "ocarina"              "seashore"
2664 "slap bass 2"               "lead 1 (square)"      "bird tweet"
2665 "synth bass 1"              "lead 2 (sawtooth)"    "telephone ring"
2666 "synth bass 2"              "lead 3 (calliope)"    "helicopter"
2667 "violin"                    "lead 4 (chiff)"       "applause"
2668 "viola"                     "lead 5 (charang)"     "gunshot"
2669 "cello"                     "lead 6 (voice)" 
2670 @end example 
2671
2672 @c @end quotation
2673
2674
2675 @cindex MIDI types and performers
2676
2677 The types available for  MIDI translators are:
2678
2679 @table @samp
2680   @item @code{Performer_group_performer}@indexcode{Performer_group_performer}
2681   @item @code{Score_performer}@indexcode{Score_performer}
2682   @item @code{Staff_performer}@indexcode{Staff_performer}
2683 @end table
2684
2685 The performers for MIDI translators are:
2686
2687 @table @samp
2688   @item @code{Key_performer}@indexcode{Key_performer}
2689   @item @code{Time_signature_performer}@indexcode{Time_signature_performer}
2690   @item @code{Note_performer}@indexcode{Note_performer}
2691   @item @code{Lyric_performer}@indexcode{Lyric_performer}
2692   @item @code{Swallow_performer}@indexcode{Swallow_performer}
2693 @end table
2694
2695
2696
2697 @node Pre-defined Identifiers, , ,  Reference Manual
2698
2699 @section Pre-defined Identifiers
2700
2701 @cindex pre-defined identifiers
2702
2703
2704 Various identifiers are defined in the initialization files to
2705 provide shorthands for some settings.  Most of them are in
2706 @file{ly/declarations.ly}.
2707
2708 @table @samp
2709   @item @code{\break}@keyindex{break}  
2710     Force a line break in music by using a large argument for the
2711     keyword @code{\penalty}.
2712
2713   @item @code{\center}@keyindex{center}  
2714     Used for setting direction  properties.  Equals 0.
2715
2716   @item @code{\down}@keyindex{down}  
2717     Used for setting direction setting properties.  Is equal
2718     to -1.
2719
2720   @item @code{\free}@keyindex{free}  
2721     Used for setting direction setting properties.  Is equal
2722     to 0.
2723
2724   @item @code{\left}@keyindex{left}  
2725     Used for setting text alignment property.  Is equal to -1.
2726
2727   @item @code{\nobreak}@keyindex{nobreak}  
2728     Prevent a line break in music by using a large negative argument
2729     for the keyword @code{\penalty}.
2730
2731   @item @code{\none}@keyindex{none}  
2732     Used for setting @code{Score.beamslopedamping} and
2733     @code{Score.beamquantisation} properties.  Is equal to 0.
2734
2735   @item @code{\normal}@keyindex{normal}  
2736     Used for setting @code{Score.beamslopedamping} and
2737     @code{Score.beamquantisation} properties.  Is equal to 1.
2738
2739   @item @code{\normalkey}@keyindex{normalkey}  
2740     Select normal key signatures where each octave has the same key
2741     signature.  This sets the @code{Staff.keyoctaviation} property.
2742
2743   @item @code{\right}@keyindex{right}  
2744     Used for setting text alignment property.  Is set to 1.
2745
2746   @item @code{\shiftoff}@keyindex{shiftOff}  
2747     Disable horizontal shifting of note heads that collide.  Sets the
2748     @code{Voice.horizontalNoteShift} property.
2749
2750   @item @code{\shiftOn}@keyindex{shiftOn}  
2751     Enable note heads that collide with other note heads to be
2752     shifted horiztonally.  Sets the @code{Voice.horizontalNoteShift}
2753     property.
2754
2755   @item @code{\slurBoth}@keyindex{slurBoth}  
2756     Allow slurs to be above or below notes.  This sets the
2757     @code{Voice.slurVerticalDirection} property.
2758
2759   @item @code{\slurDown}@keyindex{slurDown}  
2760     Force slurs to be below notes.  This sets the
2761     @code{Voice.slurVerticalDirection} property.
2762
2763   @item @code{\slurUp}@keyindex{slurUp}  
2764     Force slurs to be above notes.  This sets the
2765     @code{Voice.slurVerticalDirection} property.
2766
2767   @item @code{\specialkey}@keyindex{specialkey}  
2768     Allow key signatures do differ in different octaves.  This sets
2769     the @code{Staff.keyoctaviation} property.
2770
2771   @item @code{\stemBoth}@keyindex{stemBoth}  
2772     Allow stems, beams, and slurs to point either upwards or
2773     downwards, decided automatically by LilyPond.  This sets the
2774     @code{Voice.verticalDirection} property.
2775
2776   @item @code{\stemdown}@keyindex{stemdown}  
2777     Force stems, beams, and slurs to point down.  This sets the
2778     @code{Voice.verticalDirection} property.
2779
2780   @item @code{\stemUp}@keyindex{stemUp}  
2781     Force stems, beams and slurs to point up.  This sets the
2782     @code{Voice.verticalDirection} property.
2783
2784   @item @code{\traditional}@keyindex{traditional}  
2785     Used for setting the @code{Score.beamquantisation} property.  Is
2786     equal to 2.
2787
2788   @item @code{\up}@keyindex{up}  
2789     Used for setting various direction properties.  Is equal
2790     to 1.
2791 @end table