Search Results for

    Show / Hide Table of Contents

    Class OutputDevice

    Represents an output MIDI device. More info in the Devices and Output device articles.
    Inheritance
    object
    MidiDevice
    OutputDevice
    Implements
    IOutputDevice
    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 OutputDevice : MidiDevice, IOutputDevice, IDisposable

    Properties

    Name

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

    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 output MIDI devices presented in the system.
    Declaration
    public static ICollection<OutputDevice> GetAll()
    Returns
    Type Description
    ICollection<OutputDevice> All output MIDI devices presented in the system.

    GetByIndex(int)

    Retrieves an output MIDI device by the specified index.
    Declaration
    public static OutputDevice GetByIndex(int index)
    Parameters
    Type Name Description
    int index Index of an output device to retrieve.
    Returns
    Type Description
    OutputDevice Output 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 output MIDI device with the specified name.
    Declaration
    public static OutputDevice GetByName(string name)
    Parameters
    Type Name Description
    string name The name of an output MIDI device to retrieve.
    Returns
    Type Description
    OutputDevice Output 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 output MIDI device which is not presented in the system.
    MidiDeviceException An error occurred on the device.

    GetDevicesCount()

    Retrieves the number of output MIDI devices presented in the system.
    Declaration
    public static int GetDevicesCount()
    Returns
    Type Description
    int Number of output 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(OutputDeviceProperty)

    Returns current value of the specified property attached to the current output device.
    Declaration
    public object GetProperty(OutputDeviceProperty property)
    Parameters
    Type Name Description
    OutputDeviceProperty 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 output 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
    Technology OutputDeviceTechnology
    VoicesNumber int
    NotesNumber int
    Channels FourBitNumber[]
    Options OutputDeviceOption
    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 output devices on the current operating system.
    Declaration
    public static OutputDeviceProperty[] GetSupportedProperties()
    Returns
    Type Description
    OutputDeviceProperty[] The list of the properties supported by output devices on the current operating system.

    PrepareForEventsSending()

    Prepares output MIDI device for sending events to it allocating necessary resources.
    Declaration
    public void PrepareForEventsSending()
    Remarks
    It is not needed to call this method before actual MIDI data sending since first call of SendEvent(MidiEvent) will prepare the device automatically. But it can take some time so you may decide to call PrepareForEventsSending() before working with device.
    Exceptions
    Type Condition
    MidiDeviceException An error occurred on device.

    SendEvent(MidiEvent)

    Sends a MIDI event to the current output device.
    Declaration
    public void SendEvent(MidiEvent midiEvent)
    Parameters
    Type Name Description
    MidiEvent midiEvent MIDI event to send.
    Exceptions
    Type Condition
    ObjectDisposedException The current OutputDevice is disposed.
    ArgumentNullException midiEvent is null.
    MidiDeviceException An error occurred on device.

    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()

    TurnAllNotesOff()

    Turns off all notes that were turned on by sending Note On events, and which haven't yet been turned off by respective Note Off events.
    Declaration
    public void TurnAllNotesOff()
    Exceptions
    Type Condition
    ObjectDisposedException The current OutputDevice is disposed.
    MidiDeviceException An error occurred on device.

    Events

    EventSent

    Occurs when a MIDI event is sent.
    Declaration
    public event EventHandler<MidiEventSentEventArgs> EventSent
    Event Type
    Type Description
    EventHandler<MidiEventSentEventArgs>

    Operators

    operator ==(OutputDevice, OutputDevice)

    Determines if two OutputDevice objects are equal.
    Declaration
    public static bool operator ==(OutputDevice outputDevice1, OutputDevice outputDevice2)
    Parameters
    Type Name Description
    OutputDevice outputDevice1 The first OutputDevice to compare.
    OutputDevice outputDevice2 The second OutputDevice 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 !=(OutputDevice, OutputDevice)

    Determines if two OutputDevice objects are not equal.
    Declaration
    public static bool operator !=(OutputDevice outputDevice1, OutputDevice outputDevice2)
    Parameters
    Type Name Description
    OutputDevice outputDevice1 The first OutputDevice to compare.
    OutputDevice outputDevice2 The second OutputDevice 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

    IOutputDevice
    IDisposable
    In this article
    Back to top 2024 / Generated by DocFX