LilyPond Notation Reference: 3.5.3 The MIDI block

### 3.5.3 The MIDI block

To create a MIDI output file from a LilyPond input file, insert a `\midi` block, which can be empty, within the `\score` block;

>     \score {
>       … music …
>       \layout { }
>       \midi { }
>     }

Note: A `\score` block that, as well as the music, contains only a `\midi` block (i.e., without the `\layout` block), will only produce MIDI output files. No notation will be printed.

The default output file extension (`.midi`) can be changed by using the `-dmidi-extension` option with the `lilypond` command:

>     lilypond -dmidi-extension=mid MyFile.ly

Alternatively, add the following Scheme expression before the start of either the `\book`, `\bookpart` or `\score` blocks. See File structure.

>     #(ly:set-option 'midi-extension "mid")

#### See also

Notation Reference: File structure, Creating output file metadata.

Installed Files: ‘`scm/midi.scm`’.

#### Known issues and warnings

There are fifteen MIDI channels available and one additional channel (#10) for drums. Staves are assigned to channels in sequence, so a score that contains more than fifteen staves will result in the extra staves sharing (but not overwriting) the same MIDI channel. This may be a problem if the sharing staves have conflicting, channel-based, MIDI properties – such as different MIDI instruments – set.

Using a `midi` block with polymetric notation may cause unexpected barcheck warnings. In this case move the `Timing_translator` from the `Score` context to the `Staff` context within the `midi`block.

    \midi {
      \context {
        \Score
        \remove "Timing_translator"
      }
      \context {
         \Staff
         \consists "Timing_translator"
      }
    }

#### LilyPond — Notation Reference v2.22.2 (stable-branch).