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