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

MxUnitApp
ExtensionExtension

scripting interface object for a unit

Description

A unit holds an object like an Instr, NDef, Bus, Spline, SFP (soundfile player) etc.

Each unit

Instance Methods

.name

Name is implemented by the object driver and should usually return a useful unique readable name.

Returns:

string

.source

The object you added

Returns:

the object

.inlets

returns an MxIOletsApp which can be used to access specific the units inlets by name or iterated over like an array.

Returns:

an MxIOletsApp

.outlets

returns an MxIOletsApp which can be used to access specific outlets by name or iterated over like an array.

.i

shorthand for .inlets

Returns:

an MxIOletsApp

.o

shorthand for .outlets

Returns:

an MxIOletsApp

>>

Connect the default out of this unit to "that".

Arguments:

that

an inlet, a channel fader

.point

channel@slot position on the grid. master channel is inf

Returns:

Point

.remove

Disconnect and remove the unit from the grid

Returns:

this

.moveTo

Move the unit to a different position. This moves it to a new Group as well. Overwrites anything that might be there.

Arguments:

point

channel@slot

Returns:

this

.moveBy

Move the unit by a channel@slot offset. Overwrites anything that might be there.

Arguments:

vector

Point representing the offset. eg. 1@0 will move it to the next channel

.dup

Duplicate the object to the slot directly below it, insert an open space if there is already something there.

Arguments:

num

How many times to duplicate

Returns:

unit or array of units

.copy

Copies the unit to a specific point, overwriting anything that might be there.

Arguments:

toPoint

destination point

Returns:

new unit

.copyBy

Copies the unit by a channel@slot offset, overwriting anything that might be there.

Arguments:

vector

channel@slot offset Point

Returns:

new unit

.disconnect

Disconnect all inlets and outlets of this unit

Returns:

this

.channel

the channel object that this unit is in

Returns:

.use

Each unit has an environment which the driver can use to store state variables. The proto of this environment is the driver handler functions, so these methods are also available. This can be used by a unit (for instance a Document for live coding) to enter the variable space of another unit. see also MxUnit varPooling

Arguments:

function

like Environmenent.use, a function executed in the unit's environment.

Returns:

result of the function

.stop

Stop the unit from playing. The Mx will continue to play

Returns:

this

.play

Play the unit if it is not already playing. Does not start the Mx

Returns:

this

.respawn

Stops then restarts the unit. An Instr will automatically restart itself if its source code is edited. Accuracy of the respawn depends on the implementation in the object's driver, but in the worst case it just stops and then plays the object.

Returns:

this

.isPlaying

is unit playing ?

Returns:

boolean

.spec

Spec of the unit itself. Note that a unit may have multiple outlets of varying spec. ~spec is implemented by the driver and it depends how the object wishes to declare itself. Most objects in super collider have a single spec.

Returns:

Spec subclass

.beatDuration

Of interest to the timeline to know how long you are going to play for

Returns:

float or nil (meaning endless)

.gui

Open a gui. The gui implementation is defined in the object driver file.

Arguments:

parent

parent view, window or nil

bounds

bounds rect or nil

Returns:

this

.printOn

Arguments:

stream