Node:
Filter:
Classes | Server > Nodes | Server > Abstractions

Node : Object

Abstract superclass of Synth and Group
Source: Node.sc
Subclasses: AbstractGroup, Synth

Description

This class is the abstract super class of Synth and Group, which represent synth and group nodes on the server. Node objects are not made explicitly, but Synth and Group are subclasses, and inherit the methods documented below.

Freed Nodes and Node Status

Nodes which you explicitly free using the methods free or release will have their group instance variable set to nil. However Nodes which are automatically freed after a certain time (for instance by an EnvGen with a doneAction of 2) will not. This keeps the implementation of the classes simple and lightweight.

To have the current state of a Node tracked you can register it with an instance of NodeWatcher, either by calling register on the Node instance or on the NodeWatcher singleton. This will enable two variables, isPlaying and isRunning, which you can use for checking purposes.

Bundling

Many of the methods below have two versions: a regular one which sends its corresponding message to the server immediately, and one which returns the message in an Array so that it can be added to a bundle. It is also possible to capture the messages generated by the regular methods using Server's automated bundling capabilities. See Server and Bundled Server Messages for more details.

Class Methods

Node.addActions

Returns:

the list of addActions as an event.

Discussion:

Useful for converting addAction symbols to their corresponding integer codes.

Inherited class methods

Undocumented class methods

Node.actionNumberFor(addAction: 'addToHead')

Node.basicNew(server, nodeID)

Node.orderNodesMsg(nodes)

Node.setnMsgArgs( ... args)

Instance Methods

Instance Variables

The following getter methods also have corresponding setters, but they should be used with extreme care and only if you are sure you know what you're doing.

.nodeID

.nodeID = value

Returns:

the Node's node ID number.

Discussion:

Normally you should not need to access this since instances of Node can be passed directly as UGen inputs or Synth args.

.group

.group = value

Returns:

an instance of Group or RootNode corresponding to this Node's group on the server.

.server

.server = value

Returns:

an instance of Server corresponding to this Node's server app.

.isPlaying

.isPlaying = value

Returns:

a boolean indicating if this node is currently on the server, providing this Node has been registered with a NodeWatcher.

Discussion:

N.B. If this Node has not been registered this will likely be false in any case.

.isRunning

.isRunning = value

Returns:

a boolean indicating if this node is currently on the server, providing this Node has been registered with a NodeWatcher.

Discussion:

N.B. If this Node has not been registered this will likely be false in any case.

Node Commands

See the Node Commands section in Server Command Reference for the OSC equivalents of the methods outlined below.

.free(sendFlag: true)

.freeMsg

Stop this Node and free it from its parent group on the server. Once a Node has been freed, you cannot restart it.

Arguments:

(sendFlag)

a boolean indicating whether the free message should be sent. If false an n_free message will not be sent to this Node's server, but its isPlaying and isRunning variables will be set to false. The default for sendFlag is true.

Discussion:

If this Node is a Group this will free all Nodes within the Group.

.run(flag: true)

.runMsg(flag: true)

Set the running state of this Node according to a boolean. False will pause the node without freeing it. The default is true.

Discussion:

If this Node is a Group this will set the running state of all Nodes within the Group.

.set( ... args)

.setMsg( ... args)

Set controls in this Node to values.

Discussion:

Controls are defined in a SynthDef as args or instances of Control. They are specified here using symbols, strings, or indices, and are listed in pairs with values. If this Node is a Group this will set all Nodes within the Group.

Values that are arrays are sent using the OSC array type-tags ($[ and $]). These values will be assigned to subsequent controls in the manner of setn.

.setn( ... args)

.setnMsg( ... args)

Set sequential ranges of controls in this Node to values.

Discussion:

Controls are defined in a SynthDef as args or instances of Control. They are specified here using symbols, strings, or indices, and are listed in pairs with arrays of values. If this Node is a Group this will setn all Nodes within the Group.

.fill(controlName, numControls, value ... args)

.fillMsg(controlName, numControls, value ... args)

Set sequential ranges of controls in this Node to a single value.

Discussion:

Controls are defined in a SynthDef as args or instances of Control. They are specified here using symbols, strings, or indices, and are listed in groups of three along with an integer indicating the number of controls to set, and the value to set them to. If this Node is a Group this will fill all Nodes within the Group.

.map( ... args)

.mapMsg( ... args)

Map controls in this Node to read from control or audio rate Buses.

Discussion:

Controls are defined in a SynthDef as args or instances of Control or its subclasses. They are specified here using symbols, strings, or indices, and are listed in pairs with Bus objects. The number of sequential controls mapped corresponds to the Bus' number of channels.

