How to update AudioProcessorEditor in real-time with data processed in AudioProcessor?

Hi JUCE masterminds,

Allow me to explain my core problem.

I’d like to create a VST plugin to read user’s midi inputs from DAW or an external device and display the inputs on plugin UI while playing. Currently I’m trying to implement some code inside AudioProcessor::processBlock method by translating every midiMessage in juce::MidiBuffer& midiMessages and calling a TextEditor object in getActiveEditor() to show the strings.

It occurred to me that this may have some thread conflict between audio and UI. Is there a recommend way to deal with real-time audio playback and UI update? Thanks a lot.

Liang

You need to safely pass the data between the two threads, without ‘blocking’ (pausing the real time thread).

One option is a non-blocking FIFO, whereby you can push MIDI bytes onto it from the process thread, and pull them off on the UI thread. The UI thread will need a Timer that periodically checks for fresh data in the FIFO.

MIDI Monitor