Combining Nodes in SuperCollider

Creating and Connecting Nodes

Audio buses can be used to connect synth nodes. In this example we will create two nodes - one for generating a sound and one for processing it. First thing is an audio bus:

~aBus = Bus.audio(s,1);

The ~osc node generates a sawtooth signal and the output is routed to the audio bus:

~osc = {arg out=1; Out.ar(out,Saw.ar())}.play;

~osc.set(\out,~aBus.index);

The second node is a simple filter. Its input is set to the index of the audio bus:

~lpf = {arg in=0; Out.ar(0, LPF.ar(In.ar(in),100))}.play;

~lpf.set(\in,~aBus.index);

Warning

Although everything is connected, there is no sound at this point. SuperCollider can only process such chains if the nodes are arranged in the right order. The filter node can be moved after the oscillator node:


Moving Nodes

/images/basics/sc-order-1.png

Node Tree before moving the processor node.


The moveAfter() function is a quick way for moving a node directly after a node specified as the argument. The target node can be either referred to by its node index or by the related name in sclang:

~lpf.moveAfter(~osc)

/images/basics/sc-order-2.png

Node Tree after moving the processor node.