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

**URL:** <https://forum.juce.com/t/access-a-member-function-of-the-audioprocessoreditor-class-via-the-audioprocessor-class/25080>\
**Category:** Audio Plugins\
**Created:** [November 9, 2017, 10:43pm UTC](https://forum.juce.com/t/access-a-member-function-of-the-audioprocessoreditor-class-via-the-audioprocessor-class/25080 "2017-11-09T22:43:55Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [November 16, 2017, 12:00pm UTC](https://forum.juce.com/t/access-a-member-function-of-the-audioprocessoreditor-class-via-the-audioprocessor-class/25080/15 "2017-11-16T12:00:14Z")

</div>

Also^3: If one thinks “I’m smarter that the machine, I use a smart pointer (aka WeakReference)”, it is still possible that the editor is just being destroyed while you are executing code there, because these are different threads.  
“Ok, but I can use a ReferenceCountedObject to make sure, it is only being deleted when I release my reference”, then you have to hack the AudioProcessor, as that one uses a normal ScopedPointer and will trigger the destruction regardless of your counted reference…  
It all leads nowhere and is not worth it…

Back to the topic: there is a simple level meter for a specific purpose in the AudioDeviceSelectorComponent. It is not meant to be used outside the Component, but you can see how they did it:

> <https://github.com/juce-framework/JUCE/blob/develop/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp#L50>

Also setting a link here to the thread from sondzark, and see my answer there:

> [@Let the processor know when the Editor is closed](https://forum.juce.com/t/let-the-processor-know-when-the-editor-is-closed/25096/5):
>
> A little theory, have a look at the [observer-pattern](https://en.wikipedia.org/wiki/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](https://github.com/ffAudio/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.

---

_[View the full topic](https://forum.juce.com/t/access-a-member-function-of-the-audioprocessoreditor-class-via-the-audioprocessor-class/25080)._
