Hello all,
I am new to SC, and trying to build a polyrhythmic granular sampler. I feel like I have hit a conceptual wall and no number of tutorials or support documents is helping me get past it.
I am designing a sampler that uses at least two voice. I want the voices to synchronise and desynchronise using simple polyrhythmic ratios. e.g., voice 1 lasts 0.02ms and voice 2 lasts 0.03ms. However I also want these to be able to change according to a predefined sequence (or composition) and am trying to use patterns to achieve this. So for example voice 1 could change from 0.02ms to 0.04ms.
My first approach was to use BufRd.ar and have it controlled by Phasor.ar, allowing me to loop particular grains in the sample. The conceptual problem I hit with this is when I try to make changes to the length of the loop using Pbind it creates a new instance of Phasor, and I just start layering buffers on top of each other. Phasor obviously doesn’t have a doneAction, and this makes me feel that perhaps this is a misuse of this Ugen.
The second approach I have thought of it is not to loop at all but to use Line.ar instead, and use Pbind along with Pdup to create a rapid succession of Synthdefs. My concern is this somehow ‘feels’ wrong, and I wonder if it might create timing errors.
That leads me to my third design challenge which is when I have one voice functioning, how to make sure that it accurate synchronises with a second voice. The timing is essential in this design because both loops have to realign at 0 in their polyrhythmic cycles.
Here is a version of the code I have using the Phasor:
(
SynthDef.new (\voice, {
arg amp=1, out=0, buf, start, end, rate=1, dur;
var sig, ptr;
ptr = Phasor.ar(0, BufRateScale.kr(buf)*rate, start, end);
// ptr = Line.ar(0, end, dur, doneAction:2);
sig = BufRd.ar(2, buf, ptr);
sig = sig * amp;
Out.ar(out, sig);
}).add;
)
(
Pbind(
\instrument, \voice,
\buf, ~b0.bufnum,
\dur, Pseq([1, 1, 1, 1], 4),
\amp, 0.3,
\start, 0,
\end, Pseq([~b0.numFrames-1/32, ~b0.numFrames-1/64, ~b0.numFrames-1/128, ~b0.numFrames-1/246], 4),
\rate, 1).play;
);
Thank you in advance for any help, and thank you in general to the community who have created such an inspiring piece of software.
Dom