Saturday, February 7, 2009

Moog Thing

This is a blog about SuperCollider.

Whilst supercollider isn't my first language, I'm not a hugely experienced programmer, so this is going to be very much from a newbies perspective.

Lets start at the beginning.

This is the first real SuperCollider program that I managed to get working, very closely aided by my mate Dan who is very good at Supercollider indeed.


(
SynthDef("Moog",{

arg oscType =0, oscType2 = 1, pan = 0, level = 0.5, cutoff = 500, gain = 3.3, attack = 0.1, decay = 0.1, sust = 0.7, rel = 0.2, attackf = 0.1, decayf = 0.1, sustf = 0.9, relf = 0.2, gate = 1, freq =440;


var oscArray = [Saw.ar(freq ), SinOsc.ar(freq), Pulse.ar(freq)];
var oscArray2 = [Saw.ar(freq), SinOsc.ar(freq), Pulse.ar(freq)];
var ampEnv = EnvGen.ar(Env.adsr(attack, decay, sust, rel), gate, doneAction:2);
var filterEnv = EnvGen.ar(Env.adsr(attackf, decayf, sustf, relf), gate, doneAction:2);
var osc1 = Select.ar(oscType, oscArray);
var osc2 = Select.ar(oscType2, oscArray2);
var fade = XFade2.ar(osc1, osc2, pan , level * ampEnv);
var filter = MoogFF.ar(fade, cutoff * filterEnv, gain);
Out.ar(0,filter)

}).store
)

it's a synth. A simple Moog inspired thing, with two oscillators, which can be either saw, sin or square/pulse waves and a mixer to mix them. It's also got a filter and two envelopes, one controlling the filter and one controlling the amplitude.

here's a pattern to play it with.

(
Pbind(
\instrument, "Moog",
\freq, Pseq([440, 550, 660, 770, 660, 330, 880], inf),
\dur, Pseq([0.2, 0.4, 0.1, 0.2, 0.2], inf),
\oscType, Pseq([0,0,0,0,0], inf),
\oscType2, Pseq([0,0,2,2,1], inf),
\cutoff, Pseq([100,599,1000,20,800], inf),
\pan, Pseq([1], inf)

).play
)


I'll go into more details of it's workings later...

No comments:

Post a Comment