MidiBuffer memory allocation

midi

#1

I’ve noticed that the MidiBuffer passed to AudioProcessor::processBlock as argument has pre-allocated memory in some of the plug-in audio formats (VST, AU) but it doesn’t in others (VST3, AAX, AUv3). This is a concern when output midi messages are added to the midi buffer during dsp processing in the audio thread in the latter formats. Would it be possible to add a similar call to MidiBuffer::ensureSize during initialisation in the formats that are currently missing it so that memory allocation is avoided in the audio thread? Or is there a reason why this hasn’t been done in those formats, and if so what’s the best way of avoiding this memory allocation in the audio thread?

I’m using the latest version of JUCE in develop.


#2

OK. I’ve pushed this to develop with commit cfb071d. It should be available on the public git repo shortly.

Thanks!


#3

Thank you!


#4

How about using user-modifiable constants instead of hard coded values? So that MIDI-heavy processors may allocate more, just in case.

I’ve seen some magic numbers elsewhere in JUCE source code, it would be nice to be able to modify them in AppConfig.h or other relevant file. We’d rather not modify the juce source code directly.