If this Node is a Group this will map all Nodes within the Group.

Note that with mapMsg if you mix audio and control rate busses you will get an Array of two messages rather than a single message. Integer bus indices are assumed to refer to control buses. To map a control to an audio bus, you must use a Bus object.

.mapn( ... args)

.mapnMsg( ... args)

Map sequential ranges of controls in this Node to read from control rate Buses.

Discussion:

This is similar to map above, but you specify the number of sequential Controls to map. If this Node is a Group this will mapn all Nodes within the Group.

.release(releaseTime)

.releaseMsg(releaseTime)

This method causes the receiver to be freed after the specified amount of time. This is a convenience method which assumes that the synth contains an envelope generator (an EnvGen, Linen, or similar UGen) running a sustaining envelope (see Env: Sustained Envelope Creation Methods) and that this envelope's gate argument is set to a control called \gate.

Arguments:

releaseTime

The amount of time in seconds during which the node will release. If set to a value <= 0, the synth will release immediately. A nil value will cause the synth to release using its envelope's normal release stage(s).

NOTE: Providing a releaseTime != nil doesn't trigger a normal release, but a different behavior called forced release. This difference is particularly important for envelopes with a multi-node release stage, i.e. whose releaseNode is not their last node. See EnvGen: Forced release.

Discussion:

If the receiver is a Group, all nodes within the group will be released.

.query(action)

Sends an n_query message to the server, which will reply with a message containing information about this node and its place in the server's node tree.

Arguments:

action

An optional Function to be called. If the node is a Synth, the function will take the arguments serverCmd, nodeID, parent, prev, next, isGroup. If the node is a Group, the function will take the arguments serverCmd, nodeID, parent, prev, next, isGroup, head, tail. Providing a function here will bypass query's normal behaviour, i.e., the usual node information will not be posted.

Discussion:

This information will be printed to the post window. (See also the queryAllNodes method of Server.) "parent" indicates the Node's enclosing group. If "prev" or "next" are equal to -1 that indicates that there are no other nodes in the enclosing group before or after this one, respectively.

.trace

Causes a synth to print out the values of the inputs and outputs of its unit generators for one control period to the post window. Causes a group to print the node IDs and names of each node in the group for one control period.

.register(assumePlaying: false)

Registers the node at the NodeWatcher object.

Discussion:

This will enable two variables, isPlaying and isRunning, which you can use for checking purposes.

Changing the order of execution

The following methods can be used to change the Node's place in the order of execution. See the Order of execution help file for more information on this important topic. See Server Command Reference for the OSC equivalents of these methods.

.moveAfter(aNode)

.moveAfterMsg(aNode)

Move this Node to be directly after aNode. N.B. n_after, the OSC message which this method encapsulates, allows already freed nodes as targets. This is so that one may attempt a series of moves, with the last successful one taking effect. For this reason this method will fail silently if either the target or this node have already been freed. If you will need to check, you may register the relevant nodes with a NodeWatcher.

.moveBefore(aNode)

.moveBeforeMsg(aNode)

Move this Node to be directly before aNode. N.B. n_before, the OSC message which this method encapsulates, allows already freed nodes as targets. This is so that one may attempt a series of moves, with the last successful one taking effect. For this reason this method will fail silently if either the target or this node have already been freed. If you will need to check, you may register the relevant nodes with a NodeWatcher.

.moveToHead(aGroup)

.moveToHeadMsg(aGroup)

If aGroup is a Group then this method will move this Node to the head of that Group. If it is nil this will move this Node to the head of the default_group of this Node's Server.

.moveToTail(aGroup)

.moveToTailMsg(aGroup)

If aGroup is a Group then this method will move this Node to the tail of that Group. If it is nil this will move this Node to the tail of the default_group of this Node's Server.

Other Methods

.asTarget

From extension in /usr/share/SuperCollider/SCClassLibrary/Common/Control/asTarget.sc

Returns:

this Node. See the asTarget help file for more details.

.printOn(stream)

Prints this Node's Class (Synth or Group) and nodeID on stream.

.hash

Returns:

server.hash bitXor: nodeID.hash

==(that)

Returns:

true if this Node and aNode have the same nodeID and the same Server object, otherwise returns false.

Discussion:

Under certain circumstances this Node and aNode might not be the same object, even though this returns true.

.onFree(func)

Evaluate function when this Node is freed.

Discussion:

.waitForFree

Wait until this Node is freed. Should be used inside a Routine or similar.

Discussion:

Inherited instance methods

Undocumented instance methods

.asControlInput

.asNodeID

From extension in /usr/share/SuperCollider/SCClassLibrary/Common/Control/asTarget.sc

.asUGenInput

.unregister