p= ProxySpace.push(s.boot)
p.makeTempoClock(1.4)
c= p.clock

//trying pattern melodies
Pdef(\chord, Pbind(\dur, 0.5, \note, Pseq([0, 3, 5, 0, 3, 5, -2, 3, 5, -2, 3, 5, -3, 3, 5, -3, 3, 5, -4, 3, 5, -4, 4, 5], inf))).play
Pdef(\chord, Pbind(\amp, Pseq([0.1, 0.06, 0.07], inf), \legato, Pseq([1.5, 1, 1], inf), \dur, 0.5, \degree, Pseq([-1, 3, 5, -1, 3, 5, -2, 3, 5, -2, 3, 5, -5, 3, 5, -5, 3, 5, -4, 3, 5, -3, 4, 5], inf)))
Pdef(\chord).stop

(
SynthDef(\chord, {|freq= 400, amp= 0.1, gate= 1, dur= 1|
	var e, z;
	e= EnvGen.kr(Env.perc(0.1, dur), gate, doneAction:2);
	z= LPF.ar(Saw.ar(freq, amp), freq*2);
	Out.ar(0, e*z);
}).store
)

Pdef(\chord, Pbind(\instrument, \chord, \amp, Pseq([0.1, 0.06, 0.07], inf), \legato, Pseq([1.5, 1, 1], inf), \dur, 0.5, \degree, Pseq([-1, 3, 5, -1, 3, 5, -2, 3, 5, -2, 3, 5, -5, 3, 5, -5, 3, 5, -4, 3, 5, -3, 4, 5], inf))).play

(
SynthDef(\chord, {|freq= 400, amp= 0.1, gate= 1, len= 1|
	var e, z;
	e= EnvGen.kr(Env.perc(0.1, len), gate, doneAction:2);
	z= LPF.ar(Pulse.ar(freq, SinOsc.ar(freq/2, 0, 0.1, 0.5), amp), freq*2);
	Out.ar(0, Pan2.ar(e*z));
}).store
)

(
SynthDef(\chord, {|freq= 400, amp= 0.1, gate= 1, len= 1|
	var e, z;
	e= EnvGen.kr(Env.perc(0.1, len), gate, doneAction:2);
	z= LPF.ar(Pulse.ar(freq*[1, 1.01], SinOsc.ar(freq/2, 0, 0.1, Rand(0.4, 0.6)), amp), freq*2);
	Out.ar(0, e*z);
}).store
)

(
SynthDef(\mel, {|freq= 400, amp= 0.1, gate= 1, len= 1|
	var e, z;
	e= EnvGen.kr(Env.perc(0.8, len), gate, doneAction:2);
	z= LPF.ar(SinOsc.ar(freq*[1, 1.01], SinOsc.ar(freq/2, 0, 0.1, Rand(0.4, 0.6)), amp), freq*2);
	Out.ar(0, e*z);
}).store
)

Pdef(\mel).play(c)
Pdef(\mel, Pbind(\instrument, \mel, \degree, Pseq([7, 12, 7, 6, 5, 5], inf), \len, 4, \dur, Pseq([4, 6, 4, 6, 2, 4], inf)))

Pdef(\mel2).play(c)
Pdef(\mel2, Pbind(\instrument, \mel, \amp, Pseq([0.04, 0.05], inf), \degree, Pseq([14, 15, 14, 15, 16, 19], inf), \len, 0.4, \dur, Pseq([4, 6, 4, 6, 2, 4]*0.25, inf)))

(
a= 0;
b= 0;
d= 0;
Pdef(\mel, Pbind(\instrument, \mel, \degree, Pseq([7, 12, 7, 6, 5, 5], inf), \len, 4, \dur, Pseq([4, 6, 4, 6, 2, 4], inf), \mtranspose, Pfunc({a})));
Pdef(\mel2, Pbind(\instrument, \mel, \amp, Pseq([0.04, 0.05], inf), \degree, Pseq([14, 15, 14, 15, 16, 19], inf), \len, 0.4, \dur, Pseq([4, 6, 4, 6, 2, 4]*0.25, inf), \mtranspose, Pfunc({b})));
Pdef(\chord, Pbind(\instrument, \chord, \amp, Pseq([0.1, 0.06, 0.07], inf), \legato, Pseq([1.5, 1, 1], inf), \dur, 0.5, \degree, Pseq([-1, 3, 5, -1, 3, 5, -2, 3, 5, -2, 3, 5, -5, 3, 5, -5, 3, 5, -4, 3, 5, -3, 4, 5], inf), \mtranspose, Pfunc({d})));
)

