SWDataNetwork Pattern support

A couple of patterns have been defined to use values of slots in patterns. The slots or nodes can be either accessed by their label, their node ID or their slot ID. The labels or id's themselves can be output by other patterns too. If arrays are used, the patterns create multiple events as expected (multichannel expansion).

- Example -

x = SWDataNetwork.new;

// build the device list and start the event loop: 
GeneralHID.buildDeviceList; 
GeneralHID.startEventLoop; 
 
// find an Impact game device and open it: 
a = GeneralHID.open( GeneralHID.findBy( 1973 ) ); 

// set a spec for the device:
a.setSpec( a.findSpec.first ); 

// add the device to the network:
x.addExpected( 1, \impact );
a.addToNetwork( x, 1 );

// boot the server 
 s = Server.local.boot; 

// simple example, use the left axis as the current note to be played:
p = Pbind( 
    \degree, ( PdataKey( \lx, x, inf )*12 ).round(1), 
    \dur, 0.25 
).play;

// stop the pattern
p.stop; 

// simple example, use all of the nodes as the current note to be played.
// Since there are multiple slots, this will result in many synths to be created
// (the sonic result of this example is not beautiful).
p = Pbind( 
    \degree, ( PdataKey( \impact, x, inf )*12 ).round(1), 
    \dur, 0.25, \amp, 0.025
).play;

p.stop; 

// same as above, but use the node ID instead:
p = Pbind( 
    \degree, ( PdataNode( 1, x, inf )*12 ).round(1), 
    \dur, 0.25,\amp,0.025
).trace.play;

p.stop;

// Using the slot ID's. Also showing that the slot ID's to use can be sequenced with another pattern.
p = Pbind( 
    \degree, ( PdataSlot( Pseq( (14..17),inf ), 1, x, inf )*12 ).round(1), 
    \dur, 0.25 
).play;

p.stop;

// Using the slot ID's. Also showing that the slot ID's can be arrayed to produce multiple synths.
p = Pbind( 
    \degree, ( PdataSlot( [12,14,16], 1, x, inf )*12 ).round(1), 
    \dur, 0.25 
).play;

p.stop;

- Methods -

PdataSlot( slot, node, network, repeats )
Access a slot by ID. Both slot and node input can be another pattern.
PdataNode( node, network, repeats )
Access a node by ID. This generates an Array with all the values of all slots. The node input can be another pattern.
PdataKey( key, network, repeats )
Access a node or slot by its key (label). In the case of a node, this generates an Array with all the values of all slots. The key input can be another pattern.



Marije Baalman 2009-03-16