--- /dev/null
+
+TempoClock.tempo = 240 / 60;
+
+~beri = ~bcrFactory.value;
+
+(
+~curNote = 60;
+~steps = (0..15);
+~intervalWeights = [1]++(0!15);
+~freqHigh = 3200;
+~freqLow = 200;
+~chorus = (0..15);
+~chorusWeights = [1]++(0!15);
+
+~durs = (1..8);
+~durWeights = (0!7) ++ [1];
+
+~legatos = (1..8)/8;
+~legatoWeights = (0!7) ++ [1];
+
+~decibels = [110, 100, 90, 80, 70, 60, 40, 20];
+~decibelWeights = [1] ++ (0!7);
+
+~pnotes = Pfunc({
+ var direction, step, upWeight, downWeight, chorus, curFreq;
+ upWeight = 1;
+ downWeight = 1;
+ curFreq = ~curNote.midicps;
+ if (curFreq > ~freqHigh, {downWeight = curFreq/~freqHigh;});
+ if (curFreq < ~freqLow, {upWeight = ~freqLow/curFreq;});
+ direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum);
+ step = ~steps.wchoose(~intervalWeights.normalizeSum);
+ ~curNote = ~curNote + (step * direction);
+ chorus = ~chorus.wchoose(~chorusWeights.normalizeSum);
+ [~curNote, ~curNote+chorus];
+});
+
+~pdurs = Pfunc({
+ var dur;
+ dur = ~durs.wchoose(~durWeights.normalizeSum);
+ dur;
+});
+
+~plegatos = Pfunc({
+ var legato;
+ legato = ~legatos.wchoose(~legatoWeights.normalizeSum);
+ legato;
+});
+
+~pdecibel = Pfunc({
+ var decibel;
+ decibel = ~decibels.wchoose(~decibelWeights.normalizeSum);
+ decibel;
+});
+)
+
+(
+~beri.turn = {|zi, val, num|
+ num.postln;
+ if (num <= 16, {
+ ~intervalWeights[num-1] = val;
+ ("interval "++~steps[num-1]++" weight changed to "++val).postln;
+ });
+ if ((num >= 17) && (num <= 32), {
+ ~chorusWeights[num-17] = val;
+ ("chorus "++~chorus[num-17]++" weight changed to "++val).postln;
+ });
+ if ((num >= 81) && (num <= 88), {
+ ~durWeights[num-81] = val;
+ ("duration "++~durs[num-81]++" weight changed to "++val).postln;
+ });
+ if ((num >= 89) && (num <= 96), {
+ ~legatoWeights[num-89] = val;
+ ("legato "++~legatos[num-89]++" weight changed to "++val).postln;
+ });
+ if ((num >= 97) && (num <= 104), {
+ ~decibelWeights[num-97] = val;
+ ("decibel "++~decibels[num-97]++" weight changed to "++val).postln;
+ });
+};
+)
+
+(
+Pdef(\qeka, ~de.feja <> Pbind(*[
+ midinote: ~co.bass,
+ dur: Pseq([5, 3], inf),
+ db: -19 + Pseq([-2, -3], inf),
+])).quant_(8).stop;
+)
+
+(
+Pdef(\maka, ~de.feja <> Pbind(*[
+ midinote: ~co.snare,
+ dur: Pseq([Rest(2), 4, 2], inf),
+ db: -29,
+])).quant_(8).stop;
+)
+
+(
+Pdef(\gitu, ~de.feja <> Pbind(*[
+ midinote: ~co.hatclosed,
+ dur: Pwrand([
+ Pseq(2!4, 1),
+ Pseq(1!8, 1),
+ Pseq(0.5!16, 1),
+ ], [15, 5, 1].normalizeSum, inf),
+ db: -32,
+])).quant_(8).stop;
+)
+
+(
+Pdef(\huzi, ~de.feja <> Pbind(*[
+ midinote: ~co.clap,
+ dur: 32/3 * Pwrand([
+ Pseq(1!3, 1),
+ Pseq(0.5!6, 1),
+ ], [5, 2].normalizeSum, inf),
+ db: -59,
+])).quant_(8).stop;
+)
+
+(
+Pdef(\xula, ~de.feja <> Pbind(*[
+ midinote: Prand([~co.side, ~co.rim, ~co.tomfloor, ~co.tomlow, ~co.tomhigh, ~co.hatopen, ~co.cowbell, ~co.ride, ~co.ccrash, ~co.ride2, ~co.splash, ~co.hatsemiopen], inf),
+ dur: 4 * Prand([2, 3, 4], inf),
+ db: -37,
+])).quant_(8).stop;
+)
+
+(
+Pdef(\rulu, ~de.dufe <> Pbind(
+ \midinote, ~pnotes.trace,
+ \dur, ~pdurs/2,
+ \legato, ~plegatos,
+ \amp, ~pdecibel/127,
+)).quant_(8).stop;
+)
+
+(
+Pdef(\dipo, ~de.dufe <> Pbind(
+ \midinote, ~pnotesLow-24,
+ \dur, ~pdursLow*3/2,
+ \legato, ~plegatosLow,
+ \amp, ~pdecibelLow/127,
+)).quant_(8).stop;
+)
+
+(
+~curNoteLow = 60;
+
+~pnotesLow = Pfunc({
+ var direction, step, upWeight, downWeight, chorus, curFreq;
+ upWeight = 1;
+ downWeight = 1;
+ curFreq = ~curNoteLow.midicps;
+ if (curFreq > ~freqHigh, {downWeight = curFreq/~freqHigh;});
+ if (curFreq < ~freqLow, {upWeight = ~freqLow/curFreq;});
+ direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum);
+ step = ~steps.wchoose(~intervalWeights.normalizeSum);
+ ~curNoteLow = ~curNoteLow + (step * direction);
+ chorus = ~chorus.wchoose(~chorusWeights.normalizeSum);
+ [~curNoteLow, ~curNoteLow+chorus];
+});
+
+~pdursLow = Pfunc({
+ var dur;
+ dur = ~durs.wchoose(~durWeights.normalizeSum);
+ dur;
+});
+
+~plegatosLow = Pfunc({
+ var legato;
+ legato = ~legatos.wchoose(~legatoWeights.normalizeSum);
+ legato;
+});
+
+~pdecibelLow = Pfunc({
+ var decibel;
+ decibel = ~decibels.wchoose(~decibelWeights.normalizeSum);
+ decibel;
+});
+)
+
+(
+Pdef(\heri, ~de.dufe <> Pbind(
+ \midinote, ~pnotesMid-12,
+ \dur, ~pdursMid,
+ \legato, ~plegatosMid,
+ \amp, ~pdecibelMid/127,
+)).quant_(8).stop;
+)
+
+(
+~curNoteMid = 60;
+
+~pnotesMid = Pfunc({
+ var direction, step, upWeight, downWeight, chorus, curFreq;
+ upWeight = 1;
+ downWeight = 1;
+ curFreq = ~curNoteMid.midicps;
+ if (curFreq > ~freqHigh, {downWeight = curFreq/~freqHigh;});
+ if (curFreq < ~freqLow, {upWeight = ~freqLow/curFreq;});
+ direction = [-1, 1].wchoose([downWeight**3, upWeight**3].normalizeSum);
+ step = ~steps.wchoose(~intervalWeights.normalizeSum);
+ ~curNoteMid = ~curNoteMid + (step * direction);
+ chorus = ~chorus.wchoose(~chorusWeights.normalizeSum);
+ [~curNoteMid, ~curNoteMid+chorus];
+});
+
+~pdursMid = Pfunc({
+ var dur;
+ dur = ~durs.wchoose(~durWeights.normalizeSum);
+ dur;
+});
+
+~plegatosMid = Pfunc({
+ var legato;
+ legato = ~legatos.wchoose(~legatoWeights.normalizeSum);
+ legato;
+});
+
+~pdecibelMid = Pfunc({
+ var decibel;
+ decibel = ~decibels.wchoose(~decibelWeights.normalizeSum);
+ decibel;
+});
+)
+