The way MIDI is being handled in the processor isn't ideal. The main issue is that there are allocations and locks in the processBlock method.
The incoming MIDI is looped over and added to an Array<juce::MidiMessage>. This is unlikely to cause much of a performance hit as the MIDI in events are likely sporadic / quite few in number per block (of course this isn't necessarily the case!). However, this data structure is inconsistent with how the output midi data is stored (juce::MidiBuffer) and specific storage classes exist for MIDI data which should be utilised
The outcoming MIDI is stored in a juce::MidiBuffer which is unfortunately accessed by both the audio thread and the message / GUI thread. I was forced to temporarily put a lock for access to the buffer in place to prevent exceptions and bad memory accesses. I haven't noticed any slowdown, but a better approach should be found.
In both cases an abstract fifo could be used (this is whats done in MidiLoggerPluginDemo.h, see the MidiQueue class). From what I've read online that is a viable approach, though I need to read a bit more in depth about how the FIFO is thread safe.
The way MIDI is being handled in the processor isn't ideal. The main issue is that there are allocations and locks in the processBlock method.
Array<juce::MidiMessage>
. This is unlikely to cause much of a performance hit as the MIDI in events are likely sporadic / quite few in number per block (of course this isn't necessarily the case!). However, this data structure is inconsistent with how the output midi data is stored (juce::MidiBuffer
) and specific storage classes exist for MIDI data which should be utilisedjuce::MidiBuffer
which is unfortunately accessed by both the audio thread and the message / GUI thread. I was forced to temporarily put a lock for access to the buffer in place to prevent exceptions and bad memory accesses. I haven't noticed any slowdown, but a better approach should be found.In both cases an abstract fifo could be used (this is whats done in
MidiLoggerPluginDemo.h
, see theMidiQueue
class). From what I've read online that is a viable approach, though I need to read a bit more in depth about how the FIFO is thread safe.