How can the juce host receive a start/stop command from a plugin, like Vienna Ensemble Pro?
AFAIK plugin formats don’t provide any way of sending transport control messages.
(The only exception I can think of is the ARA extension, but that’s only supported by a couple of hosts and a handful of plugins)
I don’t know about Vienna Ensemble Pro, but if it’s a midi plugin, especially a midi instrument, it could emit some MidiMachineControlCommands, although I might suspect these are primarily used by external, physical, midi instruments.
Cubase, ProTools, etc. all start and stop playback when the Start/Stop button is pressed in any of the Vienna plugins. So the plugin has to be sending something. I can’t figure out what.
If the plugin was sending MidiMachineControlCommands how would the demo host receive them?
I found this is the Vienna forum:
Transport Play/Stop button, which is transmitted to the master host as well (Space key). Now you can start and stop your playback from within Vienna Ensemble PRO!
So it sounds to me like they are saying the plugin is sending a Space Bar key press. Does this make sense?
OK, so I suppose it’s just a hack where the plugin sends a fake space bar keyboard message into the host application’s message queue? That probably would require some direct win32/Cocoa API use in a JUCE context…(I mean if you are trying to code a plugin which should implement this, but are you actually asking about hosting plugins…?)
I have tracked it down and sure enough the plugin sends a key press (space bar) to the operating system. Problem is I am getting two of them, one for key down and one for key up, I assume. It is easy enough to trap this, so thank you for your input.
Was this something you were able to do? Trying to do this myself right now. Thanks!
I trapped the key press in main window like this:
if (key == KeyPress::spaceKey) //This is here because Vienna sends two space bars that start and stop immediately
{ //so we allow a 100msec in between to make sure.
static int64 lastKeyPressTime = 0;
if ( Time::getCurrentTime().toMilliseconds() > lastKeyPressTime + 100 )
{
pControlBar->DoCommand (CMD_PLAY);
lastKeyPressTime = Time::getCurrentTime().toMilliseconds();
return true;
}
}
Hope this helps.
Thank you!! I am certain it will but I’m not quite there yet.
I’m just not sure how to simulate this keypress. I’d like to send ‘space’ on a button click.
I’d imagine something like…
button.onClick = [this]
{
postCommandMessage('spaceKey'); //...basically
};
I am still learning, sorry if this is obvious 
My pControlbar is the control bar that starts and stops playing.
Your app should have an object that does the same and just call that object to start/stop playback on click.
Hmm… Interesting. At first I need to make it work in plugin (not app as you mentioned). And in PluginEditor I can’t find such object as you mentioned. Probably I have it but it is implemented somewhere inside plugin type wrapper and it’s different for AU, VST3 etc. And I can’t find any direct access to such object.
So I still have no idea what exactly does pControlBar->DoCommand (CMD_PLAY);
Maybe could you tell what is exact pControlBar class type? Or could you paste here the constructor of pControlBar, and the code which is inside DoCommand? I would be very appretiate.
I can’t find anything like ControlBar nor DoCommand in Juce documentation.
For any help great thanks in advance.
Best Regards
implementing something as a plugin is encouraged even early on when you’re still developing the basic functionality. because then you can do stuff like returning false from hasEditor in the audioProcessor to find out if the GUI has anything to do with your issue. if an issue persists then you can disregard more than half of your project’s files in many cases, which is nice
