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.
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?
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.