Hi!
I want to use a Playbuf in order to play a wavetable that I have created in a buffer.
When using just play; the Playbuf works as expected.
When I want to make it work with patters things do not go as expected…
this is the example code:
// 1) Create a table at buffer 10:
(
p=2.pow(11);
v=Signal.sineFill(p, 1.0/[1, 2, 3, 4, 5, 6]);
v.plot;
n=Buffer.alloc(s,p,1,bufnum:10);
n.loadCollection(v);
)
// 2)This plays normally…
(
SynthDef(\help_PlayBuf, {| out = 0,buf=10,trig=1000,dur |
trig=MouseX.kr(1,10000);
Out.ar(0,
PlayBuf.ar(1, buf, (2048/Server.default.sampleRate)*trig, Impulse.ar(trig), 0.0, 0)
)
}).play;
)
//3) when adding a pattern things behave differently…
(
SynthDef(\help_PlayBuf, {| out = 0,buf=10,trig=1,dur,envratePoll_Mult=1,sustain |
var env = EnvGen.ar(Env([1, 1, 0], [sustain, 0]), doneAction: 2);
Out.ar(out,
PlayBuf.ar(1, buf, (2048/Server.default.sampleRate)*trig, Impulse.ar(trig), 0.0, 0)*env
)
}).add;
)
(
Pdef(\f,
Pbind(
\instrument, \help_PlayBuf,
\trig, Pbrown(1,10000,100,inf)
\buf,10,
\dur, 1/(Pkey(\trig))
)
).play;
)
How could I use patterns to trigger the synth and make it play the table correctly like in the first example without patterns? I tried to use dur in order to free the Synth every time a trig hits… I pass the sustain in an env which releases the synth after each trigger. It seems that the wavetable is not played till the end but leaves a small gap in between each grain (is it scaling the table?). Why is this happening and how could I correct it? I think it has something to do with dur, sustain etc but I am not sure how to figure it out…
any help would be appreciated!
thank you people!!!