a= -5
b= -5
d= -5
d= 0

a= -7
d= -2
b= -3
d= 0

Pdef(\mel2, Pbind(\instrument, \mel, \amp, Pseq([0.04, 0.05], inf), \degree, Pseq([14, 15, 14, 15, 16, 19, 19, 17], inf), \len, 0.4, \dur, Pseq([4, 6, 4, 6, 2, 4, 3, 3]*0.25, inf), \mtranspose, Pfunc({b})));

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([3, 3], inf), \degree, Pseq([-12], inf), \mtranspose, Pfunc({d})));
Pdef(\bass).play(c, quant:4)
Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([3, 3, 3, 1.5, 1.5], inf), \degree, Pseq([-12, -13, -14, -10, -11], inf), \mtranspose, Pfunc({d})));
[3, 3, 3, 1.5, 1.5].sum

(
Pdef(\bass).stop;
Pdef(\chord).stop;
Pdef(\mel).stop;
Pdef(\mel2).stop;
)
c.tempo_(1)
(
Pdef(\bass).play(c);
Pdef(\chord).play(c);
Pdef(\mel).play(c);
Pdef(\mel2).play(c);
)

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([3, 3, 3, 1.5, 1.5], inf), \degree, Pseq([-12, -13, -14, -10, -11], inf), \mtranspose, Pfunc({d})));

b= 0
a= -5

Pdef(\mel2, Pbind(\instrument, \mel, \amp, Pseq([0.04, 0.05], inf), \degree, Pseq([14, 15, 14, 15, 16, 19, 19, 17].scramble, inf), \len, 0.4, \dur, Pseq([4, 6, 4, 6, 2, 4, 3, 3].scramble*0.25, inf), \mtranspose, Pfunc({b})));

b= 3
Pdef(\mel2, Pbind(\instrument, \mel, \amp, Pseq([0.04, 0.05], inf), \degree, Pseq([14, 15, 14, 15, 16, 19, 19, 17].scramble, inf), \len, 0.4, \dur, Pseq([4, 6, 4, 6, 2, 4, 3, 3].scramble*0.25, inf), \mtranspose, Pfunc({b})));

b= 0

Pdef(\mel, Pbind(\instrument, \mel, \degree, Pseq([7, 12, 7, 6, 5, 5].scramble, inf), \len, 4, \dur, Pseq([4, 6, 4, 6, 2, 4].scramble*0.5, inf), \mtranspose, Pfunc({a})));

f= 1
Pdef(\chord, Pbind(\instrument, \chord, \amp, Pseq([0.1, 0.06, 0.07], inf)*Pfunc({f.value}), \legato, Pseq([1.5, 1, 1], inf), \dur, 0.5, \degree, Pseq([-1, 3, 5, -1, 3, 5, -2, 3, 5, -2, 3, 5, -5, 3, 5, -5, 3, 5, -4, 3, 5, -3, 4, 5], inf), \mtranspose, Pfunc({d})));
f= 0.8
f= 0.6
f= 0.5
f= {[0.7, 0.5, 0].choose}
f= {[0.5, 0].choose}

b= -5
d= -5
a= -5

Pdef(\mel2).stop
Pdef(\mel, Pbind(\instrument, \mel, \degree, Pseq([7, 12, 7, 6, 5, 5].scramble, inf), \len, 6, \dur, Pseq([4, 6, 4, 6, 2, 4].scramble*0.5, inf), \mtranspose, Pfunc({a})));

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([7, 12, 7, 6, 5, 5].scramble, inf), \len, 6, \dur, Pseq([4, 6, 4, 6, 2, 4].scramble*0.5, inf), \mtranspose, Pfunc({a})));

a= -12
f= {[0.3, 0, 0].choose}

