Thanks jamshark, I got confused as I thought the array wouldn’t all be stored in 0. I tried to return p.value[7] got nothing and assumed wrongly nothing was stored in there.
Im trying to take something like SinOcs and make a little array that imitates its output for something like amplitude in a pattern
Is there any way to shorten the numbers the array spits out?
Im getting this from a SinOsc
[0.0, 0.00014246479258873, 0.00028492958517745, 0.00042739437776618, 0.0005698591703549, 0.00071232399204746, 0.00085478869732469, 0.00099725346080959, 0.0011397181078792]
You can use the duration arg of loadToFloatArray to generate only the number of samples you need.
Remember also to de-interleave the array if you have multiple channels by .clump(numChannels).flop
(
s.waitForBoot{
var numSamples = 25; // number of samples you want
var cond = CondVar(); // used to wait for the function to generate samples
var numChannels = 3; // for multichannel output
var outArray; // the array to store your output
{
SinOsc.ar(2000 * (1..numChannels)) // 3 channels of signal
}.loadToFloatArray(
duration: numSamples / s.sampleRate, // just generatea as much as you need
action: { |array|
outArray = array.clump(numChannels).flop; // de-interleave the channels
cond.signalOne;
}
);
cond.wait; // wait for the function to generate the output
// do something with the array
outArray.plot;
}
)