LilyPond audio playback in Linux | Composing Music with LilyPond

By | 2014/09/14

It is possible to have very acceptable audio playback under Linux with LilyPond scores. As one would press ‘play’ in Sibelius or Finale, the same can be done with a LilyPond score in the app Frescobaldi. Check it out!

How does it sound? Here is a string quartet example:

This is a screenshot of frescobaldi where this was created:


Note: this assumes you have a LilyPond score with the midi block enabled and midi instruments defined! If you are new to LilyPond you may want to check out their docs or the #lilypond channel for help.

A sample LilyPond file as a demo is available here.

1. First, install timidity, the FluidR3 soundfont, and frescobaldi if you do not have these already. [For frescobaldi, you may wish to grab the latest from github.]

Debian / Ubuntu example:

$ sudo apt-get install timidity fluid-soundfont-gm fluid-soundfont-gs frescobaldi

2. Next, edit /etc/timidity.cfg to enable the fluid R3 soundfont, as well as making changes to better the audio quality.


opt EFresamp=l
opt EFreverb=g,65
opt EFchorus=s
opt s48kHz
opt p64a
opt anti-aliased=a
opt Os

#opt EFreverb=25
#opt EFchorus=0
# latency config. set to B2,8 if your cpu can't do B2,5
opt B2,5

# By default, try to use the instrument patches from freepats:
#source /etc/timidity/freepats.cfg

# alternatively, you can use the fluid-soundfont:
source /etc/timidity/fluidr3_gm.cfg
source /etc/timidity/fluidr3_gs.cfg

3. Next, start the timidity service.

$ sudo service timidity start

4. Now in the frescobaldi app, check the midi output preferences are set to timidity port 0.


5. In your LilyPond score, be sure to have the midi instrument set for each staff.


\set Staff.midiInstrument = #"violin"

Also, be sure to have the midi block enabled in the score.

  \midi { } 

If all is well, pressing PLAY on the MIDI controls in frescobaldi will now playback your score with acceptable proof-quality results.

Below is an example track produced with the above settings by simply clicking File > Export Audio from frescobaldi and uploaded to soundcloud.

Rock on,