The ParameterAttachment is a class you can use to have a value synchronised with an AudioProcessorParameter. More...
#include <foleys_ParameterAttachment.h>
Inherits Listener, and AsyncUpdater.
Public Member Functions | |
ParameterAttachment () | |
virtual | ~ParameterAttachment () override |
ValueType | getValue () const |
Thread safe way to read the current value. | |
ValueType | getNormalisedValue () const |
Thread safe way to read the normalised value of the current value. | |
void | setValue (ValueType newValue) |
Set the value from a not normalised range.min..range.max value. | |
void | setNormalisedValue (ValueType newValue) |
Set the value from a normalised 0..1 value. | |
void | attachToParameter (juce::RangedAudioParameter *parameterToUse) |
Make this value attached to the parameter with the supplied parameterID. | |
void | detachFromParameter () |
void | beginGesture () |
Make sure to call this before you send changes (e.g. | |
void | endGesture () |
Make sure to call this after finishing your changes (e.g. | |
void | parameterValueChanged (int parameterIndex, float newValue) override |
void | parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override |
void | handleAsyncUpdate () override |
Public Attributes | |
std::function< void()> | onParameterChanged |
Set this lambda to be called from whatever thread is updating the parameter. | |
std::function< void()> | onParameterChangedAsync |
Set this lambda to be called from the message thread via AsyncUpdater. | |
The ParameterAttachment is a class you can use to have a value synchronised with an AudioProcessorParameter.
It takes care of updating either way, keeps the value thread safe in an atomic and allows setting lambdas to be executed when the value changes.
ParameterAttachment | ( | ) |
|
overridevirtual |
References detachFromParameter().
ValueType getValue | ( | ) | const |
Thread safe way to read the current value.
ValueType getNormalisedValue | ( | ) | const |
Thread safe way to read the normalised value of the current value.
void setValue | ( | ValueType | newValue | ) |
Set the value from a not normalised range.min..range.max value.
References parameterValueChanged().
void setNormalisedValue | ( | ValueType | newValue | ) |
Set the value from a normalised 0..1 value.
References parameterValueChanged().
void attachToParameter | ( | juce::RangedAudioParameter * | parameterToUse | ) |
Make this value attached to the parameter with the supplied parameterID.
References detachFromParameter().
void detachFromParameter | ( | ) |
Referenced by attachToParameter(), and ~ParameterAttachment().
void beginGesture | ( | ) |
Make sure to call this before you send changes (e.g.
from mouseDown of your UI widget), otherwise the hosts automation will battle with your value changes.
void endGesture | ( | ) |
Make sure to call this after finishing your changes (e.g.
from mouseDown of your UI widget), this way the automation can take back control (like e.g. latch mode).
|
override |
References onParameterChanged, and onParameterChangedAsync.
Referenced by setNormalisedValue(), and setValue().
|
override |
|
override |
References onParameterChangedAsync.
std::function<void()> onParameterChanged |
Set this lambda to be called from whatever thread is updating the parameter.
Referenced by parameterValueChanged().
std::function<void()> onParameterChangedAsync |
Set this lambda to be called from the message thread via AsyncUpdater.
Referenced by handleAsyncUpdate(), and parameterValueChanged().