A basic example of a lilypond input file is
\version "2.11.38" \score { ...compound music expression... % all the music goes here! \header { } \layout { } \midi { } }
There are many variations of this basic pattern, but this example serves as a useful starting place.
Up to this point none of the examples you have seen has used a
\score{}
command. This is because LilyPond automatically
adds the extra commands which are needed when you give it simple
input. LilyPond treats input like this:
\relative c'' { c4 a d c }
as shorthand for this:
\book { \score { \new Staff { \new Voice { \relative c'' { c4 a b c } } } \layout { } } }
In other words, if the input contains a single music expression,
LilyPond will interpret the file as though the music expression
was wrapped up inside the commands shown above. For now, though,
let us return to the first example and examine the \score
command, leaving the others to default.
A \score
block must always contain just one music
expression, and
this must appear immediately after the \score
command.
Remember that a music expression could be anything from a single
note to a huge compound expression like
{ \new GrandStaff << ...insert the whole score of a Wagner opera in here... >> }
Since everything is inside { ... }
, it counts
as one music expression.
As we saw previously, the \score
block can contain other
things, such as
\score { { c'4 a b c' } \header { } \layout { } \midi { } }
Some people put some of those commands outside the \score
block – for example, \header
is often placed above the
\score
command. That's just another shorthand that LilyPond
accepts.
Two more commands you have not previously seen are
\layout { }
and \midi {}
. If these appear as
shown they will cause LilyPond to produce a printed output and a
MIDI output respectively. They are described fully in the
Notation Reference – Score layout and
Creating MIDI files.
You may code multiple \score
blocks. Each will be
treated as a separate score, but they will be all combined into
a single output file. A \book
command is not necessary
– one will be implicitly created. However, if you would like
separate output files from one .ly
file then the
\book
command should be used to separate the different
sections: each \book
block will produce a
separate output file. For details see in a book
Multiple scores in a book.
Another great shorthand is the ability to define variables. All the templates use this
melody = \relative c' { c4 a b c } \score { \melody }
When LilyPond looks at this file, it takes the value of
melody
(everything after the equals sign) and inserts it
whenever it sees \melody
. There's nothing special about
the names – it could be melody
, global
,
TimeKey
,
pianorighthand
, or foofoobarbaz
. For more details,
see Saving typing with variables and functions.
Remember that you can use almost any name you like as long
as it contains just alphabetic characters and is distinct from
LilyPond command names. The exact
limitations on variable names are detailed in
File structure.
For a complete definition of the input format, see
File structure.
Diese Seite ist für LilyPond-2.11.40 (Entwicklungszweig).
Fehler bitte an http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs melden.
Ihre Vorschläge für die Dokumentation sind willkommen.
Otros idiomas: français.