Hi,
I have a couple of questions concerning Buffer
(including VOsc
), which I’ve been using for years, but really don’t quite understand some of the finer points.
When working a soundfiles using Buffer.alloc
, I understand that numFrames
is easy to understand as you can set your numFrames
as s.sampleRate * x
, depending on the number of seconds needed.
However, when working with several envelopes (or whatever), building Signals (.asSignal
), and then loading into buffers using Buffer.allocConsecutive
, I see that numFrames is described as:
The number of frames to allocate in each buffer. Actual memory use will correspond to numFrames * numChannels.
How can we know what the number of Frames are?
Here’s a working example (of what I’m testing) built from tutorials and past stuff. It’s a bit basic (and probably not correct), but at least it can give someone a basis on which to explain and reply.
(
~sigArrays = 4.collect({
arg i;
i = i.linexp(0, 3, 4, 40).round(1);
Env(
{rrand(0.0, 1.0)}.dup(i),
{rrand(0.5, 1)}.dup(i),
{rand(-5, 5)}.dup(i)
).asSignal(512); // I've used 512, but why not 1, 2, 16, etc .. they're also pow2?
});
)
~sigArrays.plot;
// Same question for numFrames, how do I calculate my frames from the above Envs?
// I notice I can use any pow2 number in the Buffer,
// except very low figures just 'click' - too small I imagine.
// So how do I find the numFrames to use ( * numChannels is 'one' I see).
(
b = Buffer.allocConsecutive(4, s, 512*2, 1, {
arg buf, index;
buf.setnMsg(0, ~sigArrays[index].asWavetable);
});
)
(
a = { VOsc.ar(LFNoise1.kr(5).range(b.first.bufnum+0.1, b.last.bufnum-0.1),
LFNoise0.kr(10).range(120, 240), 0, 0.2) }.play;
)
b.free;
Oh, and a supplementary question about pow2 numbers. Why do the examples mostly use 512 (513), and above? As I understand, VOsc/Signal, etc, need pow2 numbers. But what’s wrong with smaller pow2 numbers (or much bigger numbers even, ex: 1.2676506002282e+30)
Thanks in advance - joesh