// Basic oscillator SynthDefs
(
// Pure sine tone
SynthDef(\sineTone, { |out=0, freq=440, amp=0.1, pan=0, attack=0.01, release=1|
    var sig, env;
    env = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
    sig = SinOsc.ar(freq) * env * amp;
    Out.ar(out, Pan2.ar(sig, pan));
}).add;

// Square wave tone
SynthDef(\squareTone, { |out=0, freq=440, amp=0.1, pan=0, attack=0.01, release=1, width=0.5|
    var sig, env;
    env = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
    sig = Pulse.ar(freq, width) * env * amp;
    Out.ar(out, Pan2.ar(sig, pan));
}).add;

// Sawtooth wave tone
SynthDef(\sawTone, { |out=0, freq=440, amp=0.1, pan=0, attack=0.01, release=1|
    var sig, env;
    env = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
    sig = Saw.ar(freq) * env * amp;
    Out.ar(out, Pan2.ar(sig, pan));
}).add;

// Triangle wave tone
SynthDef(\triTone, { |out=0, freq=440, amp=0.1, pan=0, attack=0.01, release=1|
    var sig, env;
    env = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
    sig = LFTri.ar(freq) * env * amp;
    Out.ar(out, Pan2.ar(sig, pan));
}).add;

// FM synthesis tone
SynthDef(\fmTone, { |out=0, freq=440, amp=0.1, pan=0, attack=0.01, release=1, modRatio=2, modAmt=0.5|
    var sig, env, mod;
    env = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
    mod = SinOsc.ar(freq * modRatio, 0, freq * modAmt);
    sig = SinOsc.ar(freq + mod) * env * amp;
    Out.ar(out, Pan2.ar(sig, pan));
}).add;

"Oscillator SynthDefs loaded".postln;
)