s.boot;

(
SynthDef(\guitar, {
	arg freq; // A2
	var env;
	var trig = Impulse.kr();

    // Simulated pick attack — short noise burst
    var pickEnv = Decay2.kr(trig, 0.001, 0.03);
    var pickNoise = WhiteNoise.ar(0.4) * pickEnv;

    // Plucked string body
    var string = Pluck.ar(
		WhiteNoise.ar(0.5),
        trig,
        delaytime: 1/freq,
        maxdelaytime: 0.1,
        decaytime: 4,
        coef: 0.4
    );

    // Mix pick noise and string
    var signal = string + pickNoise;

    // Optional: low-pass to tame brightness (like tone knob or cab sim)
    signal = LPF.ar(signal, 8000);

	env = EnvGen.kr(Env.perc(attackTime: 0.1, releaseTime: 0.2, level: 1, curve: -4), doneAction:2);

    // Mono signal
	Out.ar(0, signal * env);
}).play;
)




(
~clock = TempoClock.new(90/60);

Pbind(
	\instrument, \guitar,
	// \freq, Pseq([[60, 63], [50, 59, 67], [48, 54, 60] ], inf).midicps,
	\freq, Pseq([60], inf).midicps,
    \dur, Pseq([
        0.05, 0.03, 0.03,  // strum delays for chord 1
        0.5, 0.5,          // rest for "&"
        0.05, 0.03, 0.03,  // chord 2 strum
        0.05, 0.03, 0.03,  // chord 2 "&" strum
        // continue for whole pattern
], inf)).play(~clock);
)

(
Pbind(
	\instrument, \guitar,
	\freq, Pseq([[60, 63], [50, 59, 67], [48, 54, 60] ], inf).midicps,
    \dur, Pseq([
        0.05, 0.03, 0.03,  // strum delays for chord 1
        0.5, 0.5,          // rest for "&"
        0.05, 0.03, 0.03,  // chord 2 strum
        0.05, 0.03, 0.03,  // chord 2 "&" strum
        // continue for whole pattern
    ], inf)).play;
)