// Boot the server first
s.boot;

// Define a SynthDef using a damped harmonic oscillator model
(
SynthDef(\dampedResonator, {
    |freq = 220, amp = 0.5, decay = 0.5|
    var excitation, signal, damping;

    // Impulse excitation (can replace with Dust or WhiteNoise)
    excitation = Impulse.ar(0); // one-shot impulse at start

    // Damping factor converted from decay time (rough approximation)
    damping = exp(-2pi / (decay * SampleRate.ir));

    // Simple feedback resonator: excitation + feedback loop
    signal = Ringz.ar(excitation, freq, decay) * amp;

    Out.ar(0, signal ! 2); // stereo output
}).add;
)

// Play a few resonant tones
(
Pbind(
    \instrument, \dampedResonator,
    \freq, Pseq([220, 330, 440, 550], inf),
    \decay, Pseq([1.5, 1.2, 0.8, 0.5], inf),
    \amp, 0.3,
    \dur, 0.5
).play;
)
