Here’s a question …
How can I resize a buffer that has been declared with …
AudioSampleBuffer::AudioSampleBuffer (float ** dataToReferTo, numChannels, numSamples)
… and still have a directly accessible data array to refer to?
If I do the standard:
recordedBuffer->setSize(2, recordedBuffer->getNumSamples() + 300000, true, true);
Then it no longer refers to the data it was initiated with … (from the docs) … “Note that if the buffer is resized or its number of channels is changed, it will re-allocate memory internally and copy the existing data to this new area, so it will then stop directly addressing this memory.”
I can do a realloc on the array …
recordedData = (float**)juce_realloc(myLoops[loopNumber].recordedData, sizeof(myLoops[loopNumber].recordedData) + sizeof(float)*300000);
But then the juce recordedBuffer doesn’t realize the data has been resized and it throws an error …
I tried adding this after the realloc …
recordedBuffer->setDataToReferTo((float**)recordedData, 2, sizeof(recordedData));
but that doesn’t do it either.
What am I missing here … I need to have directly addressable data for my buffer, but I also need it to be dynamically resizable. Surely this is possible?
Thanks,
A