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