hammerspoon2-docs
    Preparing search index...

    Class HSMIDIDevice

    A MIDI device or virtual source, created via hs.midi.deviceNamed() or hs.midi.virtualSourceNamed().

    Index

    Constructors

    Properties

    displayName: string

    The device's user-facing display name. Falls back to name if unavailable.

    identifier: string

    A unique identifier for this device object.

    isOnline: boolean

    Whether the device is currently online (connected).

    isVirtual: boolean

    Whether this is a virtual source (created via hs.midi.virtualSourceNamed()) rather than a physical device.

    manufacturer: string

    The device's manufacturer name, or an empty string if unavailable.

    model: string

    The device's model name, or an empty string if unavailable.

    name: string

    The device's raw name.

    Methods

    • Stops receiving from and releases all resources held by this device object. Called automatically when Hammerspoon reloads.

      Returns void

    • Sends a MIDI Identity Request. The device's reply, if any, arrives via the callback set with setCallback() as a systemExclusive message.

      Returns void

    • Sends a MIDI command to the device.

      Parameters

      • commandType: string

        The command type string

      • metadata: object

        A table of command-specific fields

      Returns boolean

      true if the command was sent, false if the device has no

    • Sends a System Exclusive command to the device.

      Parameters

      • command: string

        A hex string (whitespace ignored), e.g. "F0 7E 7F 06 01 F7"

      Returns void

    • Sets or removes the callback fired when a MIDI message is received. The callback receives five arguments: this device object, the device's name, the command type as a string (e.g. "noteOn", "controlChange", "systemExclusive" — see hs.midi.commandTypes for the full set), a human-readable description, and a metadata table of command-specific fields. when released, but some send noteOn with velocity 0 instead of noteOff.

      Parameters

      • fn:
            | (
                (
                    device: HSMIDIDevice,
                    deviceName: string,
                    commandType: string,
                    description: string,
                    metadata: object,
                ) => void
            )
            | null

        The function to call on each received message, or null to remove it

      Returns HSMIDIDevice

      This device object, for chaining