Externally notifying AudioProcessorValueTreeState of a parameter change

Hi there!

I’m working on a plugin whose core algorithm is mainly implemented in C, and I’ve run into an issue when the C code changes a value in the algorithm, thereby bypassing my AudioProcessorValueTreeState which results in no GUI update. This is because the C algorithm doesn’t read the JUCE values directly, instead JUCE is responsible for keeping the items in the C code updated.

I’m wondering if there’s any functionality that would allow me to notify the ValueTreeState object directly when a value has changed? I’ve been digging through the source code to try and find out how I’d do this, but it seems like most of that functionality is private. I’m not really sure how to go about this without some kind of circular dependance, because the ValueTreeState also updates the C parameters whenever it detects an update.

Ideally, I’m looking to create a method to modify a value in an AudioProcessorValueTreeState, have the ValueTreeState update its Attachments/Listeners but ignore one specific Listener. I know this is a silly ask, but given my predicament with the C code I’m curious about what the best way to go about it would be. I’m happy to expound on the specifics of my code, but at current I feel like it’d only complicate my question.

Thank you!

*EDIT*: Just after posting this I realized that the internal ValueTree of an AudioProcessorValueTreeState is a public member. Would ValueTree::setPropertyExcludingListener() be the proper way to go about this?

I’m looking to create a method to modify a value in an AudioProcessorValueTreeState, have the ValueTreeState update its Attachments/Listeners but ignore one specific Listener

Would ValueTree::setPropertyExcludingListener() be the proper way to go about this?

From how you’ve described the problem, yes.

Thank you! I do have one question though—from what I can tell, it’s the job of the AudioProcessorValueTreeState::ParameterAdapter private subclass to notify SliderAttachments. Wouldn’t that mean that ValueTree::setPropertyExcludingListener() wouldn’t apply to the SliderAttachments? From what I can discern, the only listener of the internal ValueTree is the AudioProcessorValueTreeState, but I could easily be misinterpreting the source.

AudioProcessorValueTreeState is a listener of the ValueTree and updates the attachments in response to changes in the ValueTree.

I’m not really sure how to go about this without some kind of circular dependance, because the ValueTreeState also updates the C parameters whenever it detects an update.

Rather than trying to exclude listeners can you instead call setValueNotifyingHost on the corresponding parameter, but only when the value has actually changed?