b= -24
Pdef(\mel2).play(c)
d= -24
f= 0.01
d= 5

a= -7
Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([7, 12, 7, 6, 5, 5].scramble, inf), \len, Prand([2, 3], inf), \dur, Pseq([4, 6, 4, 6, 2, 4].scramble*0.25, inf), \mtranspose, Pfunc({a})));

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([2/3, 2/3, 5/3, 3, 3, 1.5, 1.5], inf), \degree, Pseq([-5, -6, -5, -12, -13, -14, -10, -11], inf), \mtranspose, Pfunc({d})));
[2/3, 2/3, 5/3].sum

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 7, 6, 5, 5].scramble, inf), \len, Prand([2, 3], inf), \dur, Pseq([1/3, 2/3, 3, 6, 4, 6, 2, 4].scramble*0.25, inf), \mtranspose, Pfunc({a})));

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([2/3, 2/3, 5/3, 1/3, 2/3, 2, 3, 1.5, 1.5], inf), \degree, Pseq([-5, -6, -5, 0, -4, -12, -13, -14, -10, -11], inf), \mtranspose, Pfunc({d})));

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 7, 6, 5, 0, 0, 5], inf), \len, Prand([2, 3], inf), \dur, Pseq([1/3, 2/3, 3, 6, 4, 6, 2, 1/3, 1/3, 1/3, 3]*0.25, inf), \mtranspose, Pfunc({a})));

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([2/3, 2/3, 5/3, 1/3, 2/3, 2, 2, 2/3, 1/3, 1.5, 1.5], inf), \degree, Pseq([-5, -6, -5, 0, -4, -12, -13, -14, -4, 0, -11], inf), \mtranspose, Pfunc({d})));

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 2, 0, 7, 6, 5, 0, 0, 5], inf), \len, Prand([2, 3], inf), \dur, Pseq([1/3, 2/3, 1, 4/3, 2/3, 6, 4, 6, 2, 1/3, 1/3, 1/3, 3]*0.25, inf), \mtranspose, Pfunc({a})));

b
Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 2, 0, 7, 0, 0, 0, 6, 5, 0, 0, 5], inf), \len, Prand([2, 3, 1], inf), \dur, Pseq([1/3, 2/3, 1, 4/3, 2/3, 3, 3, 1, 3, 6, 2, 1/3, 1/3, 1/3, 3]*0.25, inf), \mtranspose, Pfunc({a})));
[1/3, 2/3, 1, 4/3, 2/3, 3, 3, 1, 3, 6, 2, 1/3, 1/3, 1/3, 3].size
[0, 0, 7, 12, 2, 0, 7, 0, 0, 0, 6, 5, 0, 0, 5].size

Pdef(\bass, Pbind(\instrument, \chord, \amp, 0.1, \len, 2, \dur, Pseq([2/3, 2/3, 5/3, 1/3, 2/3, 1, 1, 4/3, 2/3, 2/3, 1/3, 1.5, 1.5], inf), \degree, Pseq([-5, -6, -5, 0, -4, -12, -13, -14, 0, -4, 0, -10, -11], inf), \mtranspose, Pfunc({d})));
d= 7

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 2, 0, 7, 12, 0, 12, 6, 5, 12, 0, 5], inf), \len, Prand([2, 1, 0.5], inf), \dur, Pseq([1/3, 2/3, 1, 4/3, 2/3, 3, 3, 1, 3, 6, 2, 1/3, 1/3, 1/3, 3]*0.25, inf), \mtranspose, Pfunc({a})));

d= 9
b= -16
b= -12
d= 12
b= -6

Pdef(\mel, Pbind(\instrument, \mel, \amp, Prand([0.1, 0], inf), \degree, Pseq([0, 0, 7, 12, 2, 0], inf), \len, Prand([0.25, 1, 0.5], inf), \dur, Pseq([1/3, 2/3, 1, 4/3, 2/3, 3]*0.25, inf), \mtranspose, Pfunc({a})));

Pdef(\mel2).stop
Pdef(\chord).play(c)
f= 0.1
a= 0
Pdef(\mel).stop

d= 16
d= 20
d= 24

Pdef(\bass).stop
Pdef(\chord).stop
p.clear
p.pop