Search Results for

    Show / Hide Table of Contents

    Class InputDevice

    Represents an input MIDI device. More info in the Devices and Input device articles.
    Inheritance
    object
    MidiDevice
    InputDevice
    Implements
    IInputDevice
    IDisposable
    Inherited Members
    MidiDevice.ErrorOccurred
    MidiDevice.IsEnabled
    MidiDevice.Dispose()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.Multimedia
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class InputDevice : MidiDevice, IInputDevice, IDisposable

    Properties

    IsListeningForEvents

    Gets a value that indicates whether InputDevice is currently listening for incoming MIDI events.
    Declaration
    public bool IsListeningForEvents { get; }
    Property Value
    Type Description
    bool

    Name

    Gets the name of the current MIDI device.
    Declaration
    public override string Name { get; }
    Property Value
    Type Description
    string
    Overrides
    MidiDevice.Name

    RaiseMidiTimeCodeReceived

    Gets or sets a value indicating if MidiTimeCodeReceived event should be raised or not. Default value is true.
    Declaration
    public bool RaiseMidiTimeCodeReceived { get; set; }
    Property Value
    Type Description
    bool

    SilentNoteOnPolicy

    Gets or sets reaction of the input device on Note On events with velocity of zero. The default is NoteOn.
    Declaration
    public SilentNoteOnPolicy SilentNoteOnPolicy { get; set; }
    Property Value
    Type Description
    SilentNoteOnPolicy
    Exceptions
    Type Condition
    InvalidEnumArgumentException value specified an invalid value.

    WaitForCompleteSysExEvent

    Gets or sets a value indicating whether system exclusive event is treated as received only when it's completed or not. Default value is true.
    Declaration
    public bool WaitForCompleteSysExEvent { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    Some MIDI devices and MIDI subsystems of operating systems can split a system exclusive event into several parts on sending the event. If WaitForCompleteSysExEvent is set to true (default value), DryWetMIDI will wait until last part received, then the library will combine all event's parts into single MIDI event and fire the EventReceived event.

    For example, considering following separate events are received (here bytes in hex format):

    F0 7F 60

    40 F7

    With WaitForCompleteSysExEvent set to true, the EventReceived will be fired only once providing the single event:

    F0 7F 60 40 F7

    (F7 is a marker of a completed system exclusive event).

    With the property set to false you'll be notified with EventReceived event two times, so every part will be considered as a MIDI event.

    Methods

    Equals(object)

    Determines whether the specified object is equal to the current object.
    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj The object to compare with the current object.
    Returns
    Type Description
    bool true if the specified object is equal to the current object; otherwise, false.
    Overrides
    object.Equals(object)
    Remarks
    On Windows the method will just compare objects references. "True" equality check available on macOS only.

    GetAll()

    Retrieves all input MIDI devices presented in the system.
    Declaration
    public static ICollection<InputDevice> GetAll()
    Returns
    Type Description
    ICollection<InputDevice> All input MIDI devices presented in the system.

    GetByIndex(int)

    Retrieves an input MIDI device by the specified index.
    Declaration
    public static InputDevice GetByIndex(int index)
    Parameters
    Type Name Description
    int index Index of an input device to retrieve.
    Returns
    Type Description
    InputDevice Input MIDI device at the specified index.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException Index is less than zero or greater than devices count minus 1.
    MidiDeviceException An error occurred on the device.

    GetByName(string)

    Retrieves a first input MIDI device with the specified name.
    Declaration
    public static InputDevice GetByName(string name)
    Parameters
    Type Name Description
    string name The name of an input MIDI device to retrieve.
    Returns
    Type Description
    InputDevice Input MIDI device with the specified name.
    Exceptions
    Type Condition
    ArgumentException

    One of the following errors occurred:

    • name is null or contains white-spaces only.
    • name specifies an input MIDI device which is not presented in the system.
    MidiDeviceException An error occurred on the device.

    GetDevicesCount()

    Retrieves the number of input MIDI devices presented in the system.
    Declaration
    public static int GetDevicesCount()
    Returns
    Type Description
    int Number of input MIDI devices presented in the system.

    GetHashCode()

    Serves as the default hash function.
    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int A hash code for the current object.
    Overrides
    object.GetHashCode()

    GetProperty(InputDeviceProperty)

    Returns current value of the specified property attached to the current input device.
    Declaration
    public object GetProperty(InputDeviceProperty property)
    Parameters
    Type Name Description
    InputDeviceProperty property The property to get value of.
    Returns
    Type Description
    object The current value of the property.
    Remarks

    To get the list of properties applicable to input devices on the current operating system use GetSupportedProperties() method.

    Following table shows the type of value returned by the method for each property:

    PropertyType
    Product string
    Manufacturer string
    DriverVersion int
    UniqueId int
    DriverOwner string
    Exceptions
    Type Condition
    InvalidEnumArgumentException property specified an invalid value.
    ArgumentException property is not in the list of the properties supported for the current operating system.
    ObjectDisposedException The current InputDevice is disposed.
    MidiDeviceException An error occurred on the device. One of the cases when this exception can be thrown is device is not in the system anymore (for example, unplugged).
    InvalidOperationException The current InputDevice instance is created by DeviceRemoved event and thus considered as removed so you cannot interact with it.

    GetSupportedProperties()

    Returns the list of the properties supported by input devices on the current operating system.
    Declaration
    public static InputDeviceProperty[] GetSupportedProperties()
    Returns
    Type Description
    InputDeviceProperty[] The list of the properties supported by input devices on the current operating system.

    StartEventsListening()

    Starts listening for incoming MIDI events on the current input device.
    Declaration
    public void StartEventsListening()
    Exceptions
    Type Condition
    ObjectDisposedException The current InputDevice is disposed.
    MidiDeviceException An error occurred on device.
    InvalidOperationException The current InputDevice instance is created by DeviceRemoved event and thus considered as removed so you cannot interact with it.

    StopEventsListening()

    Stops listening for incoming MIDI events on the current input device.
    Declaration
    public void StopEventsListening()
    Exceptions
    Type Condition
    ObjectDisposedException The current InputDevice is disposed.
    MidiDeviceException An error occurred on device.
    InvalidOperationException The current InputDevice instance is created by DeviceRemoved event and thus considered as removed so you cannot interact with it.

    ToString()

    Returns a string that represents the current object.
    Declaration
    public override string ToString()
    Returns
    Type Description
    string A string that represents the current object.
    Overrides
    MidiDevice.ToString()

    Events

    EventReceived

    Occurs when a MIDI event is received.
    Declaration
    public event EventHandler<MidiEventReceivedEventArgs> EventReceived
    Event Type
    Type Description
    EventHandler<MidiEventReceivedEventArgs>

    MidiTimeCodeReceived

    Occurs when MIDI time code received, i.e. all MIDI events to complete MIDI time code are received.
    Declaration
    public event EventHandler<MidiTimeCodeReceivedEventArgs> MidiTimeCodeReceived
    Event Type
    Type Description
    EventHandler<MidiTimeCodeReceivedEventArgs>
    Remarks
    This event will be raised only if RaiseMidiTimeCodeReceived is set to true.

    Operators

    operator ==(InputDevice, InputDevice)

    Determines if two InputDevice objects are equal.
    Declaration
    public static bool operator ==(InputDevice inputDevice1, InputDevice inputDevice2)
    Parameters
    Type Name Description
    InputDevice inputDevice1 The first InputDevice to compare.
    InputDevice inputDevice2 The second InputDevice to compare.
    Returns
    Type Description
    bool true if the devices are equal, false otherwise.
    Remarks
    On Windows the operator will just compare objects references. "True" equality check available on macOS only.

    operator !=(InputDevice, InputDevice)

    Determines if two InputDevice objects are not equal.
    Declaration
    public static bool operator !=(InputDevice inputDevice1, InputDevice inputDevice2)
    Parameters
    Type Name Description
    InputDevice inputDevice1 The first InputDevice to compare.
    InputDevice inputDevice2 The second InputDevice to compare.
    Returns
    Type Description
    bool false if the devices are equal, true otherwise.
    Remarks
    On Windows the operator will just compare objects references. "True" inequality check available on macOS only.

    Implements

    IInputDevice
    IDisposable

    Extension Methods

    DevicesConnectorUtilities.Connect(IInputDevice, params IOutputDevice[])
    In this article
    Back to top 2024 / Generated by DocFX