Lilypond

From www.oscarvandillen.com

Jump to: navigation, search

Contents

Definition

Lilypond is a MediaWiki-extension that makes it possible to "type" notation in wiki-pages like text.

Simple use

The example below is coded simply as

<lilypond>\relative c' { d e f a d bes es d cis a cis e g f e d }</lilypond>

\relative c' { d e f a d bes es d cis a cis e g f e d }

Note that the relative c' = central c is set as a reference tone, and that all notes following are the versions that are closest to the one before them.

This example being encoded with <lilypond> there is visual rendering, but no playback.


The same example, still simple but encoded with <lilymidi> and hence with playback, click to play:

<lilymidi>\relative c' { d e f a d bes es d cis a cis e g f e d }</lilymidi>

\relative c' { d e f a d bes es d cis a cis e g f e d }

When notes have to go to an octave higher than the closest one, the symbol ' (apostrophe) is added once or several times, to go to a lower octave one or more , commas are attached to the note.

Lilypond assumes 4/4 time signature and a quarter note unless other symbols change these default values. 1 means whole note, 2 half note, 4 quarter note, etc. and r simply means a rest. Once a rhythmic value is set, the notes following are assumed to be of the same value. A tie is produced by the symbol ~ (tilde).


The following example uses these basic notation symbols, and presents a variation on the melody above:

<lilymidi>\relative c' { d e8 f g a b cis d d, f'4 es d cis a,16 cis e g a cis r8 r16 a, e' cis' g'8 f e8~ e4 r8 d,, d'''4 }</lilymidi>

To test midi playback, always click to play:

\relative c' { d e8 f g a b cis d d, f'4 es d cis a,16 cis e g a cis r8 r16 a, e' cis' g' f e8~ e4 r8 d,, d'''4 }

Quarter tones

To notate quarter tones, special names are used. The following example ascends quarter-tone-chromatically from c to e.

This example contains dotted half notes; note that a dot . is always used after a note's value.

As an auditive reference, low c's are added for better appreciation of the microtones, click to play:

<lilymidi>\relative c'' { c,1 c'2. c,4 deseh'2. c,4 des'2. c,4 deh'2. c,4 d'2. c,4 dih'2. c,4 dis'2. c,4 disih'2. c,4 e'1 c,1 }</lilymidi>

\relative c'' { c,1 c'2. c,4 deseh'2. c,4 des'2. c,4 deh'2. c,4 d'2. c,4 dih'2. c,4 dis'2. c,4 disih'2. c,4 e'1 c,1 }

Code layout

For reasons of better overview, all the longer examples below are not coded in one line anymore.

Note that every opening bracket, whether { , [, ( or < will have to be closed at some point by < , ) , ] and } in the proper place and order.

In the following, more complicated examples, code lines are layouted basically for easier reading and correction, as an <enter> does not affect the functioning of the code.

Building chords

Building chords can be accomplished by the use of < and > as is shown in the example below, these chords are built top-down, relative to c' and the key of d-minor is added:

<lilymidi>
\version "2.12.2"

 \relative c' {
 \key d \minor
  < f' d a d,, >  < e bes g g, >  < d a f a,~ >  < cis g e a, >
  < d f, d bes >  < e gis, d bes > 2  < cis g e a, > 4
  < d f, d d, > 1
 \bar "|."
}
</lilymidi>


\version "2.12.2"
</p>
<pre>\relative c' {
\key d \minor
 < f' d a d,, >  < e bes g g, >  < d a f a,~ >  < cis g e a, >
 < d f, d bes >  < e gis, d bes > 2  < cis g e a, > 4
 < d f, d d, > 1 
\bar "|."
</pre>
<p>}

To make this into a piano notation, notes should be divided over two staves. This time, the chords are built bottom-up, relative to c''. At the end, a double bar is placed, by using the code \bar "|."

With a slightly more "pianistically" treated left hand this becomes:

<lilymidi>
\version "2.12.2"

\relative c'' {
 \new PianoStaff <<
  \new Staff {
  \clef treble 
  \key d \minor
   < a d f >  < g bes e >  < f a d >  < e g cis >
   < d f d' >  < d gis e' > 2  < e g cis > 4
   < d f d' > 1
  }
  \new Staff {
  \clef bass 
  \key d \minor
   d,4 g a a, bes2 bes'4 a4 d,1  
  }
 >>
 \bar "|."
}
</lilymidi>


\version "2.12.2"
</p><p>\relative c'' {
</p>
<pre>\new PianoStaff <<
 \new Staff {
 \clef treble 
 \key d \minor
  < a d f >  < g bes e >  < f a d >  < e g cis >
  < d f d' >  < d gis e' > 2  < e g cis > 4
  < d f d' > 1
 }
 \new Staff {
 \clef bass 
 \key d \minor
  d,4 g a a, bes2 bes'4 a4 d,1 
 }
>>
\bar "|."
</pre>
<p>}

Notating percussion

