hey, can someone tell me how i can implement BufRd
with playback rate and position rate control for granulation, similiar to GrainBuf
? I think its more straightforward with Playbuf
, but i would like to do this with BufRd
.
Phasor
should ramp from 0 to number of frames in the Buffer with a specific position rate, for every trigger
you multiply each grain with the hanning window driven by Sweep, the duration of each grain is the time Sweep
needs to go from 0 to 1 scaled by overlap (to overlap grains inside the SynthDef you would need to use collect and PulseDivider
here, i left it out for simplicity). I cant make sense of the combination of the modulus Phasor and the triggered Sweep atm and where to implement the posRate
and the playBackRate
when using BufRd
. thanks.
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
(
var hanningWindow = { |phase|
(1 - (phase * 2pi).cos) / 2 * (phase < 1);
};
SynthDef(\granular, { |sndBuf|
var tFreq = \tFreq.kr(10);
var trig = Impulse.ar(tFreq);
var phase = Sweep.ar(trig, tFreq);
var grainWindow = hanningWindow.(phase / \overlap.kr(1));
var pos = Phasor.ar(
trig: 0,
rate: \posRate.kr(1) * BufRateScale.kr(sndBuf) * SampleDur.ir / BufDur.kr(sndBuf),
start: \posLo.kr(0),
end: \posHi.kr(1)
);
var sig = PlayBuf.ar(
numChannels: 1,
bufnum: sndBuf,
rate: \playBackRate.kr(1),
trigger: trig,
startPos: pos * BufFrames.kr(sndBuf),
loop: 1
);
//var sig = BufRd.ar(1, sndBuf, pos * BufFrames.kr(sndBuf), loop: 1, interpolation: 4);
//var sig = BufRd.ar(1, sndBuf, phase * BufSampleRate.kr(sndBuf) + pos, loop: 1, interpolation: 4);
sig = sig * grainWindow * \amp.kr(-10.dbamp);
sig = Pan2.ar(sig, \pan.kr(0));
sig = LeakDC.ar(sig);
OffsetOut.ar(\out.kr(0), sig);
}).add;
)
Synth(\granular, [\sndBuf, b]);