ark_d.amorphic/on-the-fly-preload.scd

404 lines
9.1 KiB
Plaintext

// ideas:
/*
- bassline
- harmonic line/melody
- long strings - low
- kick, hihat, perc, snare.
- effects? - buses!
- prep underlaying elements.
- preload samples
- preload synthdefs
- preload Pdefs
- print or note patterns and ideas on paper.
- train 3x at least. print out.
*/
(
// preload samples
var smpPath = PathName(thisProcess.nowExecutingPath.dirname +/+ "smp");
// load samples
"\n--- load samples: ...".postln;
// free all buffers to restart buffer count
~smpBuffers.do(_.free);
// create Dictionary
~smpBuffers = Dictionary();
// iterate over each file in the folder
smpPath.filesDo({ |smpfile,i|
// tell me what you are loading:
postln(" " + i + smpfile.fileName );
// add a sample into a buffer, store object to Dictionary
~smpBuffers.add(smpfile.fileName -> Buffer.readChannel(s,
smpfile.fullPath, channels:[0]));
});
// function to partially match filename for buffers
~getSmp = { |regexp|
~smpBuffers.detect { |buf|
regexp.matchRegexp(buf.path)
}
};
// counter for 9 minutes
~counter = Routine {
(9 * 60).do(
{ arg item;
var timeleft = (9*60)-item;
if (timeleft.mod(10)==0, {postln("--- toGo:" + ((9*60)-item) + "---")});
1.wait;
}
);
(1000).do({
100.do({post("..time is up!!!!!")});
1.wait;
});
};
// ~counter.play
// ~counter.stop
///////////////////////////////////////////////////////////////////////////
// Synthdefs predefined
postln("--- synthdefs ...");
// synthdefs?
SynthDef(\bufCyc, {
arg bufnum, gate=1, freq=440, chanDetune=1, out=0, amp = 1,
attackTime=0.01, releaseTime=1, lpf=10;
var snd, env, lpfreq;
env = Linen.kr(gate, attackTime:attackTime, releaseTime:releaseTime, doneAction:2);
freq = [freq, freq * (1 + (chanDetune * 0.0005))];
snd = BufRd.ar(
numChannels: 1,
bufnum: bufnum,
phase: LFSaw.ar(freq).range(0, BufFrames.ir(bufnum)),
loop: 1,
interpolation: 2);
lpfreq = freq * lpf;
lpfreq = lpfreq.max(100);
lpfreq = lpfreq.min(18000);
snd = LPF.ar(snd, lpfreq);
snd = snd * amp * env;
Out.ar(out, snd);
}).add;
SynthDef(\smplr, {|out = 0, revBus, bufnum = 0, gate = 1, amp = 1, pan = 0, rate = 1, revWet = 0 |
var snd, env;
snd = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, loop: 0);
env = EnvGen.kr(envelope: Env.cutoff(0.001,1), gate: gate, doneAction:Done.freeSelf);
snd = snd * env * amp;
snd = Pan2.ar(snd, pan);
Out.ar(out, snd);
//Out.ar(revBus * revWet, snd);
}).add;
///////////////////////////////////////////////////////////////////////////
// pdef predefined
postln("--- pdefs ...");
Pdef(\bsln1, Pbind( \instrument, \bufCyc,
\bufnum, [~getSmp.("0043"),~getSmp.("0043")],
\octave, [3,2],
\detune, [0.1,0],
\chanDetune, 20,
\legato, 0.2,
\amp, [0.3,0.9,0.1] * 0.5,
\releaseTime, 0.1,
\degree, 2,
// \dur, 1
)).quant_(2);
Pdef(\strng1, Pbind( \instrument, \bufCyc,
\bufnum, [~getSmp.("sincyc06"),~getSmp.("sincyc06")],
//\dur, Pseq([3/4,2/4,1/4]*2/3,inf),
//\degree, Pseq([[4,9],2,8,4,1], inf),
//\octave, Prand([[6,5,7],[4,5,7],[7,5,4]],inf),
\octave, 4,
//\mtranspose, Pstutter(12, Pseq([1,0,-2,3,-3],inf)),
\detune, [0,0.3,-0.3],
\chanDetune, Pseq([-10,0,5,10,-5],inf),
\amp, [0.3,0.5,0.1] * 0.15,
\legato, 0.1,
\releaseTime, Prand([1,2,3,4],inf)
)).quant_(8);
// =====================================================================
// percussion with sampler
// =====================================================================
Pdef(\bd1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("bd01"),
//\dur, Pseq([3/4, 1, 1, 1, 1/4],inf),
//\dur, Pseq([3/4, 1, 1, 1, 1/4],inf),
\amp, 0.6
)
).quant_(8);
/*
Pdef(\bd2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("bd02"),
\dur, Pseq([1+(1/4), 1, 1, 1/4],inf),
\amp, 0.5
)
).quant_(8);
Pdef(\bd3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("bd03"),
\dur, Pseq([1+(1/4), 1, 1, 1/4],inf),
\amp, 0.5
)
).quant_(8);
*/
Pdef(\hh1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("hh01"),
\dur, 1/2,
\amp, Prand([1,1.2,0.8]*0.5,inf),
\rate, Prand([0.99,1,1.01],inf),
\pan, Prand([-0.2, 0, 0.2], inf)
)
).quant_(8);
Pdef(\hh2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("hh02"),
\dur, 1/2,
\amp, Prand([1,1.2,0.8] * 0.7,inf),
\rate, Prand([0.99,1,1.01],inf),
\pan, Prand([-0.2, 0, 0.2], inf)
)
).quant_(8);
Pdef(\hh3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("hh03"),
\dur, 1/4,
\amp, Prand([1,1.2,0.8]*0.2,inf),
\rate, Prand([0.99,1,1.01],inf),
\pan, Prand([-0.2, 0, 0.2], inf)
)
).quant_(8);
Pdef(\oh1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("oh01"),
\dur, Pseq([Rest(13/4),3/4],inf),
\amp, 0.4,
\pan, 0
)
).quant_(8);
Pdef(\oh2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("oh02"),
\dur, Pseq([Rest(13/4),3/4],inf),
\amp, 0.4,
\pan, 0
)
).quant_(8);
Pdef(\oh3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("oh03"),
\dur, Pseq([Rest(13/4),3/4],inf),
\amp, 0.4,
\pan, 0
)
).quant_(8);
Pdef(\sn1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("sn01"),
//\dur, Pseq([Rest(1),1],inf),
//\dur, Pseq([Rest(1),1],inf),
\amp, 1
)
).quant_(8);
Pdef(\sn2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("sn02"),
\dur, Pseq([Rest(1),1],inf),
\amp, 0.5
)
).quant_(8);
Pdef(\sn3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("sn03"),
\dur, Pseq([Rest(1),1],inf),
\amp, 2
)
).quant_(8);
Pdef(\perc1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("perc07"),
//\dur, Pseq([2],inf),
\dur, 1,
\amp, 0.6,
\rate, Prand((90..110) * 0.01,inf)
)
).quant_(8);
Pdef(\perc2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("perc03"),
//\dur, Pseq([ Pn(1/2,6), 1/4, 1/2, 1/4 ],inf),
\dur, 1,
\amp, 0.7,
\rate, Prand([0.8,0.9,1,1.1,1.2,1.5],inf)
)).quant_(8);
Pdef(\perc3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("perc05"),
\dur, Pseq([ Pn(1/2,6), 1/4, 1/2, 1/4 ],inf),
// \amp, 0.5,
\rate, Prand((90..110) * 0.01,inf),
\pan, Prand([-0.2, 0, 0.2], inf)
)).quant_(8);
Pdef(\cl1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("cl01"),
\dur, Pseq([ Rest(1), 1.5 ],inf),
\amp, 1,
// \rate, Prand([0.8,0.9,1,1.1,1.2,1.5],inf)
)
).quant_(8);
Pdef(\cl2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("cl04"),
\dur, Pseq([ Rest(1.5), 3/4 ],inf),
\amp, 1,
// \rate, Prand([0.8,0.9,1,1.1,1.2,1.5],inf)
)).quant_(8);
Pdef(\cl3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("cl05"),
\dur, Pseq([ Rest(3/4), 6/4],inf),
// \amp, 0.5,
\rate, Prand((90..110) * 0.01,inf),
// \pan, Prand([-0.2, 0, 0.2], inf)
)).quant_(8);
Pdef(\gl1, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("gl01"),
\dur, Pseq([1,3,2,3 ] / 3,inf),
\amp, 1,
// \rate, Prand([0.8,0.9,1,1.1,1.2,1.5],inf)
)
).quant_(8);
//Pdef(\gl1).play
//s.scope(4)
Pdef(\gl2, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("gl04"),
\dur, Pseq([ 3,4,2,3,1 ] / 2,inf),
\amp, 1,
// \rate, Prand([0.8,0.9,1,1.1,1.2,1.5],inf)
)).quant_(8);
Pdef(\gl3, Pbind( \instrument, \smplr, \bufnum, ~getSmp.("gl05"),
\dur, Pseq([ 4,3,4,3,4,2,1 ] / 4,inf),
// \amp, 0.5,
\rate, Prand((90..110) * 0.01,inf),
// \pan, Prand([-0.2, 0, 0.2], inf)
)).quant_(8);
postln("--- init finished.");
"";
);
//////////////////////////////////////////////////////////////////////////////////
// pre-score help!
100.do({post("... hola every1, I'm Luka. Luka P. :)")})
~counter.reset
~counter.play
~counter.stop
Ndef(\n1).play
Ndef(\n1).fadeTime = 15
(
Ndef(\n1, {
var flt1, flt2, flt3, snd = WhiteNoise.ar;
flt1 = BPF.ar(snd, LFNoise1.ar(0.1).range(100,1000), 0.3);
flt2 = BPF.ar(snd, LFNoise1.ar(0.1).range(100,1000), 0.3);
flt3 = BPF.ar(snd, LFNoise1.ar(0.1).range(100,1000), 0.3);
snd = flt1 + flt2 + flt3;
snd!2 * 0.5;
});
)
// possible development
Pdef(\bsln1).play;
(
Pbindef(\bsln1,
\dur, Pseq([1,2,3] * 1/4, inf),
\degree, Pstutter(2, Pxrand([1,2,3,0] , inf)),
\mtranspose, Pstutter(20, Pxrand([1,2,3], inf) ),
\legato, Pxrand([1,2,3]*0.3, inf),
\amp, [0.3,0.9,0.1] * 0.5,
)
)
Pdef(\strng1).play
(
Pbindef(\strng1,
\degree, Pseq([[9,4],2,8,4,1], inf),
\dur, Pseq([3,2,1]*2/8, 3),
\mtranspose, Pstutter(10,Pseq([1,0,-2,3,-3],inf)),
\ctranspose, Pseq([Pn(0,60), Pn(7,60)],inf), //later!!!
\octave, Pseq([[4,5,6],[5,6,7],[7,4,5]]-1,inf),
\octave, [3,4],
\legato, 0.1,
)
)
Pbindef(\bd1, \dur, Pseq([3/4, 1, 1, 1, 1/4], inf))
Pbindef(\bd1, \dur, Pseq([3/4, 1, 1/2, 1/2, 1, 1/4], inf))
Pbindef(\bd1, \dur, Pseq([1/2], inf))
Pdef(\bd1).play
Pdef(\bd1).clear
Pbindef(\hh1, \dur, 1/2)
Pdef(\hh1).play
Pbindef(\hh2, \dur, Pseq([Rest(1/4),1/4],inf))
Pdef(\hh2).play
Pbindef(\hh3, \dur, 1/4)
Pbindef(\hh3, \dur, 1/8)
Pbindef(\hh3, \dur, 1/6)
Pbindef(\hh3, \dur, 1/3)
Pbindef(\hh3, \dur, Pxrand([Pn(1/8, 16), Pn(1/6,12)],inf)
Pbindef(\hh3, \dur, Pseq([Pxrand([Pn(1/8, 16), Pn(1/6,12)], 8), Rest(8)],inf))
Pdef(\hh3).play
Pdef(\hh3).stop
Pdef(\hh3).clear
Pbindef(\perc1, \dur, Pseq([2,1.5],inf))
Pdef(\perc1).play
Pbindef(\perc2, \dur, Pseq([ Pn(1/2, 3), 1/4, 1/8, 1/4 ],inf))
Pdef(\perc2).play
Pbindef(\sn1, \dur, Pseq([Rest(1),1,Rest(1), Prand([1,1/2],1)],inf) )
Pdef(\sn1).play
Pbindef(\sn2, \dur, Pseq([Rest(1),1, 1/2, 2, 1/2, 1/4],inf))
Pdef(\sn2).play; ////////////////////////////////////////////////
(
Pdef(\bsln1).stop;
Pdef(\bd1).stop;
Pdef(\bd2).stop;
Pdef(\hh1).stop;
Pdef(\hh2).stop;
Pdef(\hh3).stop;
Pdef(\sn1).stop;
Pdef(\sn2).stop;
Pdef(\perc1).stop;
Pdef(\perc2).stop;
)