[icon]

GNU LilyPond

-- --

What is LilyPond
Home
Examples
Templates
Download
GNU/Linux binaries
Windows binaries
Source code
Documentation
Tutorial
Manual
Glossary
Index

Support
Mailing lists
Search
WikiWiki

External sites
lilypond.org/stable
lilypond.org/development
savannah.gnu.org
ftp.lilypond.org
Mutopia
Other music online

More basics

We continue with the introduction of the remaining musical constructs. Normal rests are entered just like notes with the name "r":

          r2 r4 r8 r16
          
[picture of music]



To raise a note by an octave, add a high quote ' (apostrophe) to the note name, to lower a note one octave, add a "low quote" , (a comma). Middle C is c':

          c'4 c'' c''' \clef bass c c,
          
[picture of music]



A tie is created by adding a tilde "~" to the first note being tied.

          g'4-~ g' a'2-~ a'4
          
[picture of music]



A tie is different from a slur. A tie simply makes the first note sound longer, and can only be used on pairs of notes with the same pitch. Slurs indicate the articulations of notes, and can be used on larger groups of notes. Slurs and ties are also nested in practice:

[picture of music]

The key signature is set with the command "\key". One caution word of caution: you need to specify whether the key is \major or \minor.

          \key d \major
          g'1
          \key c \minor
          g'
          
[picture of music]

This example shows notes, ties, octave marks, and rests in action.

          \score {
            \notes {
              \time 4/4
              \key d \minor
              \clef violin
              r4 r8 d''8 cis''4 e''
              d''8 a'4.-~ a' b'8
              cis''4 cis''8 cis'' bis'4 d''8 cis''-~
              cis''2 r2
            }
            \paper { }
          }
          
[picture of music]

There are some interesting points to note in this example. Accidentals (sharps and flats) don't have to be marked explicitly: you just enter the note name, and LilyPond determines whether or not to print an accidental. Bar lines and beams are drawn automatically. LilyPond calculates line breaks for you; it doesn't matter where you make new lines in the source file. Finally, the order of time, key and clef changes is not relevant: lilypond will use standard notation conventions for ordering these items.

The example also indicates that a piece of music written in a high register needs lots of quotes. This makes the input less readable, and is also a potential source of errors.

The solution is to use "relative octave" mode. In practice, this is the most convenient way to copy existing music. To use relative mode, add \relative before the piece of music. You must also give a note from which relative starts, in this case c''. If you don't use octavation quotes (ie don't add ' or , after a note), relative mode chooses the note that is closest to the previous one. Since most music has small intervals, you can write quite a lot in relative mode without using octavation quotes. For example: c f goes up; c g goes down:

          \relative c'' {
            c f c g c
          }
          
[picture of music]



You can make larger intervals by adding octavation quotes. Note that quotes or commas do not determine the absolute height of a note; the height of a note is relative to the previous one. For example: c f, goes down; f, f are both the same; c' c are the same; and c g' goes up:

          \relative c'' {
            c f, f c' c g' c,
          }
          
[picture of music]



Here's an example of the difference between relative mode and "normal" (non-relative) mode:

          \relative a {
          \clef bass
            a d a e d c' d'
          }
          
[picture of music]



          \clef bass
            a d a e d c' d'
          
[picture of music]



SUMMARY

The following table summarizes the syntax learned so far in this section.

Syntax Description Example
r4 r8 rest

[picture of music]


~ tie

[picture of music]


\key es \major key signature

[picture of music]


note' raise octave

[picture of music]


note, lower octave

[picture of music]


A slur is drawn across many notes, and indicates bound articulation (legato). The starting note and ending note are marked with a "(" and a ")" respectively:

          d4-( c16-)-( cis d e c cis d e-)-( d4-)
          
[picture of music]



If you need two slurs at the same time (one for articulation, one for phrasing), you can also make a phrasing slur with \( and \).

          a8-(-\( ais b  c-) cis2 b'2 a4 cis,  c-\)
          
[picture of music]



Beams are drawn automatically, but if you don't like the choices, you can enter beams by hand. Mark the first note to be beamed with [ and the last one with ]:

          a8-[ ais-] d-[ es r d-]
          
[picture of music]



To print more than one staff, each piece of music that makes up a staff is marked by adding \context Staff before it. These Staff's are then grouped inside < and >, as is demonstrated here:

          <
            \context Staff = staffA { \clef violin c'' }
            \context Staff = staffB { \clef bass c }
          >
          
[picture of music]

In this example, staffA and staffB are names that are given to the staves. It doesn't matter what names you give, as long as each staff has a different name. If you give them the same name, LilyPond will assume that you only want one staff, and will but both pieces of music on the same staff.



We can now typeset a melody with two staves:

          \score {
            \notes
            < \context Staff = staffA {
                \time 3/4
                \clef violin
                \relative c'' { e2-( d4 c2 b4 a8-[ a-] b-[ b-] g-[ g-] a2.-) }
              }
              \context Staff = staffB {
                 \clef bass
                 c2 e4  g2.
                 f4 e d c2.
              }
            >
            \paper {}
          }
          
[picture of music]

Notice that the time signature is specified in one melody staff only (the top staff), but is printed on both. LilyPond knows that the time signature should be the same for all staves.



Common accents can be added to a note using -., --, ->:

          c-. c-- c->
          
[picture of music]



Dynamic signs are made by adding the markings to the note:

          c-\ff c-\mf
          
[picture of music]



Crescendi and decrescendi are started with the commands \< and \>. The command \! finishes a crescendo on the note it is attached to.

          c2-\<  c2-\!-\ff  c2-\>  c2-\!
          
[picture of music]



Chords can be made by surrounding notes with << and >>:

          r4 <<c e g>>4 <<c f a>>8
          
[picture of music]



You can combine beams and ties with chords. Beam and tie markings must be placed outside the chord markers:

          r4 <<c e g>>8-[ <<c f a>>-]-~ <<c f a>>
          
[picture of music]
          r4 <<c e g>>8-\>-( <<c e g>> <<c e g>>  <<c f a>>8-\!-\)
          
[picture of music]



SUMMARY

Syntax Description Example
( ) slur
[picture of music]

\( \) phrasing slur
[picture of music]

[ ] beam
[picture of music]

< \context Staff ... > more staffs
[picture of music]

-> -. articulations
[picture of music]

-\mf -\sfz dynamics
[picture of music]

\< \! crescendo
[picture of music]

\> \! decrescendo
[picture of music]

<< >> chord
[picture of music]

Now you know the basic ingredients of a music file, so this is the right moment to try your at hand at doing it yourself: try typing some simple examples, and experiment a little.

When you're comfortable with the basics, you might want to read the rest of this chapter. It continues in tutorial-style, but it is much more in-depth, dealing with more advanced topics such as lyrics, chords, orchestral scores and parts, fine tuning of output, polyphonic music, and integrating text and music.

Go back to index of LilyPond.

Please send GNU LilyPond questions and comments to lilypond-user@gnu.org.

Please send comments on these web pages to (address unknown)

Copyright (c) 1997--2002 Han-Wen Nienhuys and Jan Nieuwenhuizen.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.


This page was built from LilyPond-1.7.14 (development-branch) by

Buchan Milne <(address unknown)>, Thu Mar 6 21:11:35 2003 CET.