First of all I have to admit I’m quite new to this so it’s most likely I’m doing something wrong here
When instantiating an AudioBuffer it seems like it allocates memory already in a way it is correctly aligned to use with PFFFT (16 byte boundary). At least PFFFT is not throwing an error when using it. Am I just lucky?
However I also need a vector of AudioBuffers which I create like this in my class:
std::vector< AudioBuffer<float> > m_FFTBuffer;
Then in my construcor I use this in my member initialisation list:
Now PFFFT throws an error because the allocated memory is not aligned. Is there an easy way to fix this? Or do I need to push_back AudioBuffers using preallocated memory in my constructor?
Thanks!
p.s. I could also copy it to a single preallocated AudioBuffer before feeding PFFFT, then copy it back - but that doesn’t feel right. What about performance when using AudioBuffer::copyFrom a lot in the processBlock?
Ouch! Don’t put AudioBuffer<float> in a std::vector. It’s not easy to predict what std::vector will do: it can copy, delete, swap and move around the buffers as desired. std::vector should only be used for types which are “easily” copyable. Consider using an OwnedArray instead.
Oh, am I? I thought by using vector<float*> myVector followed by myVector.reserve() I reserve a pointer for each channel? Anyway, vector doesn’t seem to be an option…