///////////////////////////////////////////////////
// History, as it was on Fri Aug 25 23:26:49 2006.
///////////////////////////////////////////////////

// - 0:0:0 -  
//tonight, more speculative investigation of Fourier balances as presented by Carol Krumhansl ealier on

// - 0:1:47.89 -  
11.div(2)

// - 0:11:25.12 -  
~f1= {arg pcset, m, n;var tmp, tmp2, tmp3, count;  if(m>(n.div(2)),{m=n-m-1;}); tmp= gcd(m,n); 

tmp2= Array.fill(n/tmp, {arg i; (i*m)%n}).sort;

tmp3= Array.fill(tmp, {arg i; tmp2+i;});

count= Array.fill(tmp, {0});

pcset.do({arg val; var index; index=0; tmp3.do({arg val2,j; val2.do({arg val3; if(val3==val,{index=j}) })}); count[index]=count[index]+1; });

count
};

// - 0:11:54.2 -  
~f1.value([0,1,2],4,12)

// - 0:11:59.88 -  
~f1.value([0,1,2],3,12)

// - 0:12:6.47 -  
~f1.value([0,1,2],5,12)

// - 0:12:11.31 -  
~f1.value([0,1,2],7,12)

// - 0:12:31.16 -  
~f1= {arg pcset, m, n;var tmp, tmp2, tmp3, count;  if(m>(n.div(2)),{m=n-m;}); tmp= gcd(m,n); 

tmp2= Array.fill(n/tmp, {arg i; (i*m)%n}).sort;

tmp3= Array.fill(tmp, {arg i; tmp2+i;});

count= Array.fill(tmp, {0});

pcset.do({arg val; var index; index=0; tmp3.do({arg val2,j; val2.do({arg val3; if(val3==val,{index=j}) })}); count[index]=count[index]+1; });

count
};

// - 0:12:32.24 -  
~f1.value([0,1,2],7,12)

// - 0:12:35.64 -  
~f1.value([0,1,2],8,12)

// - 0:12:38.42 -  
~f1.value([0,1,2],2,12)

// - 0:13:1.75 -  
//function took a lot of effort and time!

// - 0:14:5.01 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(freq, 0, LFNoise0.kr(Rand(5,7.5),0.2,0.8)*amp);

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

// - 0:16:3.33 -  
Tdef(\lctask1,{

inf.do {
var stuff;

stuff= ~f1.value([0,4,7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*100+(j*200)]) });
1.0.wait;
};

}).play;

// - 0:16:38.69 -  
Tdef(\lctask1,{

inf.do {
var stuff;

stuff= ~f1.value([0,4,7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*100+(j*200)]) });
1.0.wait;
};

}).play(quant:1.0);

// - 0:17:16.07 -  
Tdef(\lctask2,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*100+(j*200)]) });
1.0.wait;
};

}).play(quant:1.0);

// - 0:17:26.61 -  
Tdef(\lctask2,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*200+(j*400)]) });
1.0.wait;
};

}).play(quant:1.0);

// - 0:17:32.49 -  
Tdef(\lctask2,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*200+(j*400)]) });
0.5.wait;
};

}).play(quant:1.0);

// - 0:17:58.78 -  
Tdef(\lctask3,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),14);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*200+(j*400)]) });
0.25.wait;
};

}).play(quant:1.0);

// - 0:18:11.11 -  
Tdef(\lctask3,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),14);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*300+(j*500)]) });
0.25.wait;
};

}).play(quant:1.0);

// - 0:18:26.54 -  
Tdef(\lctask3,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),14);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200)]) });
0.25.wait;
};

}).play(quant:1.0);

// - 0:18:54.35 -  
Tdef(\lctask4,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),rrand(14,20));

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200)]) });
0.125.wait;
};

}).play(quant:1.0);

// - 0:19:18.53 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(XLine.kr(freq,freq*0.25,0.1), 0, LFNoise0.kr(Rand(5,7.5),0.2,0.8)*amp);

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

// - 0:19:34.63 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(XLine.kr(freq,freq*0.5,0.1), 0, LFNoise0.kr(Rand(5,7.5),0.2,0.8)*amp);

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

// - 0:19:58.12 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(XLine.kr(freq,freq*0.5,0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp);

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

// - 0:20:17.1 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(XLine.kr(freq, 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp));

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

// - 0:20:34.26 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(freq, 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp);

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

// - 0:20:47.72 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=LFSaw.ar(Line.kr(freq,freq*2,0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp);

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

// - 0:21:8.1 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=Resonz.ar(LFSaw.ar(Line.kr(freq,freq*2,0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp),Rand(2000,3000),0.3);

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

// - 0:21:46.24 -  
Tdef(\lctask2,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*200+(j*400),\amp, i*0.125.max(0.125).min(0.5)]) });
0.5.wait;
};

}).play(quant:1.0);

// - 0:21:56.03 -  
Tdef(\lctask3,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),14);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200),\amp, i*0.125.max(0.125).min(0.5)]) });
0.25.wait;
};

}).play(quant:1.0);

// - 0:22:2.36 -  
Tdef(\lctask4,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),rrand(14,20));

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200),\amp, i*0.125.max(0.125).min(0.5)]) });
0.125.wait;
};

}).play(quant:1.0);

// - 0:22:14.79 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=Resonz.ar(LFSaw.ar(Line.kr(freq,freq*4,0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp),Rand(2000,3000),0.3);

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

// - 0:22:20.77 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=Resonz.ar(LFSaw.ar(Line.kr(freq,freq*0.25,0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp),Rand(2000,3000),0.3);

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

// - 0:22:28.48 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=Resonz.ar(LFSaw.ar(Line.kr(freq,freq*0.25,sustain), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp),Rand(2000,3000),0.3);

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

// - 0:22:37.1 -  
Tdef(\lctask1,{

inf.do {
var stuff;

stuff= ~f1.value([0,4,7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*100+(j*200),\sustain,0.5]) });
1.0.wait;
};

}).play(quant:1.0);

// - 0:22:46.53 -  
Tdef(\lctask2,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7],rrand(1,6),12);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*200+(j*400),\amp, i*0.125.max(0.125).min(0.5),\sustain,0.5]) });
0.5.wait;
};

}).play(quant:1.0);

// - 0:22:53.66 -  
Tdef(\lctask3,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),14);

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200),\amp, i*0.125.max(0.125).min(0.5),\sustain,0.5]) });
0.25.wait;
};

}).play(quant:1.0);

// - 0:22:59.98 -  
Tdef(\lctask4,{

inf.do {
var stuff;

stuff= ~f1.value([rrand(0,3),rrand(0,3)+4,rrand(0,3)+7, rrand(0,3)+10],rrand(1,7),rrand(14,20));

stuff.do({arg i,j; Synth(\lcsynth1,[\freq, i*400+(j*200),\amp, i*0.125.max(0.125).min(0.5),\sustain,0.5]) });
0.125.wait;
};

}).play(quant:1.0);

// - 0:23:22.01 -  
SynthDef(\lcsynth1, {arg out=0, amp=0.1, pan=0.0, freq=440, sustain=0.1; 
var sound, env;

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

sound=Resonz.ar(LFSaw.ar(Line.kr(freq*0.25,freq,sustain*0.1), 0, LFNoise0.kr(Rand(5,17.5),0.2,0.8)*amp),Rand(2000,3000),0.3);

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

// - 0:23:50.09 -  
//CRASH!
TempoClock.default.tempo_(19)