Next: , Up: MIDI output


10.3.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 {
     \context {
       \Score
       tempoWholesPerMinute = #(ly:make-moment 72 4)
       }
     }
}

The tempo can be specified using the \tempo command within the actual music, see Metronome marks. An alternative, which does not result in a metronome mark in the printed score, is shown in the example above. In this example the tempo of quarter notes is set to 72 beats per minute. This kind of tempo specification can not take dotted note lengths as an argument. In this case, break the dotted notes into smaller units. For example, a tempo of 90 dotted quarter notes per minute can be specified as 270 eighth notes per minute

tempoWholesPerMinute = #(ly:make-moment 270 8)

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 { }
  \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"
  }
}

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.


Next: , Up: MIDI output

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

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.