# How to use AudioProcessorValueTreeState's SliderAttachment?

**URL:** https://forum.juce.com/t/how-to-use-audioprocessorvaluetreestates-sliderattachment/17720
**Category:** Audio Plugins
**Created:** [May 16, 2016, 6:48am UTC](https://forum.juce.com/t/how-to-use-audioprocessorvaluetreestates-sliderattachment/17720 "2016-05-16T06:48:44Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![mashu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mashu/32/579_2.png) [@mashu](https://forum.juce.com/u/mashu)
#### Post date: [May 16, 2016, 7:41am UTC](https://forum.juce.com/t/how-to-use-audioprocessorvaluetreestates-sliderattachment/17720/5 "2016-05-16T07:41:59Z")

</div>

this is my first time trying to use any of the audioProcessorParameter classes, so obviously i’m doing something really wrong here. Here’s what i have so far:  
(and sorry, it’s a button i’m trying to connect at the moment, not a slider)

in my PluginProcessor.h, as a public variable:

```
AudioProcessorValueTreeState mainValueTree;

```

and then here are the first lines of my PluginProcessor’s constructor:

```
PluginProcessor::PluginProcessor()
: mainValueTree (*this, nullptr)

{
    mainValueTree.state = ValueTree ("mainValueTree");

    NormalisableRange<float> buttonRange (0, 1, 1);
    mainValueTree.createAndAddParameter ("clockForwards", "ClockForwards", "clock forwards", buttonRange, 0, nullptr, nullptr);

```

and then in my GUIcomponent.h

```
AudioProcessorValueTreeState::ButtonAttachment* clockForwardsButtonAttachment;

```

and then finally, in the constructor of my GUIcomponent.cpp, after the clockForwards button is added, i have:

`clockForwardsButtonAttachment = new AudioProcessorValueTreeState::ButtonAttachment (p.mainValueTree, "clockForwards", *clockForwards);`

this doesn’t work, and gives me a seg fault. Obviously i’m doing it wrong, but quite in the dark here how to do it right.

(btw: clockFowards is just an ordinary text button, created with the projucer)

---

_[View the full topic](https://forum.juce.com/t/how-to-use-audioprocessorvaluetreestates-sliderattachment/17720)._
