MKtlElement:
Filter:
Modality-toolkit/Classes (extension) | Libraries > Modality

MKtlElement
ExtensionExtension

An element of an MKtl.

Description

A named element within an MKtl, which typically represents a slider, a button, a joystick axis etc etc. It has a description with a deviceSpec (e.g. \midiNum for a midi faderbox slider), and a type (e.g. \slider). It also has a deviceValue (in the deviceSpec range), and a value (in range 0.0 - 1.0). It is mostly created automatically when an MKtl is made.

See also Creating_Custom_Elements_and_Groups.

Class Methods

.types

The types of elements used in descs so far:

.new

Creates a new instance, with a name, a description and optionally a source.

The source arg is usually an MKtl.

Instance Methods

.deviceSpec

The spec that maps between the numerical value range the device sends and/or receives, and the the unipolar range in the MKtlElement.

.defaultValue

The element's default value

.deviceValue

Get and set the element's deviceValue in units and range of the deviceSpec

.value

Get and set the element's current value in normalised range

Arguments:

newval

a Float between 0.0 and 1.0

.valueNoSend

.deviceValueNoSend

Set the element's deviceValue or value without sending back to the hardware device

.valueAction

.deviceValueAction

Set the element's deviceValue or value and perform its action.

Discussion:

deviceValue_ and value_ will not cause the action to be performed. deviceValueNoSend_ and valueNoSend_ will also not trigger the action.

If the element is has an output to send back to the device, value_ and deviceValue_ will send the deviceValue to the device, while deviceValueNoSend_ and valueNoSend_ allow just setting the value without sending it (which is sometimes necessary).

Example: Control a knob on the Behringer BCF2000

.addAction

Add an action to the element's action. Adding multiple actions will create a FunctionList.

.removeAction

Remove an action from the list of current actions. The action to be removed has to be the exact same function object.

.doAction

Perform the actions related to this element. This includes the action instance variable, and the actions of its parents, up to the containing MKtl.

Arguments:

sendValue

Whether or not to send the value out to the device if this is an output element.

.enabled

ask whether this element's action is currently enabled

.enable

.disable

enable and disable this element's action. works hierarchically in MKtlElementGroup as well:

.resetAction

Set action to nil.

.asStream

pattern support - convert MKtlElement to a stream

.embedInStream

pattern support - embed MKtlElement in a stream.

.elemDesc

An Event or dictionary with a description of the element. Typically contains a deviceSpec, a type, and

.gui

Create a gui for this element.

Examples

Sending data back to MIDI device, one should use MAbstractElement: value_ :

Classic knobs rotating demo for BCF: