[icon]

GNU LilyPond

Welcome to the home of the GNU Music Typesetter

What is LilyPond
General information
Simple examples
Complex examples
Download
GNU/Linux binaries
Windows
Source code
Documentation
Tutorial
Manual
Glossary
other ...

Support
Mailing lists
Search
WikiWiki
FAQs

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

Node:Lyrics and chords, Next:, Previous:The first real tune, Up:Tutorial



Lyrics and chords

In this section we show how to typeset a song. This file is included as flowing.ly.

\header {
        title = "The river is flowing"
        composer = "Traditional"
}
\include "paper16.ly"
melody = \notes \relative c' {
        \partial 8
        \key c \minor
        g8 |
        c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
        c4 c8 d [es () d] c4 | d4 es8 d c4.
        \bar "|."
}

text = \lyrics {
        The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
        ri -- ver is flo -- wing down to the sea.
}

accompaniment =\chords {
        r8
        c2:3- f:3-.7 d:min es4 c8:min r8
        c2:min f:min7 g:7^3.5 c:min }

\score {
        \simultaneous {
          %\accompaniment
          \context ChordNames \accompaniment

          \addlyrics
            \context Staff = mel {
              \property Staff.noAutoBeaming = ##t
              \property Staff.automaticMelismata = ##t
              \melody
            }
            \context Lyrics \text
        }
        \midi  { \tempo 4=72 }
        \paper { linewidth = 10.0\cm }
}

The result would look this.1

The river is flowing
Traditional

[picture of music]

Again, we will dissect the file line by line.

***


        \header {

Information about the music you are about to typeset goes into a \header block. The information in this block is not used by LilyPond, but it is passed into the output. ly2dvi uses this information to print titles above the music.

***


        title = "The river is flowing"
        composer = "Traditional (?)"
the \header block contains assignments. In each assignment, a variable is set to a value. Lexically, both the variable name and the assigned value are strings. The values have to be quoted here, because they contain spaces. The variable names could also be put within quotes but it is not necessary.

***


        \include "paper16.ly"

Smaller size for inclusion in a book.

***


        melody = \notes \relative c' {

The structure of the file will be the same as the previous one, a \score block with music in it. To keep things readable, we will give names to the different parts of music, and use the names to construct the music within the score block.

***


        \partial 8

The piece starts with an anacrusis of one eighth.

***


        \key c \minor
The key is C minor: we have three flats.

***


        c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
        c4 c8 d [es () d] c4 | d4 es8 d c4.
        \bar "|."

We use explicit beaming. Since this is a song, we turn automatic beams off, and use explicit beaming where needed.

***


        }

This ends the definition of melody.

