Best practice: Audio Thread, Arrays and allocating

Hi all,

I need to do some loudness logging on the processBlock()/audio thread. At the moment I’m adding a new value every 100ms to a std::vector or a std::map<int64, float>. For the map, the values are locked to the timeline position, updating the float if that position was already played back or adding new value if on virgin territory.
Additionally, I want to store/recall those values with get/setStateInformation (therefore also in the audio thread depending the host).
Knowing that allocating on the audio thread is a bad idea, I cannot predefine the size of my array/map in prepareToPlay() as I don’t know beforehand if the user will log a few seconds or an hour of values.
What would be the best approach to handle something like that.


Perhaps just a fifo that a background thread can read out of and do the resizing/allocating there. Though theres probably a better overall solution to the problem, depending if its realtime playback or analysing a set file.