(
Ndef(\f1,{SinOscFB.ar(freq:142, feedback:Saw.ar(20 * SinOsc.ar(20)) + SinOsc.ar(0.1)).dup * 0.1}).add;


Ndef(\f2,{
    var freq = MouseX.kr(100, 400);
    var input = SinOsc.ar(freq, 0, 0.1);
    var response = WeaklyNonlinear.ar(input);
    var filt = RLPF.ar(response, XLine.kr(500, 5000, 10), 0.3);
    Pan2.ar(0.1 * filt, 0);
}).add;


Ndef(\f3,{WeaklyNonlinear.ar(SinOsc.ar(70), Impulse.kr(20), ratex:0.1, ratey:20, freq:440, initx:10 + SinOsc.kr(40), inity:20 + SinOsc.kr(20), alpha:SinOsc.kr(1), xexponent:0, beta:0, yexponent:0).dup * 0.1}).add;


Ndef(\f4, {
	var f1 = 197.9;
    var f2 = 210.3;
	var f3 = 239.7;

    // feedback amounts
	var fbAmt = Line.kr(0, 1, 8);  // can modulate later
	// var fbAmt = 0;

    var x1, x2, x3;
	var sig;

    // Indirect feedback cycle sorta
	x1 = SinOscFB.ar(f1, SinOscFB.ar(f2, 1 * SinOsc.kr(10), mul:1 + SinOsc.kr(30)));
	x2 = SinOscFB.ar(f2, x1);
	x3 = SinOscFB.ar(f3, x2 * fbAmt);

    // Mix and protect ears
	sig = Limiter.ar((x1 + x2 + x3).dup * 0.2);
	sig = AllpassC.ar(sig, maxdelaytime:0.2 + SinOsc.kr(0.1), delaytime:0.8 + SinOsc.kr(0.1), decaytime:0.0, mul:1.0);
}).add;
)
)

(
ClipTimeline('azzz').tracks = [ ( 'index': 0, 'recordArmed': false, 'recordBus': 0, 'muted': false ), ( 'index': 1, 'recordArmed': false, 'recordBus': 0, 'muted': false ), ( 'index': 2, 'recordArmed': false, 'recordBus': 0, 'muted': false ), ( 'index': 3, 'recordArmed': false, 'recordBus': 0, 'muted': false ) ];
{
ClipTimeline('azzz').eventList = TimelineEventList.newFrom([
    (\absTime: 0, \dur: 0.0, \label: 'start', \playDur: 0.0, \relDur: 0.0, \sustain: 0, \type: 'start', ),
    PlayerEvent((\absTime: 0.0, \dur: 4.0, \legato: 1, \midinote: 0.0, \playDur: 4.0, \receiver: PlayerWrapper(Ndef('f1')), \relDur: 4.0, \sustain: 4.0, \type: 'player', )),
    PlayerEvent((\absTime: 4.0, \dur: 4.0, \legato: 1, \midinote: 1.0, \playDur: 4.0, \receiver: PlayerWrapper(Ndef('f2')), \relDur: 4.0, \sustain: 4.0, \type: 'player', )),
    PlayerEvent((\absTime: 8.0, \dur: 4.0, \legato: 1, \midinote: 2.0, \playDur: 4.0, \receiver: PlayerWrapper(Ndef('f3')), \relDur: 4.0, \sustain: 4.0, \type: 'player', )),
	PlayerEvent((\absTime: 12.0, \dur: 4.0, \legato: 1, \midinote: 3.0, \playDur: 4.0, \receiver: PlayerWrapper(Ndef('f4')), \relDur: 4.0, \sustain: 4.0, \type: 'player', )),

    (\absTime: 16, \dur: 0, \label: 'end', \playDur: 0, \relDur: 0, \type: 'end', ),
]);
 }.value;
);

ClipTimeline(\azzz).edit
ClipTimeline(\azzz).play

Pdef.defaultQuant = 0;  // disable





//////////////////////////////////////////////////////////////////////////////////////////

(
{
	var f1 = 197.9;
    var f2 = 210.3;
	var f3 = 239.7;

    // feedback amounts
	var fbAmt = Line.kr(0, 1, 8);  // can modulate later
	// var fbAmt = 0;

    var x1, x2, x3;
	var sig;

    // Indirect feedback cycle sorta
	x1 = SinOscFB.ar(f1, SinOscFB.ar(f2, 1 * SinOsc.kr(10), mul:1 + SinOsc.kr(30)));
	x2 = SinOscFB.ar(f2, x1);
	x3 = SinOscFB.ar(f3, x2 * fbAmt);

    // Mix and protect ears
	sig = Limiter.ar((x1 + x2 + x3).dup * 0.2);
	sig = AllpassC.ar(sig, maxdelaytime:0.2 + SinOsc.kr(0.1), delaytime:0.8 + SinOsc.kr(0.1), decaytime:0.0, mul:1.0);
}.play;
)
