Is it possible to connect a slider to a simple value/property of a ValueTree?

I would like to connect a slider to a Value Tree property. The property is not a AudioProcessorValueTreeState::Parameter, so I guess, that i can not use the AudioProcessorValueTreeState::SliderAttachment. Is there a similar approach to connect Tree properties to a slider?

Could you clarify what you mean by property? As far as I understand the Listeners only get notified when the ValueTreeState changes.
There is no property in the value tree as far as I can tell.

Edit: Sorry, this is what an example tree looks like:

<ParameterGroups>
  <Group name="Tone Controls">
    <Parameter id="distortion" value="0.5"/>
    <Parameter id="reverb" value="0.5"/>
  </Group>
  <Group name="Other Controls">
    <Parameter id="drywet" value="0.5"/>
    <Parameter id="gain" value="0.5"/>
  </Group>
</ParameterGroups>

What do you want to connect to?

something like this should work (written just from memory, hope it helps)

    Value valueToControl; 

    valueToControl=valueTree.getPropertyAsValue("name", nullptr);
    slider.getValueObject().referTo (valueToControl);

PS: once you reassign the ValueTree with another ValueTree the connection will be broken.

3 Likes

Thank you, that was what I was looking for!

Thank you so much for this, I literally haven’t seen this anywhere in the documentation. JUCE is such a powerful tool but is held back by its lack of documentation.