Showing MIDI activity in audio plugin GUI

I’m about 2 weeks in to developing with JUCE.
I’m trying to have a little MIDI activity lamp in my audio plugin GUI, I’ve got something working but only whilst the processBlock method is getting called, and in Cubase 8.5 after a few seconds of stopping playback it no longer passes audio to be processed (also prior to pressing play I can’t tell if MIDI is being sent to the plugin).
What am I missing here? Is there some other way to determine if MIDI being passed to the plugin other than in processBlock? I’m not actually interested in what the MIDI is, just that there is some.
Thanks in advance

Well, if processblock ain’t being called there ain’t no MIDI being passed to the plugin and hence nothing to detect…

In Cubase 8.5 it appears not (to me at least). I can see MIDI going into Cubase, it gets passed along to my plugin whilst audio is playing, when I stop playback after about 2 seconds ProcessBlock is not being called any longer, as soon as I press play my MIDI indicator flashes to pick up the queued messages. Of course this may just be a Cubase thing, but more likely is I’ve done something wrong :smiley:

I’m not really sure what you’re trying to achieve. To me the expected outcome when you stop playback is you stop receiveing midi (or audio). To me that’s the quintessence of a playback function, although I must confess I’m not overly familiar with Cubase.

Just trying to achieve a MIDI activity “LED” to show that MIDI is in fact being received (I got into music production mid-nineties with hardware when all these new fangled virtual instruments were a pipe dream, so it’s something I like to see! :rofl:)
It may well actually just be Cubase trying to not process audio when it doesn’t need to, because it works with the play head not moving for a couple of seconds then stops, which is kind of frustrating, because then it looks like no MIDI is reaching the plugin.
I suppose I should just drop this “feature” for now.

Did you try adding a DBG("midi message size: " + String(midiBuffer.getNumEvents()) ) message in the processBlock that measures the size of any incoming midi buffers? that’ll tell you if Midi is coming in or not.

I really am quite noob at this, how do I get to see the output of DBG in xcode?

After a bit more investigation I can say that processBlock is actually being called all the time in my plugin, but about 2-3 seconds after pressing stop in Cubase the MIDI messages end up sitting in a queue which then all arrive as soon as I hit play. :confused:

I will try see if I get the same behaviour from a test rig plugin.

View -> Debug Area -> Activate Console

OK, I had tried that and assumed something else might need doing. :confused:

Follow up in case someone else has a similar issue in future:

Cubase will send zero length blocks to processBlock after a few seconds of silence. So, if you had something like I did where you are looking for MIDI messages inside your main for loop over the AudioBuffer, code inside that loop won’t run when the number of samples to process is zero!