3.5.2 MIDI block

A \midi block must appear within a score block if MIDI output is required. It is analogous to the layout block, but somewhat simpler. Often, the \midi block is left empty, but it can contain context rearrangements, new context definitions or code to set the values of properties. For example, the following will set the initial tempo exported to a MIDI file without causing a tempo indication to be printed:

\score {
  ...music...
  \midi {
    \context {
      \Score
      tempoWholesPerMinute = #(ly:make-moment 72 4)
    }
  }
}

In this example the tempo is set to 72 quarter note beats per minute. This kind of tempo specification cannot take a dotted note length as an argument. If one is required, break the dotted note 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)

Context definitions follow precisely the same syntax as those within a \layout block. Translation modules for sound are called performers. The contexts for MIDI output are defined in ‘../ly/performer-init.ly’, see Other sources of information. For example, to remove the effect of dynamics from the MIDI output, insert the following lines in the \midi{ } block.

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

MIDI output is created only when a \midi block is included within a score block defined with a \score command.

\score {
  { …notes… }
  \midi { }
}

Other languages: deutsch, español, français, 日本語.

LilyPond — Notation Reference