The following examples make use of a 3-line custom staff and a percussion clef (which technically uses the center staffline as c').

Single part notation

This single part example starts off with a pickup, coded \partial, and has two grace notes, coded \grace. The last three eighth notes have been linked together with square brackets, starting and ending after the notes concerned.

<lilymidi>
\version "2.12.2"
\relative c' { 
\new Staff
 \with {
  \override StaffSymbol #'line-count = #3 }
\clef percussion
\time 2/2

 \partial 8
  e8
  a,4. \grace { e'32 } c8 a4 e'8 e | 
  a,4. \grace { e'32 } c8 a[ e' e]
 \bar "|."
}
</lilymidi>


\version "2.12.2"
\relative c' { 
\new Staff
</p>
<pre>\with {
 \override StaffSymbol #'line-count = #3 }
</pre>
<p>\clef percussion
\time 2/2
</p>
<pre>\partial 8
 e8
 a,4. \grace { e'32 } c8 a4 e'8 e | 
 a,4. \grace { e'32 } c8 a[ e' e]
\bar "|."
</pre>
<p>}

Multiple part notation

The following example uses a staff-system of three percussion parts, e.g three djembé's, indicating left and right hand strokes by using \addlyrics per staff:

<lilymidi>
\version "2.12.2"
\new StaffGroup
<<
\new Staff 
 \with {
  \override StaffSymbol #'line-count = #3
  }
 \relative c' { 
 \clef percussion
 \time 2/2
  a4 c8 c a4 e'8 e | 
  a,4 c8 c a4 e'8 e 
 \bar "|."
 }
  \addlyrics {
    R R L R R L R R L R R L
 }
\new Staff 
 \with {
  \override StaffSymbol #'line-count = #3
  }
 \relative c' { 
 \clef percussion
 \time 2/2
  r4 r8 a a4 a | 
  a r8 a a4 a
 \bar "|."
 }
  \addlyrics {
    L R L R L R L
 }
\new Staff 
 \with {
  \override StaffSymbol #'line-count = #3
  }
 \relative c' { 
 \clef percussion
 \time 2/2
  c4 e8 e a,4 e'8 e | 
  c c e e a,4 e'8 e
 \bar "|."
 }
  \addlyrics {
    R R L R R L R L R L R R L
 }
>>
</lilymidi>


\version "2.12.2"
\new StaffGroup
<<
\new Staff 
</p>
<pre>\with {
 \override StaffSymbol #'line-count = #3
 }
\relative c' { 
\clef percussion
\time 2/2
 a4 c8 c a4 e'8 e | 
 a,4 c8 c a4 e'8 e 
\bar "|."
}
 \addlyrics {
   R R L R R L R R L R R L
}
</pre>
<p>\new Staff 
</p>
<pre>\with {
 \override StaffSymbol #'line-count = #3
 }
\relative c' { 
\clef percussion
\time 2/2
 r4 r8 a a4 a | 
 a r8 a a4 a
\bar "|."
}
 \addlyrics {
   L R L R L R L
}
</pre>
<p>\new Staff 
</p>
<pre>\with {
 \override StaffSymbol #'line-count = #3
 }
\relative c' { 
\clef percussion
\time 2/2
 c4 e8 e a,4 e'8 e | 
 c c e e a,4 e'8 e
\bar "|."
}
 \addlyrics {
   R R L R R L R L R L R R L
}
</pre>
<p>>>

Advanced use

The following example makes use of ties by ~, slurs by ( and ) , differently connected tuplets using "times" (plural), [ and ], double sharps and flats, dots and double dots, as well as clef-changes using "clef" and time signature changes using "time" (singular). Naturals to correct the alterations are automatically generated when appearing within one bar, otherwise they are forced by ! or in brackets with ? :

<lilymidi>
\version "2.12.2"
\relative c, 
{
 \time 3/4
 \clef bass
 \times 4/5
  { c8[ r gis' r e'16 fis]( }
 \times 2/3 
  { gis8 ais bis }
 \time 2/4
 \clef tenor
  cisis64 fis dis8..  d4~ d4.) 
 \clef treble
  a''!8(
 \time 6/8
  as4 ges,32 bes32 d?32 ges32~ ges8. fes16 es f
   \time 5/4
  d8.) r16
   \clef bass
 \grace 
  { as,32([ des, ases] } des,2.) c16 r8.
 \bar "|."
}
</lilymidi>


\version "2.12.2"
\relative c, 
{
</p>
<pre>\time 3/4
\clef bass
\times 4/5
 { c8[ r gis' r e'16 fis]( }
\times 2/3 
 { gis8 ais bis }
\time 2/4
\clef tenor
 cisis64 fis dis8..  d4~ d4.) 
\clef treble
 a''!8(
\time 6/8
 as4 ges,32 bes32 d?32 ges32~ ges8. fes16 es f
  \time 5/4
 d8.) r16
  \clef bass
\grace 
 { as,32([ des, ases] } des,2.) c16 r8.
\bar "|."
</pre>
<p>}

Extended functions

Lilypond is enormously more powerful than the examples above, and has many more possibilities.

LilyPond notation can be embedded in wikitext, by enclosing it within <lilypond>...</lilypond> tags. If the notation is enclosed within <lilymidi>...</lilymidi> tags, the image will be clickable, and the link will download the MIDI file. Users' browsers may have to be configured to play MIDI files by means of plug-ins or external applications.

Another option is to use <lilybook>...</lilybook> tags. This allows full control over Lilypond settings, and it creates a full page of music.

Complicated example of Renaissance music transcription

The following complicated (not clickable) example was taken from the Lilypond manual, and demonstrates some of its most advanced possibilites:

page

More information and manual

Experimenting in the Lilypond sandbox

Personal tools