Can I import a LilyPond file into my graphical notation editor?

Yes, but you may have to convert it to MIDI first, losing a lot of detail.

Imports and exports: imbalance of trade

Transferring files between music editors has always been difficult.  Even the two behemoths of the field – Sibelius and Finale – don’t make it easy to transfer. between them.

The programming effort involved in writing an importer or exporter is immense.  The programmer has to study all possible aspects of the format, and decide how to translate them.  It is therefore not totally surprising that the export options are sparse.  If you are developing a notation package, why expend programmer time to make it easy for your customers to leave?  On the other hand, adding import options gives you a competitive edge.

As an example, for many years, Sibelius could import the MusicXML format, but not export.  If you really needed this capability, you could buy the Dolet plugin.  This changed in 2011: Sibelius 7 added native XML export, while MakeMusic (the company which makes Finale) purchased the Dolet software and made it freely available.

MusicXML is a good (but not perfect) way to migrate files between different programs.  However, the program we are currently concerned with is LilyPond.  As of November 2012, there is no way to export from LilyPond to MusicXML.  If this capability is ever added, you should use it.

MIDI: the last resort

However, LilyPond files can be converted to audio, as MIDI (Musical Instrument Digital Interface) files.  Most music editors can import these.

There is no command to export a LilyPond file to MIDI (instead of the more common choice of typesetting it to PDF).  Instead, you need a \midi block in the music.  See the GNU LilyPond Notation Reference – Creating MIDI files for specifics.

Existing file collections may come with source files for generating MIDI.  For example, the King Arthur music used in previous examples made pre-generated MIDI files available, and also provided the file “Arthur-MIDIs.ly” for re-creating them.

Why is MIDI the last resort?

Before editing or printing notation imported from MIDI, it is vital to understand its limitations.  For details, see Why didn’t this MIDI file import properly?

More LilyPond

  1. What is a LilyPond file?
  2. How do I read this LilyPond file?
  3. How do I edit a LilyPond file?
  4. How do I transpose a LilyPond part?
  5. Can I import a LilyPond file into my graphical notation editor?

How do I transpose a LilyPond part?

By using the appropriate form of “\transpose” in the source code.

Still looking at “King Arthur”, the trumpets play a few movements in Act 1, and few more in Act 5.  It would be dreadful to let them get bored, so let’s give them the violin 1 and 2 parts for some of the bombastic movements.

This post discusses the mechanics of duplicating parts for different instruments, not the art of orchestration.  Doubling parts like this is better than nothing, but a good arrangement will make better use of individual instruments.

The first movement of Act 1 looks like a good start. So, open “Act1/Trumpet.ily”. In the original arrangement it contains four tacet movements before any staffs, clefs or notes appear.

%% ACT I

\tocItem \markup { \AWodenFirst " " \italic {(\Ltacet)}}

\tocItem \markup { \ALotIsCast " " \italic {(\Ltacet)}}

\tocItem \markup { \ABraveSouls " " \italic {(\Ltacet)}}

\tocItem \markup { \AWodensHall " " \italic {(\Ltacet)}}

\tocItem \AMSymphony
\score  { % MILITARY SYMPHONY
  \keepWithTag #'Part
  \new StaffGroup = "Vents" \with {
    systemStartDelimiter = #'SystemStartBrace }
  <<
    \new Staff = "Vents 1" \transpose c d <<
      \clef treble \MAC
      \include "F/global.ily" \include "F/trumpetI.ily"
    >>
    \new Staff = "Vents 2" \transpose c d <<
      \clef treble \MAC
      \include "F/global.ily" \include "F/trumpetII.ily"
    >>
  >>

  \header {
    piece = \AMSymphony
  }
  \layout {
    \context { \StaffGroup
      \consists "Instrument_name_engraver"
    }
  }
} %ends AF military symphony

Continue reading “How do I transpose a LilyPond part?”

How do I edit a LilyPond file?

With any text editor, as long as you know the rules.

Learn the words

LilyPond does take some learning.  Fortunately it is well-documented.  Read at least the first two links at lilypond.org/manuals.html.  Before you dive into a massive score, try notating a few short tunes.  At any time, I have at least a dozen 32-bar folk tunes I can’t actually play because they’re bad photocopies of bad handwriting ((If you don’t have any scrappy folk tunes that need rewriting, try hanging around at disreputable folk sessions and you’ll soon acquire some.)).

Continue reading “How do I edit a LilyPond file?”

How do I read this LilyPond file?

By opening it in the LilyPond application and typesetting it to a PDF.

Where do I find the LilyPond application?

LilyPond is free under the GNU General Public License ((To learn more about the General Public License and the philosophy behind it, visit the Free Software Foundation at www.fsf.org.)).  You can find installers for Mac OS, Windows and Unix/Linux at lilypond.org/download.html.

  1. Click on the link for your operating system.
  2. Follow the instructions for “Compiling a file”, to make sure everything works.
  3. Take note of the instructions for “Running on the command-line”.  You don’t need them right now, but you eventually will.

Continue reading “How do I read this LilyPond file?”

What is a LilyPond file?

It’s a text format for storing sheet music, and many existing classical pieces have already been notated using it.

Example

Here is the some LilyPond source code.  It may be written in any text editor.  It may look intimidating, but scroll down to see what happens to it.

\version "2.16.0"
\include "english.ly"
\header {
	title = "Drowsy Maggie"
	composer = "Traditional"
}

\relative c' {
	\key e \minor
	\time 2/2

	\repeat volta 2 {
		e4 b'8 e, d' e, b' e, |
		e4 b'8 e, a fs d fs |
		e4 b'8 e, d' e, b' e, |
	}

	\alternative {
		{ b'8 a b cs d a fs d }
		{ b'8 a b cs d a fs a }
	}

	\bar "||" \break

	d4 fs8 d cs4 e8 cs |
	d8 e fs g a fs g e |
	d4 fs8 d cs4 e8 cs |
	b8 a b cs d a fs a |

	d4 fs8 d cs4 e8 cs |
	d8 e fs g a fs g e | 
	a8 fs g e fs d e cs |
	b8 a b cs d a fs d |

	\bar "||"

	e1

	\bar "|."
}

We can compile the source code using the LilyPond program.  It outputs nicely formatted sheet music, as seen below:

Continue reading “What is a LilyPond file?”