# AU Validation Failed - Retaining parameters' value

**URL:** <https://forum.juce.com/t/au-validation-failed-retaining-parameters-value/31967>\
**Category:** General JUCE discussion\
**Created:** [February 25, 2019, 2:02pm UTC](https://forum.juce.com/t/au-validation-failed-retaining-parameters-value/31967 "2019-02-25T14:02:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [February 25, 2019, 2:02pm UTC](https://forum.juce.com/t/au-validation-failed-retaining-parameters-value/31967/1 "2019-02-25T14:02:40Z")

</div>

My plug-in is failing AU Validation through auvaltool with the following error:

```auto
Testing that parameters retain value across reset and initialization
ParameterID=98116753, Scope=0, Element=0: Saved Value = 0.943359, Current Value 0.500000
ParameterID=98116759, Scope=0, Element=0: Saved Value = 0.900391, Current Value 0.500000
ERROR: Parameter did not retain set value when Initialized

* * FAIL

```

The parameters in question are gain parameters which pass the check a few lines above in auvaltool:

```auto
Parameter ID:98116753
Name: Filter 1 - Gain
Parameter Type: Generic
Values: Minimum = -27.00, Default = 0.00, Maximum = 27.0
Flags: Values Have Strings, High Resolution, Can Ramp, Readable, Writable 
  -parameter PASS

...

Parameter ID:98116759
Name: Filter 7 - Gain
Parameter Type: Generic
Values: Minimum = -27.00, Default = 0.00, Maximum = 27.0
Flags: Values Have Strings, High Resolution, Can Ramp, Readable, Writable 
  -parameter PASS

```

Only these two parameters are showing the error even though, as you can tell by their names, they are just 2 of 7 identical gain parameters.  
The parameters are created like so (in a for-loop):

```auto
auto gain = std::make_unique<ParamFloat>("gain" + String(i),
                                         groupName + " - Gain",
                                         NormalisableRange<float>(-globals::gainRange,
                                                                  globals::gainRange),
                                         0.f,
                                         String(),
                                         AudioProcessorParameter::genericParameter,
                                         [](float value, int) -> String
                                         {
                                             int dp = 2;

                                             if (value >= 10.f)
                                                 dp = 1;

                                             return String(value, dp);
                                         },
                                         [](const String& text) -> float
                                         {
                                             return text.getFloatValue();
                                         });

```

Then added to a group which is in turn added to the AudioProcessorValueTreeState using this method:

> [@New way of adding parameters to AudioProcessorValueTreeState not sufficient for many, identical parameters](https://forum.juce.com/t/new-way-of-adding-parameters-to-audioprocessorvaluetreestate-not-sufficient-for-many-identical-parameters/29887/5):
>
> Here’s one way of doing it: AudioProcessorValueTreeState::ParameterLayout createParameterLayout() { std::vector\<std::unique\_ptr\<AudioParameterInt\>\> params; for (int i = 1; i \< 9; ++i) params.push\_back (std::make\_unique\<AudioParameterInt\> (String (i), String (i), 0, i, 0)); return { params.begin(), params.end() }; } YourAudioProcessor() : parameters (\*this, &undoManager, "PARAMS", createParameterLayout())

The parameter values are set in the `setStateInformation()` in the usual way:

```auto
void PluginProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    std::unique_ptr<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));

    if (xml.get() != nullptr)
        if (xml->hasTagName(apvts.state.getType()))
            apvts.replaceState(ValueTree::fromXml(*xml));

    // ...
}

```

I’ve run auvaltool in debug and put a breakpoint in `setStateInformation()` but it doesn’t seem to be called during this test that’s failing!

Any help with this would be greatly appreciated, thanks!

---

<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:** [March 1, 2019, 9:34am UTC](https://forum.juce.com/t/au-validation-failed-retaining-parameters-value/31967/2 "2019-03-01T09:34:10Z")

</div>

> [@Im\_Jimmi](#):
>
> setStateInformation

What does your `getStateInformation` function look like?
