Ok, Its very nearly ready… Im working on mother.scd (mother.pd equiv.) as we speak…
currently, my test polyphonic synth is working… with full organelle functionality
Actually I quite like SC, as you’ll see below in my example, is really compact for coding things up.
things still left to do for mother.scd
-
aux key
-
encoder handling
-
expression pedal
-
volume knob, this will patches using an audio bus, rather than using bus 0 (similar to throw~ in PD)
-
vumeter display
-
midi
possibly, similar default CC/note I/O like PD, not decided, as i dont really use this, and it can be patches
Im not planning on initially on multiple page menu, user patches can do that… so think of its a mother.pd (v1).
Im pretty new to SC, so if there are some SC gurus out there that want to help on developing the mother.scd please shout… there are some interesting ‘technical issues’
anyway, unfortunately other things to do today… so will be a few days before release , but its getting there !
Ok, so on to the test synth … and what it looks like…
code breakdown of main.scd
all in one file, called main.scd, in the Patches directory… like PD.
Initialisation
notice here how I send messages to the OLED.
~voices = Dictionary.new;
~cutoff = 5000.0;
~oled.screen(5,"Test Patch Loaded");
~oled.screen(1,format("Cutoff % Hz",~cutoff.asInteger));
knob handling
create a callback function for handling the knobs, and then register it for callbacks (addDependent).
you can see I also take the opportunity to update the display… and any playing voices.
~knobfunc = {
arg func, msg, knob, value;
if(knob==0, {
~cutoff = value.linexp(0,1,50,20000);
~oled.screen(1,format("Cutoff % Hz",~cutoff.asInteger));
~voices.values.do({ arg v; v.set(\cutoff,~cutoff); }
);
});
};
~knobs.addDependant(~knobfunc);
key handling
create a callback function for handling the keys, and then register it for callbacks (addDependent).
simply here, I create a voice if necessary for the key, and turn it off on note-off
~keyfunc = {
arg func, msg, key, vel;
if(vel>0 , {
if(~voices[key]!=nil,{~voices[key].set(\gate,0);});
~voices[key] = Synth.new(\testSynth,[
\freq, (key+59).midicps,
\cutoff, ~cutoff,
]
);
} , {
if(~voices[key]!=nil,{~voices[key].set(\gate,0);});
~voices[key] = nil;
};
)
};
~keys.addDependant(~keyfunc);
a synth to play
and then a simply synth that has a low pass filter, so I can demonstrate the knobs (via cutoff)
SynthDef(\testSynth,
{
arg freq=440,gate=1,cutoff=440;
var sig,env,amp=0.3;
sig = Saw.ar(freq);
env = EnvGen.ar(Env.adsr(),gate,doneAction:2);
sig = sig * env * amp;
sig = LPF.ar(sig,cutoff.clip(10,24000));
Out.ar(0,sig!2);
}
).add;