ASPiK SDK
|
MIDI messages are sent to the PluginCore's buffer processing function as part of the normal The Buffer Processing Cycle and arrive in a queue, timestamped with the sample number corresponding to locations in the DAW I/O buffers. The PluginBase implements the processAudioBuffers method and fires MIDI events into the processing loop depending on your audio processing method. The midiEvent structure holds the information for each MIDI message and has many member variables; here I am only showing the normal message members and the sample-accurate index value:
Regardless of the processing paradigm, the same MIDI function is usd to process these messages and uses a simple midiEvent structure to store the message data:
Notice how this function works:
Processing sub-blocks or buffers:
The pluginDescriptor.processFrames boolean will be false; in this case a special function is called to load the incoming MIDI message into a vector that will be usually be serviced, all at once, at the top of the block processing function; note that you may also perform this in a sample accurate manner, but it will require some coding on your part to match up the midiEvent's midiSampleOffset index (the sample location within the DAW audio buffers) with the block or buffer (for buffer processing this is trivial as the sample offsets will match up with your for( ) loop), but for sub-block processing, you will need to keep track of the blocks and samples per buffer (see the preProcessAudioBuffers function for a location to set this up). However, there are good reasons for procssing the MIDI at the top of sub-blocks as detailed in my Synth book (and many synth manufacturers use this same paradigm).
Processing Frames:
You insert your MIDI processing function (e.g. myMIDIMessageHandler( )) right inside of the processMIDIMessage( ) call here; the PluginBase will interleave the MIDI message function calls with the processAudioFrames function calls and your MIDI messaging is automatically sample accurate!