Handling Midi in an AudioApplication


#1

Hey guys!

I am creating a standalone audio application (similar to the Dashboard for Blocks). It should communicate with DAWs and other software over virtual Midi or similar. There are great tutorials for sending Midi in/out of plug-ins but unfortunately not for stand alone applications.

My approach so far has been to place MidiMessages in a MidiBuffer and send them out periodically by use of the Timer class. I guess I need something like the processBlock callback method in the AudioProcessor class so I can send Midi messages on the audio thread.

Using a Timer class callback is in any case not the best approach (not even thread safe if I understand the implementation correctly). So I come to thee, oh JUCE programmer superiori, for guidance and help.


#2

It depends whether you need the midi events to be accurately timed… If not, then Timers are fine.

If you’re playing actual musical midi data then you’ll probably want to use MidiOutput::sendBlockOfMessages to time them correctly, or use your own high-priority thread that calls sendMessageNow at the correct time.