AudioProcessorValueTreeState::Listener crashes [SOLVED]

I’m trying to update a component when the value is changed by the host, so I mad it a AudioProcessorValueTreeState::Listener (has a nice ring to it :D)

for (int i = 0; i < N_ROWS; ++i) {
    m_value_tree.addParameterListener("amount_1_[" + std::to_string(i) + "]", &(m_amount_1[i]));

But the plugin crashes when I change the param, which lets me to believe that the pointer is somehow invalid.

Now this is tricky to debug: I need a host able to change the parameter (so the JUCE host won’t cut it) and Bitwig-Studio doesn’t give me any output. Furthermore, I can’t check the pointer, because the call happens somewhere inside AudioProcessorValueTreeState.

Any idea what might be wrong?

some further research gave that the pointer to the component somehow changed between the constructor (where the listener is set) and operation - making it a void pointer.

I think I’ve dealt with a similar problem before, but then I hacked a way around it.
What could be causing the pointer to change in between?

Where are you adding the listener? Are you definitely removing the listener again, when the observer is deleted?

I’m adding the listener in the constructor of the Editor (rather a subcomponent, but its around the same time).

deleted? Will the editor be deleted before end of lifetime?

Ok yes this indeed was the problem… I’m still wondering though why the AudioPluginEditor will be deleted in between.

The editor isn’t guaranteed to exist for the duration of the AudioProcessor’s lifetime. For example, when you open the plugin window, the editor will be created, and when you close the plugin window, the editor will be destroyed, but the AudioProcessor will still exist. It’s important to make sure that your processor behaves properly, whether or not the editor exists.

ok that’s quite the information to swallow… Thanks for your help though! :slight_smile:

heads off to recode half a plugin

1 Like