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