1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
15 This section deals with general LilyPond input syntax issues,
16 rather than specific notation.
18 FIXME: don't complain about anything in this chapter. It's still
19 under heavy development.
29 * Common syntax issues TODO name?::
30 * Other stuffs TODO move?::
37 The main format of input for LilyPond are text files. By convention,
38 these files end with @code{.ly}.
42 * A single music expression::
43 * Multiple scores in a book::
44 * Extracting fragments of notation::
45 * Including LilyPond files::
47 * Different editions from one source::
52 @subsection File structure
54 A @code{.ly} file contains any number of toplevel expressions, where a
55 toplevel expression is one of the following
59 An output definition, such as @code{\paper}, @code{\midi}, and
60 @code{\layout}. Such a definition at the toplevel changes the default
61 settings for the block entered.
64 A direct scheme expression, such as
65 @code{#(set-default-paper-size "a7" 'landscape)} or
66 @code{#(ly:set-option 'point-and-click #f)}.
69 A @code{\header} block. This sets the global header block. This
70 is the block containing the definitions for book-wide settings, like
74 A @code{\score} block. This score will be collected with other
75 toplevel scores, and combined as a single @code{\book}.
77 This behavior can be changed by setting the variable
78 @code{toplevel-score-handler} at toplevel. The default handler is
79 defined in the init file @file{scm/@/lily@/.scm}.
81 The @code{\score} must begin with a music expression, and may
82 contain only one music expression.
85 A @code{\book} block logically combines multiple movements
86 (i.e., multiple @code{\score} blocks) in one document. If there are
87 a number of @code{\scores}, one output file will be created for
88 each @code{\book} block, in which all corresponding movements are
89 concatenated. The only reason to explicitly specify @code{\book} blocks
90 in a @code{.ly} file is if you wish multiple output files from a single
91 input file. One exception is within lilypond-book documents, where you
92 explicitly have to add a @code{\book} block if you want more than a
93 single @code{\score} or @code{\markup} in the same example.
95 This behavior can be changed by setting the variable
96 @code{toplevel-book-handler} at toplevel. The default handler is
97 defined in the init file @file{scm/@/lily@/.scm}.
100 A compound music expression, such as
105 This will add the piece in a @code{\score} and format it in a
106 single book together with all other toplevel @code{\score}s and music
107 expressions. In other words, a file containing only the above
108 music expression will be translated into
124 This behavior can be changed by setting the variable
125 @code{toplevel-music-handler} at toplevel. The default handler is
126 defined in the init file @file{scm/@/lily@/.scm}.
129 A markup text, a verse for example
132 2. The first line verse two.
136 Markup texts are rendered above, between or below the scores or music
137 expressions, wherever they appear.
147 This can be used later on in the file by entering @code{\foo}. The
148 name of an variable should have alphabetic characters only; no
149 numbers, underscores or dashes.
153 The following example shows three things that may be entered at
158 % movements are non-justified by default
170 At any point in a file, any of the following lexical instructions can
174 @item @code{\version}
175 @item @code{\include}
176 @item @code{\sourcefilename}
177 @item @code{\sourcefileline}
182 @node A single music expression
183 @subsection A single music expression
185 A @code{\score} must contain a single music expression. However,
186 this music expression may be of any size. Recall that music
187 expressions may be included inside other expressions to form
188 larger expressions. All of these examples are single music
189 expressions; note the curly braces @{ @} or angle brackets <<
190 >> at the beginning and ending of the music.
196 @lilypond[ragged-right,verbatim,quote]
203 @lilypond[ragged-right,verbatim,quote]
205 \new Staff { c'4 c' c' c' }
206 \new Staff { d'4 d' d' d' }
214 \new Staff @{ \flute @}
215 \new Staff @{ \oboe @}
218 \new Staff @{ \violinI @}
219 \new Staff @{ \violinII @}
226 @node Multiple scores in a book
227 @subsection Multiple scores in a book
230 @cindex movements, multiple
232 A document may contain multiple pieces of music and texts. Examples
233 of these are an etude book, or an orchestral part with multiple
234 movements. Each movement is entered with a @code{\score} block,
242 and texts are entered with a @code{\markup} block,
252 All the movements and texts which appear in the same @code{.ly} file
253 will normally be typeset in the form of a single output file.
267 However, if you want multiple output files from the same @code{.ly}
268 file, then you can add multiple @code{\book} blocks, where each such
269 @code{\book} block will result in a separate output. If you do not
270 specify any @code{\book} block in the file, LilyPond will implicitly
271 treat the full file as a single @code{\book} block, see @ref{File
272 structure}. One important exception is within lilypond-book documents,
273 where you explicitly have to add a @code{\book} block, otherwise only
274 the first @code{\score} or @code{\markup} will appear in the output.
276 The header for each piece of music can be put inside the @code{\score}
277 block. The @code{piece} name from the header will be printed before
278 each movement. The title for the entire book can be put inside the
279 @code{\book}, but if it is not present, the @code{\header} which is at
280 the top of the file is inserted.
284 title = "Eight miniatures"
285 composer = "Igor Stravinsky"
289 \header @{ piece = "Romanze" @}
292 ..text of second verse..
295 ..text of third verse..
299 \header @{ piece = "Menuetto" @}
303 @node Extracting fragments of notation
304 @subsection Extracting fragments of notation
306 It is possible to quote small fragments of a large score directly from
307 the output. This can be compared to clipping a piece of a paper score
310 This is done by defining the measures that need to be cut out
311 separately. For example, including the following definition
319 (make-rhythmic-location 5 1 2)
320 (make-rhythmic-location 7 3 4)))
325 will extract a fragment starting halfway the fifth measure, ending in
326 the seventh measure. The meaning of @code{5 1 2} is: after a 1/2 note
327 in measure 5, and @code{7 3 4} after 3 quarter notes in measure 7.
329 More clip regions can be defined by adding more pairs of
330 rhythmic-locations to the list.
332 In order to use this feature, LilyPond must be invoked with
333 @code{-dclip-systems}. The clips are output as EPS files, and are
334 converted to PDF and PNG if these formats are switched on as well.
336 For more information on output formats, see @rprogram{Invoking LilyPond}.
339 @node Including LilyPond files
340 @subsection Including LilyPond files
343 @cindex including files
345 A large project may be split up into separate files. To refer to another
349 \include "otherfile.ly"
352 The line @code{\include "file.ly"} is equivalent to pasting the contents
353 of file.ly into the current file at the place where you have the
354 \include. For example, for a large project you might write separate files
355 for each instrument part and create a @q{full score} file which brings
356 together the individual instrument files.
358 The initialization of LilyPond is done in a number of files that are
359 included by default when you start the program, normally transparent to the
360 user. Run @code{lilypond --verbose} to see a list of paths and files that Lily
363 Files placed in directory @file{PATH/TO/share/lilypond/VERSION/ly/} (where
364 VERSION is in the form @q{2.6.1}) are on the path and available to
365 @code{\include}. Files in the
366 current working directory are available to \include, but a file of the same
367 name in LilyPond's installation takes precedence. Files are
368 available to \include from directories in the search path specified as an
369 option when invoking @code{lilypond --include=DIR} which adds DIR to the
372 The @code{\include} statement can use full path information, but with the UNIX
373 convention @code{/} rather than the DOS/Windows @code{\}. For example,
374 if @file{stuff.ly} is located one directory higher than the current working
378 \include "../stuff.ly"
383 @subsection Text encoding
385 LilyPond uses the Pango library to format multi-lingual texts, and
386 does not perform any input-encoding conversions. This means that any
387 text, be it title, lyric text, or musical instruction containing
388 non-ASCII characters, must be utf-8. The easiest way to enter such text is
389 by using a Unicode-aware editor and saving the file with utf-8 encoding. Most
390 popular modern editors have utf-8 support, for example, vim, Emacs,
393 @c Currently not working
395 Depending on the fonts installed, the following fragment shows Hebrew
402 @li lypondfile[fontload]{utf-8.ly}
404 The @TeX{} backend does not handle encoding specially at all. Strings
405 in the input are put in the output as-is. Extents of text items in the
406 @TeX{} backend, are determined by reading a file created via the
407 @file{texstr} backend,
410 lilypond -dbackend=texstr input/les-nereides.ly
411 latex les-nereides.texstr
414 The last command produces @file{les-nereides.textmetrics}, which is
415 read when you execute
418 lilypond -dbackend=tex input/les-nereides.ly
421 Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
422 suitable LaTeX wrappers to load appropriate La@TeX{} packages for
423 interpreting non-ASCII strings.
427 To use a Unicode escape sequence, use
430 #(ly:export (ly:wide-char->utf-8 #x2014))
434 @node Different editions from one source
435 @subsection Different editions from one source
440 The @code{\tag} command marks music expressions with a name. These
441 tagged expressions can be filtered out later. With this mechanism it
442 is possible to make different versions of the same music source.
444 In the following example, we see two versions of a piece of music, one
445 for the full score, and one with cue notes for the instrumental part
461 The same can be applied to articulations, texts, etc.: they are
464 -\tag #@var{your-tag}
466 to an articulation, for example,
471 This defines a note with a conditional fingering indication.
474 @cindex removeWithTag
475 By applying the @code{\keepWithTag} and @code{\removeWithTag}
476 commands, tagged expressions can be filtered. For example,
480 \keepWithTag #'score @var{the music}
481 \keepWithTag #'part @var{the music}
487 @c @lilypondfile[ragged-right,quote]{tag-filter.ly}
489 The arguments of the @code{\tag} command should be a symbol
490 (such as @code{#'score} or @code{#'part}), followed by a
491 music expression. It is possible to put multiple tags on
492 a piece of music with multiple @code{\tag} entries,
495 \tag #'original-part \tag #'transposed-part @dots{}
501 Multiple rests are not merged if you create the score with both tagged
505 @node Common syntax issues TODO name?
506 @section Common syntax issues TODO name?
509 * Controlling direction and placement::
510 * Distances and measurements MAYBE MOVE::
514 @node Controlling direction and placement
515 @subsection Controlling direction and placement
519 By default, LilyPond does a pretty jazz'n job of picking
520 directions. But in some cases, it may be desirable to force a
534 Maybe rename section to "directions".
536 Also mention \override Foo #'direction = #'DOWN.
538 also mention the typical \fooDown, \fooNeutral predefined commands.
540 also mention that some directions are (without other tweaking)
541 always up or always down (like dynamics or fermata), while other
542 things can alternate between up or down based on the stem direction
543 (like slurs or accents).
546 @node Distances and measurements MAYBE MOVE
547 @subsection Distances and measurements MAYBE MOVE
549 DISCUSS after working on other sections.
551 TODO: staff spaces, #UP #DOWN #LEFT #RIGHT. Maybe move into tweaks?
554 @node When to add a -
555 @subsection When to add a -
557 One of these works, the other doesn't.
561 { c'\mp\fermata\accent-\markup { "forcefully"} }
562 % { c'\mp\fermata\accent\markup { "forcefully"} }
566 @node Other stuffs TODO move?
567 @section Other stuffs TODO move?
571 * Displaying LilyPond notation::
572 * Skipping corrected music::
573 * context list FIXME::
574 * another thing FIXME::
575 * Input modes FIXME::
578 @node Displaying LilyPond notation
579 @subsection Displaying LilyPond notation
581 @funindex \displayLilyMusic
582 Displaying a music expression in LilyPond notation can be
583 done using the music function @code{\displayLilyMusic}. For example,
587 \displayLilyMusic \transpose c a, @{ c e g a bes @}
597 By default, LilyPond will print these messages to the console along
598 with all the other messages. To split up these messages and save
599 the results of @code{\display@{STUFF@}}, redirect the output to
603 lilypond file.ly >display.txt
607 @node Skipping corrected music
608 @subsection Skipping corrected music
611 @funindex skipTypesetting
612 @funindex showLastLength
614 When entering or copying music, usually only the music near the end (where
616 are adding notes) is interesting to view and correct. To speed up
617 this correction process, it is possible to skip typesetting of all but
618 the last few measures. This is achieved by putting
621 showLastLength = R1*5
626 in your source file. This will render only the last 5 measures
627 (assuming 4/4 time signature) of every @code{\score} in the input
628 file. For longer pieces, rendering only a small part is often an order
629 of magnitude quicker than rendering it completely
631 Skipping parts of a score can be controlled in a more fine-grained
632 fashion with the property @code{Score.skipTypesetting}. When it is
633 set, no typesetting is performed at all.
635 This property is also used to control output to the MIDI file. Note that
636 it skips all events, including tempo and instrument changes. You have
639 @lilypond[quote,fragment,ragged-right,verbatim]
642 \set Score.skipTypesetting = ##t
644 \set Score.skipTypesetting = ##f
648 In polyphonic music, @code{Score.skipTypesetting} will affect all
649 voices and staves, saving even more time.
652 @node context list FIXME
653 @subsection context list FIXME
655 >> > > - list of contexts: my *danger unmaintainable*
656 >> > > alarm just went off. I'm
658 I knew it would... And leaving out some of them is perfectly fine
660 I do think that a list like this, with the main contexts and a
662 description of what they do (perhaps also with a note about what
664 behavior is associated with each of them, but this may be
666 should be there, and then we could simply list the remaining ones
668 further explanation and with links to the IR.
671 The Master Of All Contexts
672 ==========================
675 This is the top level notation context. No other context
677 contain a Score context. This context handles the
678 administration of time signatures. It also makes sure that
679 items such as clefs, time signatures, and key-signatures
681 aligned across staves.
682 You cannot explicitly instantiate a Score context (since
684 not contained in any other context). It is instantiated
685 automatically when an output definition (a \score or
688 (it should also be made clear somewhere what the
689 difference is between
692 Top-level contexts: Staff containers
693 ====================================
695 Groups staves while adding a bracket on the left side,
696 grouping the staves together. The bar lines of the
698 staves are connected vertically. StaffGroup only consists
700 collection of staves, with a bracket in front and spanning
704 Identical to StaffGroup except that the contained staves
706 not connected vertically.
708 A group of staves, with a brace on the left side, grouping
710 staves together. The bar lines of the contained staves are
711 connected vertically.
713 Just like GrandStaff but with a forced distance between
715 staves, so cross staff beaming and slurring can be used.
717 Handles typesetting for percussion. Can contain DrumVoice
724 Handles clefs, bar lines, keys, accidentals. It can
728 Like Staff but for printing rhythms. Pitches are
729 ignored; the notes are printed on one line.
731 Context for generating tablature. By default lays the
733 expression out as a guitar tablature, printed on six
736 Same as Staff, except that it is accommodated for
737 typesetting a piece in gregorian style.
739 Same as Staff, except that it is accommodated for
740 typesetting a piece in mensural style.
742 Voice-level (bottom) contexts
743 =============================
744 What is generated by default here? The voice-level contexts
746 certain properties and start engravers.
749 Corresponds to a voice on a staff. This context handles
751 conversion of dynamic signs, stems, beams, super- and
752 subscripts, slurs, ties, and rests.
753 You have to instantiate this explicitly if you want to
755 multiple voices on the same staff.
758 Same as Voice, except that it is accommodated for
759 typesetting a piece in gregorian style.
761 Same as Voice, except that it is accommodated for
762 typesetting a piece in mensural style.
764 Corresponds to a voice with lyrics. Handles the printing
766 single line of lyrics.
769 A voice on a percussion staff.
773 Typesets chord names. This context is a `bottom' context;
775 cannot contain other contexts.
777 ------------------------------
778 Then the following, which I don't know what to do with:
781 * GregorianTranscriptionVoice
782 * GregorianTranscriptionStaff
785 Engraves fretboards from chords. Not easy... Not
789 * CueVoice Not documented
791 Hard coded entry point for LilyPond. Cannot be tuned.
793 Silently discards all musical information given to this
797 @node another thing FIXME
798 @subsection another thing FIXME
800 Another thing that is needed, is an overview of the various naming
803 scheme functions: lowercase-with-hyphens (incl. one-word
805 scheme functions: ly:plus-scheme-style
806 music events, music classes and music properties:
808 Grob interfaces: scheme-style
809 backend properties: scheme-style (but X and Y!)
810 contexts (and MusicExpressions and grobs): Capitalized or
812 context properties: lowercaseFollowedByCamelCase
814 Capitalized_followed_by_lowercase_and_with_underscores
816 Which of these are conventions and which are rules?
817 Which are rules of the underlying language, and which are
821 @node Input modes FIXME
822 @subsection Input modes FIXME
826 \notemode turns the front end of LilyPond into note mode
827 (which is the default parsing mode).
828 It's certainly useful in certain situations, for example if you
829 are in \lyricmode or \chordmode or ... and want to insert
830 something that only can be done with \notemode syntax.
833 http://lists.gnu.org/archive/html/lilypond-user/2007-03/msg00418.html
834 http://lists.gnu.org/archive/html/lilypond-user/2007-03/msg00218.html
835 http://lists.gnu.org/archive/html/lilypond-user/2006-12/msg00236.html
836 http://lists.gnu.org/archive/html/lilypond-user/2006-11/msg00061.html