[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-dev] [APPROVE?] SynthDef and non-float args
On Saturday, Nov 20, 2004, at 23:45 US/Eastern, James McCartney wrote:
This is unnecessary. You can just write closures. This is what I am doing for the basic synth lib.
You can put these functions in a dictionary and archive them.
Actually, I'll see your closures and raise you a "know"...
~defs = (
sin1: #{ |self, name, env, numCh = 1|
// also a good idea to have defaults for required func args
env = env ?? { Env.adsr(0.1, 0.5, 0.7, 0.1) };
SynthDef(name, { |out = 0, freq = 440, gate = 1, amp = 0.5|
var sig;
sig = SinOsc.ar(freq, 0, amp) * EnvGen.kr(env, gate, doneAction:2);
Out.ar(out, sig.dup(numCh))
});
}
);
~defs.know = true;
s.boot;
~defs.sin1(\sin1, Env.sine(2), 2).send(s);
a = \sin1, [\freq, 600]);
Now we have something really useful. Thanks for the tip!
Can we do the default synthdef library this way?
hjh
____________________________________
H. James Harkins /// dewdrop_world
http://www.dewdrop-world.net
"If attacked by a lion, thrust your arm down his throat.
This takes some practice." -- Cyril Connolly