Hi, I have few simple arrays (Array, Array<pointer*> and SortedSet) that my AudioProcessor::processBlock modifies adding or removing elements.
Since I discovered that Array class uses new keyword to add elements I worried about it.
Is safe adding/removing simple elements to/from Arrays inside AudioProcessor::processBlock()?
No, it’s definitely not safe! Adding the elements isn’t the problem (it uses placement new), but it’s the fact that when you add to an array, it may have to resize its internal buffers, which involves allocation.
Thank you. Could you suggest an alternative? Using basic c++ arrays? Preallocate juce::Array?
Well, you could prealllocate space, but it’s still a bit dodgy. You should watch some of Timur’s ADC and CPPCON talks about real-time audio coding to get a better idea of what’s involved.