***


        text = \lyrics {

Another identifier assignment. This one is for the lyrics. Lyrics are formed by syllables that have duration, and not by notes. To make LilyPond parse words as syllables, switch it into lyrics mode with \lyrics. Again, the brace after \lyrics is a shorthand for \sequential {.

***


  The4 ri -- ver is flo- __ wing,  flo -- wing and gro -- wing, the
  ri- ver is flo- __ wing down to the sea.
}

The syllables themselves are separated by spaces. You can get syllable extenders by entering __, and centered hyphens with --. We enter the syllables as if they are all quarter notes in length (hence the 4), and use a feature to align the syllables to the music, which obviously isn't all quarter notes.

***


        accompaniment =\chords {

We'll put chords over the music. To enter them, there is a special mode analogous to \lyrics and \notes mode, where you can give the names of the chords you want, instead of listing the notes comprising the chord.

***


        r8

There is no accompaniment during the anacrusis.

***


        c2:3- f:3-.7

A chord is started by the tonic of the chord. The first one lasts a half note. An unadorned note creates a major triad. Since a minor triad is wanted, 3- is added to modify the third to be small. 7 modifies (adds) a seventh, which is small by default to create the f a c es chord. Multiple modifiers must be separated by dots.

***


        d:min es4 c8:min r8

Some modifiers have predefined names, e.g. min is the same as 3-, so d-min is a minor d chord.

***


        c2:min f:min7 g:7^3.5 c:min }

A named modifier min and a normal modifier 7 do not have to be separated by a dot. Tones from a chord are removed with chord subtractions. Subtractions are started with a caret, and they are also separated by dots. In this example, g:7^3.5 produces a minor seventh. The brace ends the sequential music.

***


        \score {
                \simultaneous {

We assemble the music in the \score block. Melody, lyrics and accompaniment have to sound at the same time, so they should be \simultaneous.

***


        %\accompaniment

Chord mode generates notes grouped in \simultaneous music. If you remove the comment sign, you can see the chords in normal notation: they will be printed as note heads on a separate staff. To print them as chords names, they have to be interpreted as being chords, not notes. This is done with the following command:

***


        \context ChordNames \accompaniment

Normally, the notes that you enter are transformed into note heads. Note heads alone make no sense, they need surrounding information: a key signature, a clef, staff lines, etc. They need context. In LilyPond, these symbols are created by objects called `interpretation contexts'. Interpretation contexts exist for generating notation (`notation context') and for generating sound (`performance context'). These objects only exist during a run of LilyPond.

By default, LilyPond will create a Staff context for you. If you would remove the % sign in the previous line, you would see that mechanism in action.

We don't want that default here, because we want chord names. The command above explicitly creates an interpretation context of ChordNames type to interpret the music \accompaniment.

***


        \addlyrics

The lyrics should be aligned with the melody. This is done by combining both with \addlyrics. \addlyrics takes two pieces of music (usually a melody and lyrics, in that order) and aligns the syllables of the second piece under the notes of the first piece. If you would reverse the order, the notes would be aligned on the lyrics, which is not very useful, and looks silly.

***


        \context Staff = mel {

The first argument of \addlyrics is the melody. We instantiate a Staff context explicitly: should you choose to remove the comment before the "note heads" version of the accompaniment, the accompaniment will be on a nameless staff. The melody has to be on staff different from the accompaniment. This is accomplished by giving the melody and accompaniment staffs different names.

***


        \property Staff.noAutoBeaming = ##t

An interpretation context has variables, called properties, that tune its behavior. One of the variables is noAutoBeaming. Setting this Staff's property to ##t, which is the boolean value true, turns the automatic beaming mechanism off for the current staff.

LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a language from the LISP family. You can learn more about Scheme at http://www.scheme.org. It is used to represent data throughout the whole program. The hash-sign (#) accesses GUILE directly: the code following the hash-sign is evaluated as Scheme. The boolean value true is #t in Scheme, so for LilyPond true looks like ##t.

If Scheme scares you, don't worry. You don't need to know Scheme to create beautiful sheet music.

***


        \property Staff.automaticMelismata = ##t

Similarly, we don't want to print a syllable when there is a slur. This sets up \addlyrics to not put lyrics under each separate note while there is a slur.

***


          \melody
        }

Finally, we put the melody on the current staff. Note that the \property directives and \melody are grouped in sequential music, so the property settings are done before the melody is processed.

***


        \context Lyrics \text

The second argument of \addlyrics is the text. The text also should not land on a Staff, but on a interpretation context for syllables, extenders, hyphens etc. This context is called Lyrics.

***


        \midi  { \tempo 4=72}

MIDI (Musical Instrument Digital Interface) is a standard for connecting and recording digital instruments. So a MIDI file is like a tape recording of an instrument. The \midi block makes the music go to a MIDI file, so you can listen to the music you entered. It is great for checking the music. Whenever you hear something weird, you probably hear a typing error.

Syntactically, \midi is similar to \paper { }, since it also specifies an output method. You can specify the tempo using the \tempo command, in this case the tempo of quarter notes is set to 72 beats per minute.

***


        \paper { linewidth = 10.0\cm }

We also want notation output. The linewidth is short so the piece will be set in two lines.

Footnotes

  1. The titling and font size shown may differ, since the titling in this document is not generated by ly2dvi.


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 lilypond@packages.debian.org

Copyright (c) 1997--2001 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.4.12 (stable-branch) by

Anthony Fok <lilypond@packages.debian.org>, Tue Mar 12 01:35:39 2002 HKT.