# Attach value to AudioProcessorValueTree

**URL:** <https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644>\
**Category:** Audio Plugins\
**Created:** [April 2, 2019, 9:09pm UTC](https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644 "2019-04-02T21:09:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [April 2, 2019, 9:09pm UTC](https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644/1 "2019-04-02T21:09:41Z")

</div>

I managed to attach all my Sliders, Buttons and Comboboxes via the -Attachement classes but am puzzled with the other components.

I can attach a Listener, but from what I understand the Listener listens to the AudioProcessorValueTree and not the other way around?

---

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [April 2, 2019, 10:52pm UTC](https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644/2 "2019-04-02T22:52:08Z")

</div>

I marked this solved earlier, because I thought I had it figured out when I didn’t.

My approach so far is:  
call `AudioProcessorValueTree::state::setProperty()`, however the property doesn’t seem to change, am I missing something or is this the wrong approach overall?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [April 4, 2019, 9:42am UTC](https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644/3 "2019-04-04T09:42:58Z")

</div>

Can you provide some example code showing us exactly what you’re doing?

---

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [April 6, 2019, 1:15pm UTC](https://forum.juce.com/t/attach-value-to-audioprocessorvaluetree/32644/4 "2019-04-06T13:15:52Z")

</div>

I was trying to find a way to connect any parameter that is not a Slider/Button/Combobox to the ValueTree. I found a solution like this:

1. Give your component a reference to your AudioProcessorValueTreeState `m_value_tree`
2. Every time the value changes call

`m_value_tree.getParameter(my_variable_identifier)->setValueNotifyingHost(new_value);`

I don’t know if this is the indended way, but it seems to work. (note that new\_value needs to be scaled to 0…1 )
