BASS.NET API for the Un4seen BASS Audio Library

MidiInputDeviceClose Method

BASS.NET API for the Un4seen BASS Audio Library
Closes the Midi input device using the DeviceID.

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

public bool Close()

Return Value

Type: Boolean
on success, else .
Remarks

After you have called this method the Device is no longer valid and released. If the Midi Device IsStarted and currently recording messages this method will also Stop recording messages.

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

After you have closed the Midi input device you might open it again using the Open method.

Examples

Opens the Midi input device #0:
private MidiInputDevice _inDevice;
...
_inDevice = new MidiInputDevice(0);
_inDevice.MessageReceived += new MidiMessageEventHandler(InDevice_MessageReceived);
if (_inDevice.Open())
{
  if (!_inDevice.Start())
    MessageBox.Show(this, "Midi device could not be started! Error " + _inDevice.LastErrorCode.ToString(), "Midi Error");
}
else
  MessageBox.Show(this, "Midi device could not be opened! Error " + _inDevice.LastErrorCode.ToString(), "Midi Error");
...
// when done
if (_inDevice.IsStarted)
  _inDevice.Stop();
if (_inDevice.IsOpened)
  _inDevice.Close();
...
private void InDevice_MessageReceived(object sender, MidiMessageEventArgs e)
{
  if (e.IsShortMessage)
  {
    Console.WriteLine("{0} : {1}", e.ShortMessage.ID, e.ShortMessage.ToString());
  }
  else if (e.IsSysExMessage)
  {
    Console.WriteLine("{0} : {1}", e.SysExMessage.ID, e.SysExMessage.ToString());
  }
}
See Also

Reference