WYSWYG editor for JUCE GUIs including Visualisers
Loading...
Searching...
No Matches
ParameterAttachment< ValueType > Class Template Reference

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.
 

Detailed Description

template<typename ValueType>
class foleys::ParameterAttachment< ValueType >

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.

Constructor & Destructor Documentation

◆ ParameterAttachment()

template<typename ValueType >
ParameterAttachment ( )

◆ ~ParameterAttachment()

template<typename ValueType >
virtual ~ParameterAttachment ( )
overridevirtual

Member Function Documentation

◆ getValue()

template<typename ValueType >
ValueType getValue ( ) const

Thread safe way to read the current value.

◆ getNormalisedValue()

template<typename ValueType >
ValueType getNormalisedValue ( ) const

Thread safe way to read the normalised value of the current value.

◆ setValue()

template<typename ValueType >
void setValue ( ValueType newValue)

Set the value from a not normalised range.min..range.max value.

References ParameterAttachment< ValueType >::parameterValueChanged().

◆ setNormalisedValue()

template<typename ValueType >
void setNormalisedValue ( ValueType newValue)

Set the value from a normalised 0..1 value.

References ParameterAttachment< ValueType >::parameterValueChanged().

Referenced by XYDragComponent::mouseDown(), and XYDragComponent::mouseDrag().

◆ attachToParameter()

template<typename ValueType >
void attachToParameter ( juce::RangedAudioParameter * parameterToUse)

Make this value attached to the parameter with the supplied parameterID.

References ParameterAttachment< ValueType >::detachFromParameter().

Referenced by XYDragComponent::setParameterX(), and XYDragComponent::setParameterY().

◆ detachFromParameter()

template<typename ValueType >
void detachFromParameter ( )

◆ beginGesture()

template<typename ValueType >
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.

Referenced by XYDragComponent::mouseDown().

◆ endGesture()

template<typename ValueType >
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).

Referenced by XYDragComponent::mouseUp().

◆ parameterValueChanged()

template<typename ValueType >
void parameterValueChanged ( int parameterIndex,
float newValue )
override

◆ parameterGestureChanged()

template<typename ValueType >
void parameterGestureChanged ( int parameterIndex,
bool gestureIsStarting )
override

◆ handleAsyncUpdate()

template<typename ValueType >
void handleAsyncUpdate ( )
override

Member Data Documentation

◆ onParameterChanged

template<typename ValueType >
std::function<void()> onParameterChanged

Set this lambda to be called from whatever thread is updating the parameter.

Referenced by ParameterAttachment< ValueType >::parameterValueChanged().

◆ onParameterChangedAsync

template<typename ValueType >
std::function<void()> onParameterChangedAsync

Set this lambda to be called from the message thread via AsyncUpdater.

Referenced by ParameterAttachment< ValueType >::handleAsyncUpdate(), ParameterAttachment< ValueType >::parameterValueChanged(), and XYDragComponent::XYDragComponent().


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