Storing a lot of values


Hi all,
for my plugin I need to be able to save and recall 14 sets of 120 boolean values.
My first thought was to put it into a parameter and into the valuetree, however it appears that it’s only possible to store a NormalisableRange as a parameter

Any ideas on how to keep this simple?

Thanks a lot


The question is, do you want to be able to automate these parameters from the host?
If not, you can simply save them in the ValueTree state, which is a public member of AudioProcessorValueTreeState. Also BigInteger is something to look into (although, you have to serialise it manually into a var).


Ah I don’t need to automate them.

Could you give an example on how to store an array in the ValueTree state?

Thanks Daniel,


Sure, quite simple: just use the BigInteger::toString() and parseString(). The benefit of using BigInteger over an Array or vector of bool values is, that you have all the bool operations available, if you want to join different sets.

// member: BigInteger mySwitches;
void MyAudioProcessor::getStateInformation (MemoryBlock& destData)
    auto switchNode = state.state.getOrCreateChildWithName ("MySwitches", nullptr);
    switchNode.setProperty ("values", mySwitches.toString (16), nullptr);

    MemoryOutputStream stream(destData, false);
    state.state.writeToStream (stream);

void MyAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
    ValueTree tree = ValueTree::readFromData (data, size_t (sizeInBytes));
    if (tree.isValid()) {
        state.state = tree;

        auto switchNode = state.state.getChildWithName ("MySwitches");
        if (switchNode.isValid() && switchNode.hasProperty ("values"))
            mySwitches.parseString (switchNode.getProperty ("values"), 16);
            // notify the GUI if necessary, e.g. ChangeBroadcaster

Hope that helps