(
Server.default = s = Server.internal.boot;
s.waitForBoot({
s.scope;
});
)
(
var noteObject, note;
noteObject = CtkSynthDef(\example_3a, {arg amp, freq, dur, attack, decay;
var env, envgen, osc;
// an exponential envelope. Because the envelope is exponential,
// the level values must not cross 0.
env = Env.new([0.0001, 1, 1, 0.0001],
[attack, dur - (attack + decay), decay],
\exp);
// Here the env object is sent to the EnvGen UGen. The levels will be
// scaled by the amp value (converted from a decibel value) passed in
// as an argument.
envgen = EnvGen.kr(env, 1, amp.dbamp, 0, 1, 0);
osc = SinOsc.ar(freq, 0, 1);
Out.ar(0, osc * envgen);
});
note = noteObject.new(1.0, 10.0).amp_(-10).freq_(460).dur_(10)
.attack_(0.04).decay_(8.8);
// play it
note.play;
)