MxCable:
Filter:
Mx/Classes (extension) | Mx

MxCable
ExtensionExtension

a connection between an MxUnit's outlet and another MxUnit's inlet

Description

Cables represent a connection between an outlet and an inlet. These may be audio, control or frame rate, but also event stream (Pbind), FFT chains or objects types like Env, Rect or Image. Currently implemented are audio, control and frame rate.

Note: In addition to cabling objects together, scripts, documents or units may communicate directly or via shared environment variables. This allows ad hoc communication, while the cables represent fixed links. See MxUnit varPooling.

Cables may be freely connected and disconnected while playing.

Connections are made using MxCableStrategy objects. These objects solve the connecting and disconnecting from two objects based on the behavior of the outlet and inlet as defined in the objects MxInlet and MxOutlet which are created in the driver file for that object.

MxCableStrategy are defined in MxCable.initClass. More connection types will be solved and become available as the project progresses.

An MxCable has a little environment in which it stores state. The cable strategy functions are invoked in this environment and may store variables like ~synth.

Class Methods

.new

Arguments:

outlet

The outlet that the cable starts from.

inlet

The inlet that the cable goes to.

mapping

See mapping below

active

Activate or deactivate a cable without deleting it.

Returns:

boolean

.hasStrategy

Checks if the it is possible to cable from the outlet to the inlet.

Arguments:

outlet

MxOutlet

inlet

MxInlet

Returns:

boolean

.register

Registers an MxCableStrategy

Arguments:

outAdapterClassName

an AbsMxAdapter subclass

inAdapterClassName

an AbsMxAdapter subclass

strategy

an MxCableStrategy

Returns:

this

.instr

This is an internally used Instr, created on demand.

Returns:

Instr

Instance Methods

.outlet

the outlet where the cable starts

Returns:

MxOutlet

.inlet

the inlet where the cable goes to

Returns:

MxInlet

.mapping

This allows customized scaling and shaping of values from the outlet spec to the inlet spec. A mapping of nil (which is the default) will scale from the outlet spec to the inlet spec. eg. \freq => \pchRatio will automatically map correctly, as will \unipolar => \freq. mapping, if set, should be a function that take a value and returns a value.

Returns:

mapping function or nil if not set.

.active

Set or get active status of cable. It is possible to deactivate a cable without deleting it.

Returns:

boolean

.pending

internal. if the cable has been attached but the Mx has not yet updated

Returns:

boolean

.state

an Environment used by the MxCableStrategy connect and disconnect functions. This stores any state or resources like ~synth so they are available for the disconnect.

Returns:

an Environement

.init

.asString

.strategy

the MxCableStrategy for this connection.

Returns:

MxCableStategy

.setInitial

Some cable strategies need to set an initial value on the target inlet at the time that the changes are being enacted. For instance when a cable is connected it does not immediately set the value on the target inlet until the Mx calls .update and the first the units are spawned and then the cables are spawned. setInitial allows the cable to set a value for the unit which the unit needs when it spawns, because the unit must spawn before the cable.

Returns:

this

.spawnToBundle

Not all cables use synths on the server. For relationships that exist only in the language, functions may be added to the bundle which enact the actual connection.

Arguments:

bundle

MixedBundle

Returns:

this

.stopToBundle

Disconnecting the cable, stopping any cable synthsetcc.

Arguments:

bundle

MixedBundle

Returns:

this

.freeToBundle

Free any resources. In practice everything is freed at stop and no resources are kept around.

Arguments:

bundle

MixedBundle

Returns:

this

.map

Map the value from the outlet spec to the inlet spec. Audio to audio does not perform any mapping. If a mapping function is set then it is used instead.

Arguments:

v

input value.

Returns:

mapped value