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