radio42.Multimedia.MidiMidiInputDevice
Namespace: radio42.Multimedia.Midi
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.2
The MidiInputDevice type exposes the following members.
Name | Description | |
---|---|---|
![]() | MidiInputDevice(Int32) |
Creates a new instance of a MidiInputDevice.
|
![]() | MidiInputDevice(Int32, MIDIINPROC) |
Creates a new instance of a MidiInputDevice.
|
Name | Description | |
---|---|---|
![]() | AutoPairController |
Gets or Sets if Channel Messages (a MidiShortMessage) with a ControlChange should automatically be paired (default is None).
|
![]() ![]() | ColtrollerPairMatrix |
Sets the controller pair matrix to automatic combine any ShortMessage with a StatusType of ControlChange.
|
![]() | Device |
Returns the device handle for this input device.
|
![]() | DeviceID |
Returns the device id (number) which was used to create this instance.
|
![]() | IsDisposed |
Returns , if this class is being disposed.
|
![]() | IsOpened |
Returns if the Midi input device is opened - else .
|
![]() | IsStarted |
Returns if the Midi input device is started and recording messages - else .
|
![]() | LastErrorCode |
Returns the last Midi error code (see MIDIError for possible values).
|
![]() ![]() | MessageFilter |
Gets or Sets the filter to be applied (messages types which should be suppressed).
|
![]() | ProcessErrorMessages |
Gets or Sets if erroneous Midi messages should also be processed.
|
![]() | ShortMessage |
Gets the current (last) MidiShortMessage which was received from the Device.
|
![]() | SysExBufferSize |
Gets or Sets the maximum buffer size for system-exclusive messages (between 2 and 65536, default is 1024).
|
![]() | SysExMessage |
Gets the current (last) MidiSysExMessage which was received from the Device.
|
![]() | User |
User instance data to be used when providing system-exclusive messages.
|
Name | Description | |
---|---|---|
![]() | AddSysExBuffer |
Creates and adds a system exclusive buffer to the midi device.
|
![]() ![]() | Close |
Closes the Midi input device using the DeviceID.
|
![]() | Connect |
Connects this input device to a MIDI thru or output device.
|
![]() | Disconnect |
Disconnects this input device from a MIDI thru or output device.
|
![]() | Dispose |
Releases all managed and unmanaged resources used by this class.
|
![]() | Finalize |
Destructor of the MidiInputDevice for finalization code.
(Overrides ObjectFinalize.) |
![]() ![]() | GetDeviceCount |
Returns the total number of available Midi input devices.
|
![]() ![]() | GetDeviceDescription |
Returns the name of the given input device ID.
|
![]() ![]() | GetDeviceDescriptions |
Returns all available Midi input device names.
|
![]() ![]() | GetInfo |
Determines the capabilities of a specified MIDI input device.
|
![]() ![]() ![]() | GetMidiPorts |
Returns all available Midi input port IDs.
|
![]() | IsPairedControllerMessage |
Is the given MidiShortMessage a paired controller message?
|
![]() ![]() | Open |
Opens the Midi input device using the DeviceID.
|
![]() ![]() | Start |
Starts recording messages from the Midi input device using the DeviceID.
|
![]() ![]() | Stop |
Stops recording messages from the Midi input device using the DeviceID.
|
Name | Description | |
---|---|---|
![]() | MessageReceived |
Event handler used to notify that the input device has received a message or the status has changed.
|
After you have called the Open method the Device is being used. However, Midi messages are not yet recorded and received. To start recording Midi messages call the Start method.
It is a good idea to subscribe to the MessageReceived event handler before calling Open and Start. The property MessageFilter might be used to suppress sending certain events. The MidiMessageEventArgs contains a MidiMessageEventType which allows you to react to all possible scenarios and to process all Midi messages and events.
Call the Stop method to stop recording and receiving Midi message. Once you're done with the device call Close to close the device and release it.
using radio42.Multimedia.Midi; ... private MidiInputDevice _inDevice; ... // open and start a certain Midi input device private void OpenAndStartDevice(int device) { _inDevice = new MidiInputDevice(device); _inDevice.AutoPairController = true; _inDevice.MessageFilter = MIDIMessageType.SystemRealtime | MIDIMessageType.SystemExclusive; _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"); } // stop and close the Midi input device private void StopAndCloseDevice() { if (_inDevice != null && _inDevice.IsStarted) { _inDevice.Stop(); _inDevice.Close(); _inDevice.MessageReceived -= new MidiMessageEventHandler(InDevice_MessageReceived); } } 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()); } else 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); } else if (e.EventType == MidiMessageEventType.Started) { Console.WriteLine("Midi device {0} started.", e.DeviceID); } else if (e.EventType == MidiMessageEventType.Stopped) { Console.WriteLine("Midi device {0} stopped.", e.DeviceID); } }