Use AudioProcessorValuetreeState with multiple presets

#1

Hi JUCE team,

I currently have a design question.

I’m developing an audio standalone application with some effect processor.

I plan to use a classic approach: AudioTransportSource and then use a node to put my processorChain.

I will use a valueTree to communicate between the GUI and the audio engine (play/stop, track load, and so on…).

The effect parameters will be handle with an AudioProcessorValuetreeState.

BUT the user can selecte multiple presets. A preset store all the parameters state.
Hence everytime the user switch between the preset I will have to change the AudioProcessorValuetreeState values.

How could I handle it?

I thought about having my ValueTree designed like this:

{
  "root": {
	"trackPath1" : "~/tracks/track1.wav",
	"trackPath2" : "~/tracks/track2.wav",
    "preset": {
      "preset1" : {
        "compressor" : {
          "threshold" : "-4",
          "outputGain" : "+12"
          // other fields...
        },
        "limiter" : {
          // other fields
        }
      },
      "preset2" : {
        "compressor" : {
          "threshold" : "-8",
          "outputGain" : "+3"
          // other fields...
        },
        "limiter" : {
          // other fields
        }
      }
    }
  }
}

Then changing the value tree of the AudioProcessorValuetreeState according to the selected preset.

Something like this:

AudioProcessorValuetreeState.state = valueTree.getProperty("preset").getProperty("preset2");

I don’t know if it would be the best practice for this kind of issue.

What do you think about it?

0 Likes

#2

Assuming you have a ValueTree representing a particular preset, I’d recommend calling AudioProcessorValueTreeState::replaceState to update the parameters with their preset values. This should be preferred over assigning directly to the state data member.

0 Likes

#3

Thanks for your help.
Just to be clear I’ve a ValueTree which contains an array of preset.
I’m not used to work with it so I was wondering if it’s a common practice to store the values of the different presets

0 Likes