Hi all,
I’m trying to play a FFT buffer at specific points.
I know precisely the tempo of the source audio file.
And I would like to compute the offset
value for playing the buffer from beat 2, 3, 4 …
The doc says that the offset is:
offset: An integer number of frames to offset into the playbuf file. Defaults to 0.0.
So my approach was to compute the number of frames for one beat and use that as a multiplier in a Pbind. But that’s not working and I don’t understand how to compute the right offset:
b=Buffer.readChannel(s,"some.wav",channels: [0]);
t=TempoClock(100/60).permanent_(true);
~fftsize = 16384; ~hop = 0.25; ~win = 1; // fft parameters
f = Buffer.alloc(s, b.duration.calcPVRecSize(~fftsize, ~hop)); // buffer allocation for the fft analysis
d=t.beatDur.calcPVRecSize(~fftsize, ~hop); // Number of frames for the duration of 1 beat
// a regular FFT Synth
(
SynthDef.new(\avdjm,{
var start=\start.ir(0), rate=\rate.ir(1), out=0;
var sig, chain, localbuf;
localbuf = { LocalBuf.new(~fftsize) };
chain = PV_PlayBuf(localbuf, f, offset: start, loop: 0);
sig = IFFT(chain, ~win);
sig = sig*EnvGate.new;
Out.ar(out,sig!2);
}).add;
)
// A PBind playing at every beat
(
Pdef(\sample,Pbind(
\instrument, \avdjm,
\start, Pseries(0,d,16).trace,
\dur, 1
));
)
Pdef(\sample).play
Pdef(\sample).stop
This approach works fine at start = 0, and stops working for start > 0.
So computed, d
, the offset I compute for 1 beat, equals 131075.0.
The system works for values of d ≈ 20. No idea why.
How could I compute a precise value for d
?
Thanks