MKtlDevice:
Filter:
Modality-toolkit/Classes (extension) | Libraries > Modality | External Control

MKtlDevice
ExtensionExtension

A class to provide a common interface for accessing external controllers

Description

MKtlDevice is an abstract interface to access an external device, e.g. a MIDI device such as a MIDI fader box, an HID device such as a joystick, devices or apps sending OSC, and so on.

Subclasses of MKtlDevice take care of accessing the device by its protocol.

This class is used mainly internally by MKtl, so you will not see it often.

Class Methods

.allProtocols

all protocols supported in Modality

.find

Find out which devices are attached.

Arguments:

protocols

Optional argument for which protocols to look for, e.g. [ 'hid' ]. By default, it will look for MKtlDevice.allProtocols.

post

flag to post results or not.

.initHardwareDevices

Look for available connected hardware devices.

Arguments:

force

Whether or not to look again if it was already done before.

protocols

which protocols to look for.

.open

Tries to open a device with the name (of the MKtl).

Arguments:

name

The short name of the device to open.

parentMKtl

The instance of MKtl that will refer to this device.

multiIndex

when multiple identical devices are present, the index of the device to open.

Returns:

either an instance of MKtlDevice, or nil if no device was found.

.subFor

Return the subclass that matches the protocol given.

Arguments:

protocol

The protocol to look for, e.g. \midi or \hid.

Returns:

a subclass of MKtlDevice

.protocol

The protocol of this subclass of MKtlDevice

Returns:

a Symbol

Instance Methods

.mktl

The MKtl that this MKtlDevice belongs to.

Returns:

an instance of MKtl.

.name

The short name of the device.

Returns:

a Symbol

.deviceName

The full device name of the device.

Returns:

a String

.closeDevice

Close the device and clean up anything that it used.

.trace

Print incoming data from the MKtlDevice or not.

Arguments:

bool

a Boolean whether it should be on or off.

.traceRunning

a Boolean whether or not the MKtlDevice is currently tracing.

.explore

When opening a device that is not known yet by MKtl, you want to explore the device. See for a full tutorial: How_to_create_a_description_file

Arguments:

bool

a Boolean to turn this on or off.

.exploring

a Boolean whether or not the device is currently being explored.

.createDescriptionFile

Create and open a description file for this MKtlDevice, after exploring it.

.initElements

Initialize all elements and hook them up to the hardware elements.

.initCollectives

Initialize all collectives and hook them up to the hardware elements.

.cleanupElementsAndCollectives

De-initialize all elements and collectives.