I just did the midi demo, so I’m new to this side of juce. I was thinking it would be nice to have a display of the results of the midi processing there in the plugin editor. Surprisingly, I found no 64-bit vst midi monitor vst anywhere online…
But it’s not clear how to send data to the editor from the process block method. I did a search here, and it seems that for very good reasons the processor should know nothing about the editor. So what is the approved way to approach something like this? Seemed easy, but maybe not.
They way I’d do this depends on how much information you want to send, but when we have lots of info in process block we want to get to the editor (e.g. a stream of audio to display on a graph) we use a FIFO. (See AbstractFIFO) and the processor puts stuff in the queue not worrying about whether the editor is there or not, the editor subscribes to the FIFO and pulls stuff from it.
You could set up a FIFO containing a copy of the midi data.
If it’s just a value, like a current meter reading, maybe a std::atomic that the editor reads on a timer.
There ought to be a whole book on this topic somewhere in a thread on this forum, but I can’t find it right now!!
As my comment says… don’t expect the returned pointer to always be valid… but it works if you check the returned value isn’t nullptr and use it to do something simple.
For my MIDI Logging I actually keep a pointer to the logging window and update the data from my processor’s processBlock():
if (isEditorActive())
{
if (m_pMidiMonitor != nullptr)
m_pMidiMonitor->copyMidiBuffer (midiMessages, iNumSamples);
}
m_pMidiMonitor is set to nullptr if the Editor is destroyed and set to a valid value when the Editor is created. The logging is handled in it’s own thread.
I prefer to not push data from the processblock directly to the gui. I let the gui pull data that is updated in the processblock using for example fifo’s.
I prefer to not push data from the processblock directly to the gui. I let the gui pull data that is updated in the processblock using for example fifo’s
That makes sense to me. I’m going to go read up on fifo’s…
Should I just create my own timer, or is there one associated with updating the gui already?
Should I just create my own timer, or is there one associated with updating the gui already?
Answering my question, looks like there are more tutorials than I knew about. Odd that they do not show up in the list of links at the bottom of the one I just did… The audio parameter tutorial deals with updating the gui from a timer, just in case this helps someone else, (and so no one feels obliged to point me to it.)