The MIDI output takes into account:
The sounding accidental values provided by @accid.ges on notes and accid.
The sounding octave values provided by @oct.ges on note.
Transposing instrument information provided by @trans.semi on staffDef.
With the command-line tool, for generating a MIDI file with the default options, you need to do: