Sends a system-exclusive MIDI message to the specified MIDI output device.
Namespace: radio42.Multimedia.Midi
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax
Parameters
- handle
- Type: SystemIntPtr
Handle to the MIDI output device. - headerPtr
- Type: SystemIntPtr
Pointer to a MIDI_HEADER structure that identifies the MIDI buffer.
Return Value
Type: MIDIErrorReturns 0 if successful or an error code otherwise. For possible error values see MIDIError.
Examples
private MIDIOUTPROC _midiProc; private IntPtr _midiOutHandle; ... // Open the Midi device #2 _midiProc = new MIDIOUTPROC(MyMidiProc); MIDIError ret = Midi.MIDI_OutOpen(ref _midiOutHandle, 2, _midiProc, 0); if (ret == MIDIError.MIDI_OK) { // device opened and ready } ... // When not needed anymore...stop the device Midi.MIDI_OutReset(_midiOutHandle); // and close the device Midi.MIDI_OutClose(_midiOutHandle); ... private void SendShortMessage(int message) { MIDI_OutShortMsg(_midiOutHandle, message); } private void SendSysExMessage(byte[] data) { MIDI_HEADER header = new MIDI_HEADER(data); header.Prepare(false, _midiOutHandle); // If the header was perpared successfully. if (header.HeaderPtr != IntPtr.Zero) { // send a system-exclusive message to the output device Midi.MIDI_OutLongMsg(_midiOutHandle, header.HeaderPtr); } } public void MyMidiProc(IntPtr handle, MIDIMessage msg, IntPtr instance, IntPtr param1, IntPtr param2) { // handle all Midi messages here if (msg == MIDIMessage.MOM_OPEN) { // nothing to do } else if (msg == MIDIMessage.MOM_CLOSE) { // handle is from now on invalid } else if (msg == MIDIMessage.MOM_DONE) { // process the message... // param1 will contain the pointer to the MIDI_HEADER MIDI_HEADER header = new MIDI_HEADER(param1); // process the header if needed ... // and finally unprepare the header header.Unprepare(false, handle); } }
See Also