(
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1, q=0.1; 
var sound, env;

env=EnvGen.ar(Env.perc(0.1,sustain),doneAction:2);

sound=Resonz.ar(Gendy3.ar(4,3,freq:freq),Rand(2000,1000),q);

Out.ar(out, Pan2.ar(sound*amp*env,pan))
}).store;
)

(
Tdef(\lctask1,{
var ampseq;

ampseq=Pseq((1*Array.fill(15, {[1,0,exprand(0.01,0.5)].wchoose([0.3,0.3,0.4])})),inf).asStream;

inf.do {

Synth(\lcsynth1,[\q, [0.1,exprand(0.05,0.5)].wchoose([0.4,0.6]), \amp, ampseq.next]);
1.0.wait;
};

}).play(quant:1.0);
)

	
	
(
Tdef(\lctask2,{
var ampseq;

ampseq=Pseq((1*Array.fill(15, {[1,0,exprand(0.01,0.5)].wchoose([0.3,0.3,0.4])})),inf).asStream;

inf.do {

Synth(\lcsynth1,[\freq, 880, \q, [0.1,exprand(0.05,0.5)].wchoose([0.4,0.6]), \amp, ampseq.next]);
0.5.wait;
};

}).play(quant:1.0);
)	

(
Tdef(\lctask3,{
var ampseq, durseq;

durseq=Pseq((0.5 dup:5) ++ (0.25 dup:6),inf).asStream;

ampseq=Pseq((2*Array.fill(15, {[1,0,exprand(0.01,0.5)].wchoose([0.3,0.3,0.4])})),inf).asStream;

inf.do {

Synth(\lcsynth1,[\freq, 880*2, \q, [0.1,exprand(0.05,0.5)].wchoose([0.4,0.6]), \amp, ampseq.next]);
durseq.next.wait;
};

}).play(quant:1.0);
)	

TempoClock.default.tempo_(4);

(
Tdef(\lctask4,{
var ampseq, durseq;

durseq=Pseq((0.5 dup:5) ++ (0.75 dup:6),inf).asStream;

ampseq=Pseq((2*Array.fill(15, {[1,0,exprand(0.01,0.5)].wchoose([0.3,0.3,0.4])})),inf).asStream;

inf.do {

Synth(\lcsynth1,[\freq, [60,61,63,64,66,67].choose.midicps, \q, [0.1,exprand(0.05,0.5)].wchoose([0.4,0.6]), \amp, ampseq.next, \pan, 2*(ampseq.next)-1]);
durseq.next.wait;
};

}).play(quant:1.0);
)	

a={CombL.ar(In.ar(0,2),0.1,SinOsc.kr(0.25,0,0.05,0.05),SinOsc.kr(0.125,0,2,2.5))}.play;

//wow that fx really worked!

//musn't get distracted at this point

a.free;

//ok what now? 

(
SynthDef(\lcsynth2, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1, amount=0.01; 
var sound, env;

env=EnvGen.ar(Env([1,0],[sustain]),doneAction:2);

sound=Mix(Pulse.ar(freq*[1-amount,1+amount],Rand(0.4,0.6),amp));

Out.ar(out, Pan2.ar(sound,pan))
}).store;
)

(
Tdef(\lctask5,{

inf.do {

Synth(\lcsynth2,[\freq,rrand(0.0,rrand(0.0,1.0))*50+440,\sustain,rrand(1.0,4.0)]);
(rrand(0.0,2.0)).wait;
};

}).play;
)

Tdef(\lctask1).stop
Tdef(\lctask2).stop
Tdef(\lctask3).stop

//oops too loud

b={CombL.ar(In.ar(0,2),0.1,(SinOsc.kr(0.25,0,rrand(0.0,1.0)*25,465)).reciprocal,SinOsc.kr(0.125,0,2,2.5))}.play;

b.free

//first draft interesting distortion but too noisy

b={Line.kr(0.0,1.0,20)*CombL.ar(In.ar(0,2),0.1,(SinOsc.kr(0.25,0,rrand(0.0,1.0)*25,465)).reciprocal,SinOsc.kr(0.125,0,2,2.5))}.play;

b.free

//much more musical to force distortion gradually

Tdef(\lctask4).stop

//edit

(
Tdef(\lctask5,{
var amountseq;

amountseq=Pseq((2*Array.fill(15, {[rrand(0.01,0.05),0,exprand(0.01,0.5)].wchoose([0.3,0.3,0.4])})),inf).asStream;

inf.do {

Synth(\lcsynth2,[\freq,rrand(0.0,rrand(0.0,1.0))*50+440,\sustain,rrand(1.0,4.0), \amount, amountseq.next]);
(rrand(0.0,6.0)).wait;
};

}).play;
)

