Let the processor know when the Editor is closed


Hi, as the title says i want to know what is the best way to let the processor know when the Editor window is open or closed, i’m trying to implement the meter in the InterAppAudioEffect Demo of Juce in my Vst, but the demo work only in standalone and crash in the vst because appearently in the processBlock pass constantly infos to the Editor but if the window close it crash, so i created a Bool parameter that in the constructor set true:


and in the deconstructor set false:


then in the processBlock check for that parameter and pass the infos to the editor only when the parameter is true, it work good and the meter work fine opening and closing the window, but when i close Studio One, after it’s closed give the message that the application closed unexpectedly so, technically doesn’t harm the functionality because crash only when you are closing the DAW, but it’s pretty ugly, so i want to know, if it is something related to Studio One or what i’m doing is wrong and i should use a different way to check if the editor is open or closed? As a separated topic i would also to know if that Juce Demo is the best resource to implement a meter or there are better ones that im missing.
Thx in Advance :slight_smile:


As a general rule of thumb the processor should not “know” about the editor, since the editor lifecycle is more variable than the processor.
A hint to this is thatin the juce Audio plugin initial code the editor has a “ getprocessor” but the processor does not have a “geteditor”.

Hint1 : make the editor extend the timer class and on the timer callback call “getprocessor().yourGetUpdatedData()” method.

Hint2: make the processor extend the changebroadcaster class, and the editor a changelistener. register the editor @constructor and deregister @destructor.


That general rule doesn’t mean that there aren’t valid reasons for knowing if the Editor exists… a simple example is a “Recall Dialog” which gets shown when you instantiate a plug-in and setStateInformation() needs to check if the Editor exists so it can send it a message to display the “Dialog”.

Check out AudioProcessor::getActiveEditor()

As to notifying the processor that the Editor is being destroyed… if you need to do that, your Editor has a pointer to the processor which you can use in the Editor’s destructor.



Thx for the answers guys, considering that setting processor.windowOnOffParam->operator=(true) or false in the destructor work and crash only when the DAW is closing i had the suspect that when the DAW closes at a certain point close the editor of the plugin without activate his deconstructor, so the processor make the crash in that instant before everything closes, but this is just a suspect that i have, need to do couple of more tests to confirm, now i will try to play a bit with your solutions and will post if i can make it working, thx for the support


A little theory, have a look at the observer-pattern. Basically the best way is to have an atomic float that you keep up to date from the process block, and from the editor using a timer read that value and display it.

I implemented this in my ff_meters module. You can use it or get inspiration from it. It calculates RMS and Max values in the LevelMeterSource - measureBlock, that are used to display in the LevelMeter component.

Access a member function of the AudioProcessorEditor class via the AudioProcessor class

Thank you so much daniel, i was able to fix the crash using the timer, but still struggling to pass the values correctly and with multi instances does not calculate it right, so i will give a look to yours to undestand better, very appreciated, i will update the post as soon as i successfully get it, thx for all your support guys @daniel @Rail_Jon_Rogut @fefanto i really appreciate your effort.


@daniel got it working, now i check a bit all the features and play a bit with it, i think i found a bug in case you want to give a look, in Studio One if i switch from stereo to mono and viceversa the graphic repaint and glitch, except this seems working great, thx again :slight_smile: