Hello all, I am very new to Juce and I am still learning. But I am working towards making a basic oscilloscope plugin as a bit of an exercise. So my initial thoughts are along the lines of, theres some shared data that the Processor needs to populate with sample information, and then the Editor needs to know when to get that shared data and update the display.
So taking all the shared data aspect out of it for the time being to keep this as simple as it can get, I have come across the ChangeBroadcaster / ChangeListener classes in examples and I have attempted to use them. But I am obviously not doing something correctly because I get read access violations.
There isn’t really much code to show, because I basically just started a new project to test this and really focus things down. But this is what I have done:-
- I have created a new plugin project.
- The Processor inherits ‘public juce::ChangeBroadcaster’. The Editor inherits ‘public juce::ChangeListener’.
- In the ‘createEditor()’ method of the Processor i have addChangeListener(editor) before returning the editor.
- In the Editor I have implemented the changeListenerCallback override which just prints a debug message.
- In the process block I am calling ‘sendChangeMessage()’ (which seems to be the culprit).
So theres no compiler errors. But when I launch in the host, I get odd behaviour. It sometimes works fine at first and the editor displays and I see my debug message printing. However when I close the editor I get a read access violation. And other times it will just crash on launch with the same problem.
Now… When the editor closes I think that it could be still registered as a listener perhaps? But this raises more questions. For example, how would the processor know when its associated editor has closed? I have tried getting the active editor and using that, but this doesn’t really solve the problem.
Am I doing something fundamentally wrong? Is there something I am not doing that has eluded me? I have looked around for answers but because some examples are from older versions of juce, I feel I have gone round in some circles. Perhaps someone with experience can lend me some pointers in the right direction?