Para gerar um arquivo midi você deve adicionar uma seção \midi dentro da seção \score.
O andamento é definido com o comando tempoWholesPerMinute = #(ly:make-moment X Y), onde X é a quantidade de Y por minuto e Y é a unidade de tempo.
Exemplo 31.1.
\version "2.10.20"
\score {
{
<<
\new Staff = "violino" <<
\relative c' { \clef treble c2 d }
>>
\new PianoStaff = piano <<
\new Staff \relative c' { \clef treble <c e g>2 <b d g>2}
\new Staff \relative c { \clef bass c 4b a g }
>>
>>
}
\midi {tempoWholesPerMinute = #(ly:make-moment 90 4) }
}
Exemplo 31.2.
\version "2.10.20"
\score {
{
<<
\new Staff = "violino" <<
\relative c' { \clef treble c2 d }
>>
\new PianoStaff = piano <<
\new Staff \relative c' { \clef treble <c e g>2 <b d g>2}
\new Staff \relative c { \clef bass c 4b a g }
>>
>>
}
\midi {tempoWholesPerMinute = #(ly:make-moment 90 4) }
\layout {}
}
O instrumento MIDI é definido com o comando \set Staff.midiInstrument "instrumento".
\set Staff.midiInstrument = "violin"
O nome do instrumento deve ser escolhido da lista de instrumentos MIDI suportados:
Tabela 31.1. Instrumentos MIDI
| acoustic grand | contrabass | lead 7 (fifths) |
| bright acoustic | tremolo strings | lead 8 (bass+lead) |
| eletric grand | pizzicato strings | pad 1 (new age) |
| honky-tonk | orchestral strings | pad 2 (warm) |
| electric piano 1 | timpani | pad 3 (polysynth) |
| electric piano 2 | string ensemble 1 | pad 4 (choir) |
| harpsichord | string ensemble 2 | pad 5 (bowed) |
| clav | synthstrings 1 | pad 6 (metallic) |
| celesta | synthstrings 2 | pad 7 (halo) |
| glockenspiel | choir aahs | pad 8 (sweep) |
| music box | voice oohs | fx 1 (rain) |
| vibraphone | synth voice | fx 2 (soundtrack) |
| marimba | orchestra hit | fx 3 (crystal) |
| xylophone | trumpet | fx 4 (atmosphere) |
| tubular bells | trombone | fx 5 (brightness) |
| dulcimer | tuba | fx 6 (goblins) |
| drawbar organ | muted trumpet | fx 7 (echoes) |
| percussive organ | french horn | fx 8 (sci-fi) |
| rock organ | brass section | sitar |
| church organ | synthbrass 1 | banjo |
| reed organ | synthbrass 2 | shamisen |
| accordion | soprano sax | koto |
| harmonica | alto sax | kalimba |
| concertina | tenor sax | bagpipe |
| acoustic guitar (nylon) | baritone sax | fiddle |
| acoustic guitar (steel) | oboe | shanai |
| electric guitar (jazz) | english horn | tinkle bell |
| electric guitar (clean) | bassoon | agogo |
| electric guitar (muted) | clarinet | steel drums |
| overdriven guitar | piccolo | woodblock |
| distorted guitar | flute | taiko drum |
| guitar harmonics | recorder | melodic tom |
| acoustic bass | pan flute | synth drum |
| electric bass (finger) | blown bottle | reverse cymbal |
| electric bass (pick) | shakuhachi | guitar fret noise |
| fretless bass | whistle | breath noise |
| slap bass 1 | ocarina | seashore |
| slap bass 2 | lead 1 (square) | bird tweet |
| synth bass 1 | lead 2 (sawtooth) | telephone ring |
| synth bass 2 | lead 3 (calliope) | helicopter |
| violin | lead 4 (chiff) | applause |
| viola | lead 5 (charang) | gunshot |
| cello | lead 6 (voice) |
Se o instrumento especificado não figurar na lista, ou se ele não for especificado será usado o Grand Piano ("acoustic grand").