SWDataNode

Base class for a data node

- Example -

// create a network client:
y = SWDataNetworkClient.new( "192.168.0.104", "myname" );

// subscribe to node 102
y.subscribeNode( 102 );


// -------- working with the data node:

// get a reference to a DataNode in a variable:
a = y.nodes[102];

// if the node has a label, you acces it by its label:
a = y[\minibee102];

// access the values of all slots of the node:
a.value;

(
SynthDef(\swexample,{ |out=0,amp=0.1,freq=400|
	Out.ar( out, SinOsc.ar( freq, 0, amp ) );
}).send(s)
)

// use it at synth instantiation:
b = Synth.new( \swexample, [\amp,a.value ] );

// set it again:
b.set( \amp, a.value );

// free the synth
b.free;

// instead of setting it manually each time, you can assign
// an action to the data node to do this automatically:

b = Synth.new( \swexample, [\amp,a.value ] );

a.action= { |data| b.set( \amp, data )};

// another method is to put the data automatically on a bus,
// and grab the data from there:

// reset the action:
a.action = {};

// create a bus:
a.createBus(s);

// map the amplitude of b to the bus:
b.map( \amp, a.bus );

b.free;

// alternatively, you can use In.kr in your synthdef to read
// from the bus:
(
SynthDef(\swexampleBus,{ |out=0,ampbus=0,freq=400|
	Out.ar( out, SinOsc.ar( freq, 0, In.kr( ampbus, 1 ) ) );
}).send(s)
)

b = Synth.new( \swexampleBus, [\ampbus,a.bus ] );

b.free;

- Methods -

*new( ident, maxs )
Create a new data node with ID ident and maxs slots
initSlots( )
Initializes the slots for this node with SWDataSlots.

- Identifier and label -

id ( )
The unique ID of the node
key ( )
The label of the node
key_ ( )
Set the label of the node (done internally when a mapping is added with the method add of SWDataNetwork)
type ( )
The type of the node. 0 is number (float), 1 is string (see the subclass SWDataStringNode).

- Slots and data -

slots ( )
Retrieve the array of slots of the node
data_ ( indata )
Set the data to each slot. This multiplies the indata with the scaling factor scale, sets it to the instance variable data, and then sets each slot with its value. Also sets the lasttime the data was set. Performs the action defined for the node (each slot will perform its own action as well).
data ( )
An array with the data of the slots. These values do not have the further scaling and mapping which happens in the slot itself. So only the scaling of the node is applied.
value ( )
Same as data.
scale ( )
scale_ ( )
The scaling factor for the data
setLastTime ( )
sets the last time the node
lasttime ( )
The last time the node was updated
elapsed ( )
Get the elapsed time since the last time the node received new data.

- Actions -

action ( )
action_ ( )
Function to be performed each time the data is set
restartAction ( )
restartAction_ ( )
Function to be performed when the elapsed time since the lasttime is larger than the worrytime of the network

- Bus support -

createBus ( s )
create a DataBus for the node on the server
freeBus ( )
free the Bus on the server
bus_ ( )
Set the bus for this node. Do this when e.g. the data for this node is generated from a control bus on the server (such as by an SWBusNode). In that case the DataBus is not used. This also means that the scale factor will not be used for the data on the bus.
bus ( )
Return either the Bus object from the DataBus, or the bus that had been set for this node.
databus_ ( )
databus ( )
The instance of DataBus for this node. A DataBus updates the data on the control bus on a regular time interval.
kr ( )
JITLib support. This creates the bus (if not already present) and provides an In.kr around the bus.

- Debugging and monitoring -

debug_ ( onoff )
print debugging messages for each slot
monitor ( onoff )
Monitor the data in a plot. This uses the GNUPlot to plot the data and the interface class GNUPlot and BusMonitor, which can be found in the GNUPlot quark.
monitorClose ( )
Cleans up the monitor (closing the pipe to GNUPlot).
busmonitor ( )
Reference to the BusMonitor instance for monitoring the node.




Marije Baalman 2009-03-16