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

MxQuery
ExtensionExtension

jQuery style queries for selecting objects and performing bulk operations on them

Description

An MxApp can query its contents (units, channels, inlets, outlets) and operations can be called on these queries to perform them on all results.

An initial query set is obtained from the MxApp and can then be filtered further. Operations performed on the query are performed on all matching objects and all events (like connections or replacing units) will happen in a single update.

More to come. query to query patching will be possible with UGen-style multi channel array connections

Instance Methods

.select

Just like collection select, but the function is passed: source, i, app

Arguments:

function

a new MxQuery with the selected results

.reject

Just like collection reject

Arguments:

function

a new MxQuery with the non-rejected results

.units

If a query set includes channels or iolets then this method will return a query set with all the units in those channels and all units that the iolets.

Returns:

an MxQuery with only units

.channels

If a query set includes units or iolets then this will return a query set with just the channels that those items are in.

Returns:

an MxQuery with just channels

.inlets

Returns a query set with all inlets for the currently matched results. so mx.units.inlets returns all inlets for all units in the mx. For a channel (or channels) it returns all inlets for all units in that channel. For a query set of units it returns all inlets for those units.

Returns:

an MxQuery with just inlets

.outlets

Like inlets but returns outlets

Returns:

an MxQuery with just outlets

.where

Filters the results by testing each source object if objects.selector == equalsValue. eg. qs.inlets.where(\name,\freq) would return all inlets with the name \freq

Arguments:

selector

The selector will be called on the source. For a unit this is what is inside it. For inlets, outlets and channels it is the inlet,outlet,channel itself. Thus inlet.name == 'freq' is asking the inlet.

equalsValue

The value to be matched for equality

Returns:

an MxQuery with the selected results

.whereIsA

Filters where class of the source object === class

Arguments:

class

Returns:

an MxQuery with the selected results

.whereIsKindOf

Filters where source object is of the class or a subclass of class.

Arguments:

class

Returns:

an MxQuery with the selected results

.whereAppClassIs

Arguments:

class

.do

Iterates over the result set

Arguments:

function

Supplied arguments: source, i, app

Returns:

this

.collect

Collects the resultset returning an array of whatever your function returns.

Arguments:

function

an array

.size

Size of the result set

Returns:

integer

.isEmpty

If size == 0

Returns:

boolean

.notEmpty

If size != 0

Returns:

boolean

.at

Returns an item from the result set

Arguments:

i

index

Returns:

the app object: MxUnitApp, MxInletApp etc

>>

Connects all matched items to that. Units connect their first available out.

Arguments:

that

An inlet. Will support connecting to another query set soon.

Returns:

that

.disconnect

Disconnect all matched items. Outlets and inlets disconnect all cables. Units disconnect all of their iolets.

.remove

Remove the matched items from the mx. Not to be confused with removing the items from the query set (use reject for that).

.get

From the source objects get an array of values obtained with the selector. eg. x.units.outlets.get('spec') would be all of the specs of all of outlets.

Arguments:

selector

The selector to call on the source objects.

... args

extra args to pass when calling source.selector( arg1, arg2, ...)

Returns:

an array of the results of getting

.set

Arguments:

selector
value

.dup

Duplicate all units in the query set. Dup inserts a copy of the unit directly below itself, moving anything that might be there further down by one.

Arguments:

num

Number of copies to make

Returns:

if num == 1 then returns the new unit, else returns an array of units [though a new qs would be nice]

.moveBy

Move the matched items by channel and slot according to the vector (a point). ie. 1@0 moves it over by one channel. 0@1 moves it down by one slot in the current channel. Replaces anything currently there. [ will offer safe mode or moving items ]

Arguments:

vector

a point channel@slot by which to move the objects

Returns:

this. returning a new set would be better

.copyBy

Copies rather than moves. See moveBy

Arguments:

vector

.stop

Stops matched objects from playing

.play

Plays matched objects

.free

.respawn

Respawns matched objects. See MxUnitApp respawn

.mute

For all channels of the matched object, mutes or unmutes the channel fader.

Arguments:

boo

.solo

For all channels of the matched object, solos or unsolos the channel fader.

Arguments:

boo

.db

For all channels of the matched object, set the channel fader level.

Arguments:

db