So I’ve instantiated a waveform viewer class inside my editor which, for obvious reasons is necessary to paint and place the object in the editor. The class itself also has functions which require access to the processor’s buffer so that it can display the correct waveform in the buffer to the editor. I’m just wondering how you would go about this? I’ll post some code for reference.
editor.h
class Ring_modulatorAudioProcessorEditor : public AudioProcessorEditor, public Slider::Listener, public ComboBox::Listener
{
public:
Ring_modulatorAudioProcessorEditor (Ring_modulatorAudioProcessor&);
~Ring_modulatorAudioProcessorEditor();
//==============================================================================
void paint (Graphics& g) override;
void resized() override;
void sliderValueChanged (Slider* slider) override;
void comboBoxChanged(juce::ComboBox* comboBox) override;
Component* getComponent() { return this; };
std::unique_ptr<KrotosWaveformViewer> m_waveformViewer; //instantiated waveViewer class as pointer
private:
I am having the same problem in the same place.
getActiveEditor()->
Even with this, I can only call methods within the processor editor type and not the original custom class.
There are plenty of ways to get the processor from the editor,
I too would like to know the opposite.
Though be aware that you should avoid that at all cost.
There is no guarantee that getActiveEditor() is the one and only editor. The API allows multiple editors
There is no guarantee that the editor is not being deleted while you are working on it (unless you use the MessageManager and/or a MessageManagerLock)
The better design is to store what needs to be processed in the processor and only let the editor look at it.
If you need to signal the editor, you can use ChangeBroadcaster and ChangeListener.
Yes, I am using locks on the audio thread which is a no-no, but in this case I really know they will only be held for a short time and only perform simple copy operations.