Creating a client in SuperCollider

How to use SuperCollider

Code in SuperCollider is executed by putting the cursor on the line, or selecting a block of text, and pressing:

  • On OSX: [Enter] (this is the one next to the spacebar or on the numpad), or Cmd-[Return], or Shift-[Return], or Cmd-C.
  • On Linux: [C-c C-c] (in Emacs/scel), F5 (in scvim), or Ctrl-E (in gedit/sced).
  • On Windows: Ctrl-[Enter]


For the client, you will need to have curl installed, in order to be able to retrieve a file from the host. On Linux this program is available from most distributions. On OSX it should be available by default.

Starting the DataNetwork client in SuperCollider

Now in order to create a client within SuperCollider, you execute this code:

// create a client:
y = SWDataNetworkClient( "", "myname");
// where "" is the IP-address of the host,
// and "myname" is the unique name for you in the datanetwork.

To create a graphical user interface for the DataNetwork execute:


Subscribing to data on the network

Now suppose there is interesting data on node 101:

// subscribe to node 101, by number:
y.subscribeNode( 101 );

Instead of subscribing by number, you can also pass an instance of a SWDataNode to the method:

// subscribe to node 101 by passing in an instance of SWDataNode as an argument:
y.subscribeNode( y.nodes[101] );

You can also subscribe to a DataNode from the GUI with the [sub] button, or get the data once with the [get] button.

Using the data

Now you have several ways to do something with the data:

// get a reference to a DataNode in a variable:
a = y.nodes[101];
// if the node has a label, you acces it by its label:
a = y[\minibee101];

Use the value directly:

// access the values of all slots of the node:
SynthDef(\swexample,{ |out=0,amp=0.1,freq=400| out, freq, 0, amp ) );
// use it at synth instantiation:
b = \swexample, [\amp,a.value ] );
// set it again:
b.set( \amp, a.value );
// free the synth;

Create an action that is performed each time the value changes:

// instead of setting it manually each time, you can assign
// an action to the data node to do this automatically:
b = \swexample, [\amp,a.value ] );
a.action= { |data| b.set( \amp, data )};
// reset the action:
a.action = {};

Automatically putting the value on a bus and map your synth parameters to a bus:

// create a bus:
// map the amplitude of b to the bus: \amp, a.bus );
// cleaning up the synth:;

Supplying data to the network

To create a DataNode in the network, execute the following:

// creating a node with number and label "mynode"
y.addExpected( 500, \mynode );

Now to set data to it:

// creating a node with number and label "mynode"
y.setData( 500, [0,2,3,2,3,4].normalizeSum );

The data supplied to the node must have the same size each time, i.e. the number of slots in the DataNode is constant.

More information

For more information please check the extensive help documentation that is supplied with the classes. To get an overview execute:



Comments are closed.