1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

MIDI: Allow MidiMessageCollector to preallocate storage

This commit is contained in:
reuk 2020-06-01 10:25:13 +01:00
parent f7ccdd54bb
commit 9dc6e687c1
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
2 changed files with 13 additions and 0 deletions

View file

@ -128,6 +128,11 @@ void MidiMessageCollector::removeNextBlockOfMessages (MidiBuffer& destBuffer,
}
}
void MidiMessageCollector::ensureStorageAllocated (size_t bytes)
{
incomingMessages.ensureSize (bytes);
}
//==============================================================================
void MidiMessageCollector::handleNoteOn (MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity)
{

View file

@ -80,6 +80,14 @@ public:
*/
void removeNextBlockOfMessages (MidiBuffer& destBuffer, int numSamples);
/** Preallocates storage for collected messages.
This can be called before audio processing begins to ensure that there
is sufficient space for the expected MIDI messages, in order to avoid
allocations within the audio callback.
*/
void ensureStorageAllocated (size_t bytes);
//==============================================================================
/** @internal */