SuperCollider, コンピュータ

Demand UGens and Control Bus

(Wrote as an personal note on what I am now learning…)

There are many ways of sequencing in SuperCollider. In some cases, you may want to do it without scheduling from the client side (sclang) with Routine, Task, and/or Patterns. It is possible to design rhythm and pitch patterns, as well as their sound, in SynthDef, so that all the events are controlled from the Server side (scsynth).

To synchronize one sequence with the other, there has to be a synth for integrating triggers. This synth cues beat triggering synths at the top of each bar. You may want these beat triggers to go though a synth that includes Demand UGens that form rhythm and pitch patterns. All these synths above receive, generate and send the control data from and to control bus. These control data reach synths at last, whose SynthDef have audio data as their output.

// this sets tempo of all the triggers by Impulse,
// sent out to control bus
SynthDef(\conductor, {arg bpm=120, outBus=nil;
	var out;
	out =;, out);
// receiving data from control bus, this divides a trigger into 8 beats,
// sent out to control bus
SynthDef(\trigger8, {arg inBus=nil, outBus=nil, bpm=120;
	var trig, env, out;
	trig =, 1);
	env =[0, 1, 1, 0], [10e-10, 2-(2*(10e-10)), 10e-10]), 
		timeScale: 120/bpm
	out =*8/240)*env;, out);
// receiving beat triggers from control bus, 
// this processes them into data for rhythm and accent pattern
SynthDef(\aRhythmAndAccent, {arg outBus=nil, inBus=nil;
    var env, trig, seq, out;
    trig =, 1);
    seq = Drand([
	], inf);
    out =, 0, seq)*trig;, out)
// receiving beat triggers from control bus, 
// this processes them into data for pitch pattern
SynthDef(\aPitch, {arg outBus=nil, inBus=nil;
    var env, trig, seq, out;
    trig =, 1);
    seq = Drand([
	], inf);
    out =, 0, seq);, out)
// sound
SynthDef(\aSound , {
	arg inBus1 = nil, inBus2 = nil;
	var src, env, out, trig, freq;
	trig =, 1);
	freq =, 1);
	src =;
	env =, 0.12), trig, trig*0.25);
	out =*env, 0);, out);
// control buses (index number and trigger signal flow)
the bus for general tempo --- index 0
the bus for 8-beat trigger --- index 1
the bus for specific rhythm and accent patterns --- index 2
the bus for a specific pitch pattern --- index 3
[\conductor] -> control bus 0 -> [\trigger8] -> control bus 1 
-> [\aRhythmAndAccent, \aPitch] -> control bus 2, 3 -> [\aSound]
// start conducting
s.sendMsg(\s_new, \conductor, 1001, 0, 1, \outBus, 0);
// get ready for the sound
s.sendMsg(\s_new, \aSound, 4001, 1, 1, \inBus1, 2, \inBus2, 3);
// get ready for the pattern
s.sendMsg(\s_new, \aRhythmAndAccent, 3001, 1, 1, \inBus, 1, \outBus, 2);
s.sendMsg(\s_new, \aPitch, 3002, 1, 1, \inBus, 1, \outBus, 3);
// start following the conductor
s.sendMsg(\s_new, \trigger8, 2001, 1, 1, \inBus, 0, \outBus, 1);
// end the song
s.sendMsg(\n_free, 1001);
// free the rest of nodes
s.sendMsg(\n_free, 2001);
s.sendMsg(\n_free, 3001);
s.sendMsg(\n_free, 3002);
s.sendMsg(\n_free, 4001);

Above is the code for a single melody. It is possible to add different streams, synchronizing all together. You may want another SynthDefs for patterns that can receive the same 8-beat trigger, as well as another SynthDefs for different sounds.
(Any correction would be greatly appreciated.)


メールアドレスが公開されることはありません。 * が付いている欄は必須項目です