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