Hi. I’m sort of creating a MIDI Interface class so the AudioProcessor class stays untouched. I have created my own MIDI scheduling system, but I don’t to add too many methods in the main processor class. Want to use an abstraction so I might reuse it easily for other projects.
I’m programming MIDI only plugins, no audio. I wonder if there’s any risk in passing a reference to the MIDIBuffer and Playhead to this new class.
I know there’s a warning in AudioPlayHead::getCurrentPosition that is only has context within processorBlock(). But it will be instantly passed by reference to the MIDI interface class so I can set some variables based in its content (BPM, PPQ, etc).
The same with MidiBuffer. My idea is to manipulate a copy of the MidiBuffer and exchange received midiBuffer with the edited MidiBuffer (with swap).
After some initial tests, i could see no problem whatsoever, but I ask if I might be overlooking something. My Midi processing is light enough to fit 100s of times in a single block.
Not sure exactly what you mean. Passing a reference to the playHead or the midi buffer is OK if you will be calling the MIDI interface class’ methods which use these references from within the processBlock function. If not, then simply copy out the data you need.
MIDI_PROCESSING( midiMessages , myCurrentPosInfo , buffer.getNumSamples() );
// ready to exchange with the modified/edited version
midiMessages.swapWith( MI_MidiBuffer ); // Mi_MidiBuffer created in MIDI_PROCESSING method.
}
[/CODE]
My AudioProcessor inherits from MIDI_Interface class
class MiditemplateAudioProcessor : public AudioProcessor,
public MIDI_Interface