[ << General input and output ] | [Top][Contents][Index][ ? ] | [ Spacing issues >> ] | ||
[ < MIDI output ] | [ Up : MIDI output ] | [ > ] |
3.5.1 Creating MIDI files
To create a MIDI output file from a LilyPond input file, add a
\midi
block to a score, for example,
\score { ...music... \midi { } }
If there is a \midi
block in a \score
with no
\layout
block, only MIDI output will be produced. When
notation is needed too, a \layout
block must be also be
present.
\score { ...music... \midi { } \layout { } }
Pitches, rhythms, ties, dynamics, and tempo changes are interpreted and translated correctly to the MIDI output. 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 effect of dynamic markings on the MIDI output can be removed completely, see MIDI block.
The initial tempo and later tempo changes can be specified
with the \tempo
command within the music notation. These
are reflected in tempo changes in the MIDI output. This command
will normally result in the metronome mark being printed, but this
can be suppressed, see Metronome marks. An alternative way
of specifying the inital or overall MIDI tempo is described below,
see MIDI block.
[ << General input and output ] | [Top][Contents][Index][ ? ] | [ Spacing issues >> ] | ||
[ < Creating MIDI files ] | [ Up : Creating MIDI files ] | [ MIDI block > ] |
Instrument names
The MIDI instrument to be used is specified by setting the
Staff.midiInstrument
property to the instrument name.
The name should be chosen from the list in MIDI instruments.
\new Staff { \set Staff.midiInstrument = #"glockenspiel" ...notes... }
\new Staff \with {midiInstrument = #"cello"} { ...notes... }
If the selected instrument does not exactly match an instrument from
the list of MIDI instruments, the Grand Piano ("acoustic grand"
)
instrument is used.
Selected Snippets
Changing MIDI output to one channel per voice
When outputting MIDI, the default behavior is for each staff to represent one MIDI channel, with all the voices on a staff amalgamated. This minimizes the risk of running out of MIDI channels, since there are only 16 available per track.
However, by moving the Staff_performer
to the Voice
context, each voice on a staff can have its own MIDI channel, as is
demonstrated by the following example: despite being on the same staff,
two MIDI channels are created, each with a different
midiInstrument
.
\score { \new Staff << \new Voice \relative c''' { \set midiInstrument = #"flute" \voiceOne \key g \major \time 2/2 r2 g-"Flute" ~ g fis ~ fis4 g8 fis e2 ~ e4 d8 cis d2 } \new Voice \relative c'' { \set midiInstrument = #"clarinet" \voiceTwo b1-"Clarinet" a2. b8 a g2. fis8 e fis2 r } >> \layout { } \midi { \context { \Staff \remove "Staff_performer" } \context { \Voice \consists "Staff_performer" } \context { \Score tempoWholesPerMinute = #(ly:make-moment 72 2) } } }
Known issues and warnings
Changes in the MIDI volume take place only on starting a note, so crescendi and decrescendi cannot affect the volume of a single note.
Not all midi players correctly handle tempo changes in the midi output. Players that are known to work include MS Windows Media Player and timidity.
[ << General input and output ] | [Top][Contents][Index][ ? ] | [ Spacing issues >> ] | ||
[ < Creating MIDI files ] | [ Up : Creating MIDI files ] | [ MIDI block > ] |