fsh::stk
fantastic spatial holophonic synthesis toolkit
Loading...
Searching...
No Matches
fsh::plugin::StateManager Class Reference

Base class for storing plugin state. More...

#include <StateManager.h>

Inheritance diagram for fsh::plugin::StateManager:

Public Types

using SliderAttachment = juce::AudioProcessorValueTreeState::SliderAttachment
 Helper alias for juce::AudioProcessorValueTreeState::SliderAttachment.
 
using ButtonAttachment = juce::AudioProcessorValueTreeState::ButtonAttachment
 Helper alias for juce::AudioProcessorValueTreeState::SliderAttachment.
 
using Params = juce::AudioProcessorValueTreeState::ParameterLayout
 Helper alias for juce::AudioProcessorValueTreeState::ParameterLayout.
 

Public Member Functions

 StateManager (juce::AudioProcessor &parent, Params &&params)
 Construct a PluginStateBase object.
 
auto getState () -> juce::XmlElement
 Called by the PluginBase class to save the plugin state.
 
void setState (const juce::XmlElement &xml)
 Called by the PluginBase class to restore the plugin state.
 
auto getReferenceToBaseClass () -> juce::AudioProcessorValueTreeState &
 Can be used by GUI objects, e.g.
 

Protected Member Functions

template<typename T >
auto getParameter (const juce::ParameterID &id) const -> T
 Get a parameter by its ID string.
 

Detailed Description

Base class for storing plugin state.

This class is a wrapper around juce::AudioProcessorValueTreeState. Every plugin should implement its own PluginState class that inherits from this class. This PluginState class is responsible for storing, saving, recalling, and communicating state to/from the DAW. You can then add parameters to the PluginState class by passing in an initializer list of fsh::FloatParam and fsh::ChoiceParam objects. Preferably these can be returned from a helper function inside an anonymous namespace, in the PluginState class's .cpp file.

Constructor & Destructor Documentation

◆ StateManager()

StateManager::StateManager ( juce::AudioProcessor & parent,
Params && params )

Construct a PluginStateBase object.

Parameters
parentThe plugin that owns this PluginStateBase object.
paramsA list of plugin parameters

Member Function Documentation

◆ getParameter()

template<typename T >
auto fsh::plugin::StateManager::getParameter ( const juce::ParameterID & id) const -> T
inlineprotected

Get a parameter by its ID string.

This is a wrapper around juce::AudioProcessorValueTreeState::getRawParameterValue(), but with a nullptr check. If you try to get a parameter that doesn't exist, this function will fail gracefully by returning 0.0f and logging an error.

◆ getReferenceToBaseClass()

auto StateManager::getReferenceToBaseClass ( ) -> juce::AudioProcessorValueTreeState&

Can be used by GUI objects, e.g.

to create SliderAttachments. See the Knob class, or the JUCE documentation for more info. This should be used sparingly. In most cases you probably want to use getRawParamSafely() from within your derived class.


The documentation for this class was generated from the following files: