Interface IMidiInstrument
An instrument that consumes MIDI events and renders audio: MIDI in via ProcessMidiEvent(MidiEvent), audio out via the ISampleProvider pull model. Implemented by the NAudio.Sampler engine, and the seam for any other MIDI-driven renderer (a synthesiser, a hosted VST instrument, …) to plug into the same playback hosts: SequencedMidiPlayer (timeline playback), OfflineMidiRenderer (faster-than-real-time render) and LiveMidiInstrument (live input from another thread).
public interface IMidiInstrument : ISampleProvider
- Inherited Members
- Extension Methods
Remarks
Unless an implementation documents otherwise, it is single-threaded:
ProcessMidiEvent(MidiEvent) and Read must be called from the same
thread, and events take effect on the audio rendered by subsequent
Read calls. Hosts that interleave events and audio within a block
(as SequencedMidiPlayer does) get sample-accurate timing by
rendering in segments between events.
Methods
AllSoundOff()
Stops all sound promptly (the MIDI "all sound off" panic), e.g. when a host seeks or stops. Implementations should avoid clicks where they can (a short fade) but must not let notes ring out naturally.
void AllSoundOff()
ProcessMidiEvent(MidiEvent)
Dispatches a MIDI event (note on/off, control change, pitch-bend, aftertouch, program change). Unsupported messages are ignored.
void ProcessMidiEvent(MidiEvent midiEvent)
Parameters
midiEventMidiEvent