Thank you Trevor. That makes sense.
I have the following code:
----
import abjad
voice = abjad.Voice("c'4 d'4 e'4 f'4", name="Voice")
midi = abjad.Block("midi")
score = abjad.Score([voice], name="Score")
midi_score = abjad.LilyPondFile([score, midi])
abjad.show(midi_score)
----
Which seems correct, adds the midi block and compiles without errors. But abjad.Score creates the score as a context and abjad.LilyPondFile concatenates the midi block to that context:
\version "2.24.0"
\language "english"
\context Score = "Score"
<<
\context Voice = "Voice"
{
c'4
d'4
e'4
f'4
}
>>
\midi {}
Lilypond seems to require the \midi block to be nested in a \score block and no midi output is produced. I am unsure how to achieve this.
iain