Running LilyPond

Creating PDF output

There are currently two different ways you can run LilyPond on your document.

The default one (by pressing the toolbar button or Ctrl+M) is to output a PDF preview document. This document contains clickable notes and other objects. If you click on a note or other object, Frescobaldi will put your textcursor in the correct place (and even open the document for you if needed).

In the LilyPond menu, you can also find the option Run LilyPond (publish). This option also runs LilyPond, but with clickable notes disabled. The resulting PDF is much smaller and better suitable for distribution via e-mail or the Web. With large musical scores, disabling the clickable notes can make the PDF many times smaller.

While LilyPond is running, you can follow its progress in the log view. If LilyPond encounters errors, you can click on the messages to place the text cursor in the offending line and column. If there are many errors you want to correct without waiting for LilyPond to be finished, you can click the LilyPond button again to abort the running LilyPond process.

When you want to run LilyPond on your text document, it needs to be saved to disk first, so LilyPond can read it. (Currently, you can not run LilyPond on non-local LilyPond documents.) If your document has not been saved yet, Frescobaldi asks you to save it to a local file. If your document has been modified, Frescobaldi asks you to save it first.

If you want Frescobaldi to always save your last modifications before running LilyPond, you can go to Settings » Configure Frescobaldi... and check the option Save document when LilyPond is run.

After a succesful LilyPond run, you will see some buttons appear at the bottom of the Log view.

If LilyPond created a PDF, a button will be shown to open the PDF in the default PDF viewer, and a button to (directly!) print the PDF by sending it to the lpr command. (You can configure a different print command in Settings » Configure Frescobaldi... » Paths » Print command.)

Creating MIDI output

If LilyPond created a MIDI file, a button will be shown to play the MIDI in the default MIDI player. If you want LilyPond to create a MIDI file, add a \midi { } line in your \score { } section, like this:

\score {
  \relative c'' {
    \time 7/4
    c2 bes4 a2 g a bes4 a( g) f2
  }
  \addlyrics {
    Join us now and share the soft -- ware!
  }
  \layout { }
  \midi { }
}

(Be sure to also add a \layout { } line if you add a \midi { } line, otherwise LilyPond will not generate a PDF.)

Also an email button is shown, allowing you to easily send the source and output documents to someone else using your default mail client.

LilyPond files that include other files

When working on large music scores, it might be possible that you divide the musical score in different files, and include them from a "master" file. Such a master file, named e.g. NewSong.ly, might look like:

\version "2.12.0"

\header {
  title = "New Song"
}

\include "LayoutSettings.ly"

\include "SopranoPart.ly"
\include "PianoPart.ly"

\score {
  <<
    \new Staff = "soprano" \sopranoMusic
    \new Lyrics \lyricsto "soprano" \sopranoText
    \new PianoStaff <<
      \new Staff = "right" \rightHandMusic
      \new Staff = "left" \leftHandMusic
    >>
  >>
}

The files SopranoPart.ly and PianoPart.ly just contain the music definitions and LayoutSettings.ly has some settings for font and page layout etc. Neither one of them has a \score { } section in it. So pressing Ctrl+M and running LilyPond while you are working on such an included document might not make much sense, as it would probably not generate a PDF output file (the document only contains music expressions that are assigned to variables).

In such cases, you can tell Frescobaldi that another file is the "master" file for the current document. When you run LilyPond, Frescobaldi will run LilyPond on the master document rather than the current document. So in SopranoPart.ly and PianoPart.ly you add a special line that is just a LilyPond comment. But Frescobaldi will read the line and understand that you want LilyPond to be run on the master file. Here is an example how SopranoPart.ly would look like:

\version "2.12.0"

% Soprano part

sopranoMusic = \relative c' {
  c d e f g f e d
}

sopranoText = \lyricmode {
  Boer er ligt een kip in't wa -- ter
}

%%master: NewSong.ly

The last line %%master: <filename> directs Frescobaldi to compile NewSong.ly instead of the current document when LilyPond is started.

There are two related special comments: %%master-preview: and %%master-publish:. Those will only compile the named file in either preview or publish mode. That can be useful if you include several movements or e.g. hymns in a master file, where every source file has it's own score section. If you e.g. use %%master-publish, running in preview mode will just show the current document, but running in publish mode will compile the master document so you get a view on the whole score or book.

Last modified: 16 jan 2009