At the Sounding Edge: LilyPond, Part 1

An introduction to this music notation software for Linux.
Putting in the Pond

LP's developers state that building the program from source code is a complicated process, and they advise installing a pre-built package, conveniently providing a list of available packages on the LilyPond Web site. Packages currently are available for Red Hat, Debian, Mandrakelinux and Slackware systems. The common source tarball also is available. However you install it, once installation is complete you can start using LP.

The following examples assume LP in version 2.2.0 or higher. LP is a moving target with a brisk development pace; your mileage may vary if you run the examples with another version.

Jumping In

The LilyPond documentation includes a good tutorial guide to the basics of using the language interface. The following code is a fairly simple example of a LilyPond source file:


  % This is a comment.

  \score {			
    \notes { c'4 e' g' b'}
  }

In this example, the \score element prepares a default 5-line staff with treble clef and common (4/4) time signature. Its braces hold the data to be represented in the score. In this example, the score includes a sequence of notes that starts from middle C and arpeggiates a Cmaj7 chord in quarter notes. Pitch elements include pitch name (c), an octave specifier (') and a duration value (4). If no duration value is given for the next element, it takes its duration from the preceding note.

To create a PostScript graphics file from this code, simply process it with the LP compiler, as follows:


  lilypond lj-ex-1.ly

Figure 1 shows the output file, lj-ex-1.ps, as displayed by GhostView.

Figure 1. Basic LilyPond

Now we add a few more language elements to create something a little more complete:


  \header{
          title = "Simple"
          composer = "DLP 2004"
          }
  \score {
    \notes { c'4 e' g'8 a'8 b'4 c''1 \bar "|."}
    \midi {\tempo 4=132}
    \paper { }
  }

The new elements include a header block, further specifications for rhythm and pitch, a specifier for a double-bar and directives for MIDI output (with tempocontrol) and LilyPond's default print-ready formats. Figure 2 displays the compiled output, again in the GhostView PostScript file viewer.

Figure 2. More Symbols and Signs

Notation-savvy musicians may notice that I did not specify a bar line expected between b' and c''. As advertised, LilyPond automates many aspects of the score layout but always allows the possibility of customizing the output to virtually any degree.

As a last code example, here's a complex fragment in two staves with considerably more complicated rhythms:


  \version "2.2.0"
  \header{
        title = "Toccata Vivace"
        subtitle = "For Flute and Bassoon"
        composer = "DLP 2004"
	}

	Flute = \notes \context Voice = Flute {
        \set Staff.instrument = "Flute"
        \set Staff.midiInstrument = "flute"
        \key c \major
        \clef treble
        \time 3/4 \partial4 r4 | r8. g''16 -\staccato ges'' -\staccato f'' -\staccato b'-\mf -\accent fis''-\accent r e'-\sf  r8 |
        r4 \times 2/3 { ees'16 -\staccato d'' -\staccato des'' } f''8\< ~ f''4\! \bar "||"
	} 

	Bassoon = \notes \context Voice = Bassoon { 
        \set Staff.instrument = "Bassoon" 
        \set Staff.midiInstrument = "bassoon"
        \key c \major
        \clef bass
        \time 3/4 \partial4 r16 cis'-\mf  -\staccato c' -\staccato d' -\staccato |
        f-\accent e'-\accent r a,-\sf  r4 r8 \times 2/3 { a,16 -\staccato g -\staccato cis'\< ~ } |
        cis'4\! \>~ \times 2/3 { cis'8\! ( b bes, } d,4-\accent) \bar "||"
	}

	FluteStaff = \context Staff = FluteStaff <<
        	\Flute
		>>


        BassoonStaff = \context Staff = BassoonStaff <<
              	\Bassoon
            	>>

      	\score {
          	<<
                  \FluteStaff
                  \BassoonStaff
                >>
        \paper { }
        \midi {\tempo 4 = 160}
  }

Figure 3 displays the PostScript output. With a little thought you should be able to figure out the logic of the code. One point of assistance: LP uses 'is' to indicate a sharp, 'es' to indicate a flat. The other new elements are fairly self-explanatory, especially with reference to Figure 3, and I refer the interested reader to LilyPond's documentation to clarify any remaining obscurity.

Figure 3. A More Complicated Score Engraved by LP

______________________

Similis sum folio de quo ludunt venti.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: At the Sounding Edge: LilyPond, Part 1

Anonymous's picture

Musical Notation has not only evolved over centuries, it is also facing numerous dilemmas: Instruction to the performer vs. compositional concept, difficulties with tuning systems, and so on. I own about 6 kilograms of books about the subject, so I am not surprised that there can be fiery discussions about notation programs.

My favourite tools for notating music will always be some sheets of paper and a 4b pen, and I will never touch an eraser when composing or arranging.

Author's reply

Anonymous's picture

I agree, music notation has become a wildly tangled garden, and it is indeed a difficult thing to come up with a program that could satisfy all possible demands.

Btw, your last comment reminded me of Morton Feldman's statement that he always composed with pen & ink. He claimed it made him really think about whether he should write down what he was considering...

Best,

dp

Re: At the Sounding Edge: LilyPond, Part 1

Anonymous's picture

An archive of folk tunes in LilyPond format is at http://sniff.numachi.com/~rickheit/dtrad/.

no comments

Anonymous's picture

no comments

LilyPond formated archive

Anonymous's picture

Unfortunately, the site owner at http://sniff.numachi.com/~rickheit/dtrad/ no longer provides songs in the LilyPond format.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix