Hey, im trying to convert the Iteration attempt to play different soundfiles from a folder with a routine to be used with a Pmono and get the same results. Im not sure if i have to use \timingOffset
or \lag
or something to mimic the waittime of the routine example inside the Pmono. any ideas?
here is the code:
// Iteration with Routines
(
SynthDef(\resonator_routine, {
arg sndBuf=0;
var freqs = (51 + ([3, 7, 12, 14, 15, 24, 26] +.x [0, 12])).midicps *.x [1, 1.008];
var sig, env, exc;
env = EnvGen.ar(Env([0,1,1,0],[\atk.kr(0.01),\sus.kr(1),\rel.kr(3)],[0,\c1.kr(1),0,\c2.kr(-1)]), doneAction:2);
exc = PlayBuf.ar(1, sndBuf, \rate.kr(1) * BufRateScale.ir(sndBuf), startPos: \spos.kr(0));
exc = exc * -50.dbamp * env;
exc = HPF.ar(exc, 100);
sig = Klank.ar(`[freqs, 1 ! freqs.size, BufDur.ir(sndBuf) ! freqs.size], exc, decayscale: \dec.kr(0.18));
sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
Out.ar(\out.kr(0), sig);
}).add;
)
(
r = Routine({
loop {
15.do{|i|
Synth(\resonator_routine,
[
\atk, rrand(0.1, 2.0),
\sus, rrand(0.5, 2.0),
\rel, exprand(2.0, 6.0),
\c1, exprand(1,8),
\c2, exprand(-8,-1),
\sndBuf, ~samples[\sawblade_long].choose,
\rate, rrand(0.95, 1.05),
\amp, exprand(0.08, 0.18),
\pan, rrand(-0.9, 0.9),
\spos, rrand(0, 10000),
\dec, exprand(0.08, 0.18),
\out, i.wrap(0,1),
]
);
rrand(0.2, 0.4).wait;
};
rrand(2.0, 3.0).wait;
};
}).play;
)
r.stop;
// Iteration with Pmono
(
SynthDef(\resonator_pmono, {
arg sndBuf=0;
var freqs = (51 + ([3, 7, 12, 14, 15, 24, 26] +.x [0, 12])).midicps *.x [1, 1.008];
var sig, env, exc;
env = EnvGen.ar(Env([0,0,1,1,0], [0,\atk.kr(0.01),\sus.kr(1),\rel.kr(3)], [0,\c1.kr(1),0,\c2.kr(-1)]), \trig.tr);
exc = PlayBuf.ar(1, sndBuf, \rate.kr(1) * BufRateScale.ir(sndBuf), startPos: \spos.kr(0));
exc = exc * -50.dbamp * env;
exc = HPF.ar(exc, 100);
sig = Klank.ar(`[freqs, 1 ! freqs.size, BufDur.ir(sndBuf) ! freqs.size], exc, decayscale: \dec.kr(0.18));
sig = sig * \amp.kr(0.25);
Out.ar(\out.kr(0), sig);
}).add;
)
(
Pdef(\resonator_pmono,
Ppar({ |i|
Pmono(\resonator_pmono,
\dur, Pwhite(2.0, 3.0),
\timingOffset, i / 2 + 0.02,
\atk, Pwhite(0.1, 2.0),
\sus, Pwhite(0.5, 2.0),
\rel, Pexprand(2.0, 6.0),
\c1, Pexprand(1,8),
\c2, Pexprand(-8,-1),
\sndBuf, Pfunc { ~samples[\sawblade_long].choose },
\rate, Pwhite(0.95, 1.05),
\amp, Pexprand(0.08, 0.18),
\spos, Pwhite(0, 10000),
\dec, Pexprand(0.08, 0.18),
\amp, 0.15,
\out, i.wrap(0,1),
)
} !15 )
).play;
)
Pdef(\resonator_pmono).stop;