# Adding expression to LilyPond MIDI output

The Artemis Orchestra Competition uses LilyPond as its musical input description language.  LilyPond is primarily a means to produce beautifully typeset music scores; but it can also produce MIDI (musical instrument digital interface) output for 'proofhearing' the scores.  Unfortunately, LilyPond's MIDI output is not very good: it obeys the notes and any explicit metronome and dynamic markings, but that's about it.

The result sounds like this.

Obviously, to enter the Artemis competition, we needed something that used a lot more of the detail available from the LilyPond input.

LilyPond has an extension language (Scheme, a statically scoped variant of LISP).  So I (Peter Chubb) wrote some scheme code that interpreted some of the more commonly used marks in a musical score.  The idea was to rewrite the LilyPond input before LilyPond interpreted it, so, for example, slurs and phrases were obeyed, and trills were fully expanded.

After using articulate, the result sounds like this.

# The Articulate Script

The resulting script is called articulate (indications such as staccato or tenuto are termed  articulations).

• Any note not under a slur or phrasing mark, and not marked with an explicit articulation, is shortened by ac:normalFactor (default 7/8)
• Any note marked staccato is shortened by ac:staccatoFactor (default 1/2)
• Any note marked tenuto gets its full value.
• Appogiaturas are made to take half the value of the note following, without taking dots into account (so in \appoggiatura c8 d2. the c will take the time of a crotchet)
• Trills and turns are expanded. The algorithm tries to choose notes within the time of the current tempo that lead to each twiddle being around 1/8 seconds; this can be adjusted with the ac:maxTwiddleTime variable.
• rall, poco rall and a tempo are observed.  It'd be fairly trivial to make accel. and stringendo and so on work too.

## How to use Articulate

The simplest way to use Articulate is to use the lilywrap shell script in the tarball, viz:

\$ lilywrap inputfile.ly

\$ timidity inputfile.midi

lilywrap rewrites the input file by adding an \include "articulate.ly line after any \header block, then inserts \unfoldRepeats  \articulate before the body of any \score block.

## A short example

\include "articulate.ly"
\score {
\unfoldRepeats \articulate <<
\context Staff {
\set Staff.midiInstrument="clarinet"
\relative c' {
\time 4/4 \tempo 4=100
c4-. c4( d e |
f\trill) g\turn a b |
c1--
}
}
>>
\midi {}
}

# Where do I get it?

Articulate was first released to the lilypond-user mailing list — see the thread starting there for discussion, etc.  Updates will also be sent there, or to the lilypond-devel mailing list.

The script is now maintained as part of the LilyPond source, and is distributed with the LilyPond package.

Last modified:  Fri May  4 10:53:25 EST 2012