Creating MIDI files - GNU LilyPond
Description: GNU LilyPond

Next: MIDI block, Up: MIDI output

#### 10.7.1 Creating MIDI files

To create a MIDI from a music piece of music, add a `\midi` block to a score, for example,

    \score {
      ...music...
      \midi { \tempo 4=72 }
    }

The tempo is specified using the `\tempo` command. In this example the tempo of quarter notes is set to 72 beats per minute.

If there is a `\midi` command in a `\score`, only MIDI will be produced. When notation is needed too, a `\layout` block must be added

    \score {
      ...music...
      \midi { \tempo 4=72 }
      \layout { }
    }

Ties, dynamics, and tempo changes are interpreted. Dynamic marks, crescendi and decrescendi translate into MIDI volume levels. Dynamic marks translate to a fixed fraction of the available MIDI volume range, crescendi and decrescendi make the volume vary linearly between their two extremes. The fractions can be adjusted by `dynamicAbsoluteVolumeFunction` in Voice context. For each type of MIDI instrument, a volume range can be defined. This gives a basic equalizer control, which can enhance the quality of the MIDI output remarkably. The equalizer can be controlled by setting `instrumentEqualizer`, or by setting

    \set Staff.midiMinimumVolume = #0.2
    \set Staff.midiMaximumVolume = #0.8

To remove dynamics from the MIDI output, insert the following lines in the `\midi{}` section.

    \midi {
      ...
      \context {
        \Voice
        \remove "Dynamic_performer"
        \remove "Span_dynamic_performer"
      }
    }

##### Bugs

Unterminated (de)crescendos will not render properly in the midi file, resulting in silent passages of music. The workaround is to explicitly terminate the (de)crescendo. For example,

    { a\< b c d\f }

will not work properly but

    { a\< b c d\!\f }

will.

This page is for LilyPond-2.8.8 (stable-branch).

Other languages: English.
Using automatic language selection.