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