How do I integrate with a DAW? (Saving/loading patches, allowing knob modulation, prameters, etc)

#1

I’ve got an audio plugin I’m pretty happy with. The knobs work, the sound is pretty, etc. Now it’s time to make it actually useful in a studio setting. I have to integrate with the DAW.

As far as I can tell, all I have to do is make sure to add all my parameters to AudioPlugin (https://docs.juce.com/master/classAudioProcessor.html#ae686ddf13e3e8f6008cb7b4c41704aba)

But before I barrel in, I was wondering if anybody has advice on the subject?

0 Likes

#2

I don’t have as much Juce experience as some of the forum regulars, but for what it’s worth I use the AudioProcessorValueTreeState class for managing parameters, then connect them to sliders (knobs) with APVTS’s SliderAttachment class. That way, your sliders automagically change whenever your parameters change and vice versa.

For saving and restoring plugin state, you would use your AudioProcessor's getStateInformation and setStateInformation methods. Those methods are called whenever the host DAW wants to save or restore state, and it’s straightforward to convert your APVTS (i.e. your parameters) to XML when passing them to the DAW, and vice versa when going in the other direction.

There is a tutorial that covers all of these concepts: https://docs.juce.com/master/tutorial_audio_processor_value_tree_state.html

You can use the same XML<->state principal for saving and restoring presets. Here are the methods from one of my plugins, stripped down to the essentials:

bool MyAudioProcessor::savePreset(String filePath)
{
    // Convert the state ValueTree to XML
    auto stateCopy = apvts.copyState();
    std::unique_ptr<XmlElement> xml (stateCopy.createXml());

    if (!xml->writeToFile(filePath, "", "UTF-8", 60)) {
        return false;
    }

    return true;
}

bool MyAudioProcessor::loadPreset(String filePath)
{
    // Load preset XML file
    File presetFile = File (filePath);
    ScopedPointer<XmlElement> xml (XmlDocument::parse (presetFile));

    if (!presetFile.existsAsFile() || xml == nullptr) {
        return false;
    }

    // Replace current state with loaded state.
    apvts.replaceState (ValueTree::fromXml (*xml));

    return true;
}

You just need to pass the path of the file you want to save/load to the appropriate method.

1 Like