(
SynthDef(\lcsynth2, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1, amount=0.01; 
var sound, env;

env=EnvGen.ar(Env([1,0],[sustain]),doneAction:2);

sound=Mix(Pulse.ar(freq*[1-amount,1+amount],Rand(0.4,0.6),amp));

Out.ar(out, Pan2.ar(sound,pan))
}).store;
)

b={Limiter.ar(Line.kr(0.0,0.2,20)*CombL.ar(In.ar(0,2),0.1,(SinOsc.kr(0.25,0,rrand(0.0,1.0)*25,465)).reciprocal,SinOsc.kr(0.125,0,2,2.5)))}.play;

//I actually like this, amazingly enough, might give myself the rest of the month off now? 

a={CombL.ar(In.ar(0,2),0.1,SinOsc.kr(0.25,0,0.05,0.05),SinOsc.kr(0.125,0,2,2.5))}.play;

b.free

a.free;

Tdef(\lctask1).play
Tdef(\lctask2).play

//now have enough material to play with!

(
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.5, q=0.1; 
var sound, env;

env=EnvGen.ar(Env.perc(0.1,sustain),doneAction:2);

sound=Resonz.ar(Gendy3.ar(4,3,freq:freq),Rand(10000,1000),q);

Out.ar(out, Pan2.ar(sound*amp*env,pan))
}).store;
)

b={Limiter.ar(Line.kr(0.0,0.5,20)*CombL.ar(In.ar(0,2),0.1,(SinOsc.kr(0.25,0,rrand(0.0,1.0)*25,465)).reciprocal,SinOsc.kr(0.125,0,2,2.5)))}.play;

//ok, half an hour in, might call it a day now?

//nah, build it up more

(
Tdef(\lctask6,{
var amountseq;

amountseq=Pseq((2*Array.fill(25, {[rrand(0.01,0.05),exprand(0.01,0.5)].wchoose([0.3,0.7])})),inf).asStream;

inf.do {

Synth(\lcsynth2,[\freq,rrand(0.0,rrand(0.0,1.0))*400+440,\sustain,rrand(1.0,8.0), \amount, amountseq.next]);
(rrand(0.0,6.0)).wait;
};

}).play;
)

b.free;

Tdef(\lctask6).stop

Tdef(\lctask5).stop

Tdef(\lctask6).play

Tdef(\lctask1).stop

Tdef(\lctask2).stop

(
Tdef(\lctask6,{
var amountseq;

amountseq=Pseq((2*Array.fill(25, {[rrand(0.01,0.05),exprand(0.01,0.5)].wchoose([0.3,0.7])})),inf).asStream;

inf.do {

Synth(\lcsynth2,[\freq,rrand(0.0,rrand(0.0,1.0))*4000+4400,\sustain,rrand(1.0,8.0), \amount, amountseq.next]);
(rrand(0.0,6.0)).wait;
};

}).play;
)

//too shrill

(
SynthDef(\lcsynth2, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1, amount=0.01; 
var sound, env;

env=EnvGen.ar(Env([1,0],[sustain]),doneAction:2);

sound=Resonz.ar(Mix(Pulse.ar(freq*[1-amount,1+amount],Rand(0.4,0.6),amp)),1000,0.1);

Out.ar(out, Pan2.ar(sound,pan))
}).store;
)

//very quiet now in background

(
SynthDef(\lcsynth2, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1, amount=0.01; 
var sound, env;

env=EnvGen.ar(Env([1,0],[sustain]),doneAction:2);

sound=Resonz.ar(Mix(Pulse.ar(freq*[1-amount,1+amount],Rand(0.4,0.6),amp)),SinOsc.kr(0.25,0,2000,3000),0.1);

Out.ar(out, Pan2.ar(sound,pan))
}).store;
)

//push end

b={Limiter.ar(Line.kr(0.0,10,20)*CombL.ar(In.ar(0,2),0.1,(SinOsc.kr(0.25,0,rrand(0.0,1.0)*25,465)).reciprocal,SinOsc.kr(0.125,0,2,2.5)))}.play;

//OW! but interesting

a={CombL.ar(In.ar(0,2),0.1,SinOsc.kr(0.25,0,0.05,0.05),SinOsc.kr(0.125,0,2,2.5))}.play;

//nice again dramatic return

Tdef(\lctask1).play;
Tdef(\lctask2).play

Tdef(\lctask6).stop

b.free

a.free

Tdef(\lctask1).stop;

Tdef(\lctask2).stop

//got it to end well!

//hmm, only a few days in and I actually enjoyed some of that, weird. And I played piano a little earlier today and hated it. Good sign?