BASS.NET API for the Un4seen BASS Audio Library

MidiOutputDeviceOpen Method

BASS.NET API for the Un4seen BASS Audio Library
Opens the Midi output device using the DeviceID.

Namespace:  radio42.Multimedia.Midi
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

public bool Open()

Return Value

Type: Boolean
on success, else .
Remarks

After you have called this method the Device is being used and you might send messages to the device using the Send(MidiShortMessage) methods.

When you have subscribed to the MessageReceived event you'll get notified when the device is opened (Opened) and closed (Closed).

Once you're done with the device call Close to close the device and release it.

Examples

private MidiOutputDevice _outDevice;
...
_outDevice = new MidiOutputDevice(0);
_outDevice.MessageReceived += new MidiMessageEventHandler(OutDevice_MessageReceived);
if (!_outDevice.Open())
{
  MessageBox.Show(this, "Midi device could not be opened! Error " + _outDevice.LastErrorCode.ToString(), "Midi Error");
}
...
// when done
if (_outDevice.IsOpened)
  _outDevice.Close();
...
private void OutDevice_MessageReceived(object sender, MidiMessageEventArgs e)
{
  if (e.EventType == MidiMessageEventType.Opened)
  {
    Console.WriteLine("Midi device {0} opened.", e.DeviceID);
  }
  else if (e.EventType == MidiMessageEventType.Closed)
  {
    Console.WriteLine("Midi device {0} closed.", e.DeviceID);
  }
}
See Also

Reference