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.
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. |
boolean
Checks if the it is possible to cable from the outlet to the inlet.
outlet |
MxOutlet |
inlet |
MxInlet |
boolean
Registers an MxCableStrategy
outAdapterClassName |
an AbsMxAdapter subclass |
inAdapterClassName |
an AbsMxAdapter subclass |
strategy |
an MxCableStrategy |
this
This is an internally used Instr, created on demand.
Instr
the outlet where the cable starts
MxOutlet
the inlet where the cable goes to
MxInlet
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.
mapping function or nil if not set.
Set or get active status of cable. It is possible to deactivate a cable without deleting it.
boolean
internal. if the cable has been attached but the Mx has not yet updated
boolean
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.
an Environement
the MxCableStrategy for this connection.
MxCableStategy
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.
this
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.
bundle |
this
Free any resources. In practice everything is freed at stop and no resources are kept around.
bundle |
this
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.
v |
input value. |
mapped value