foleys_gui_magic
WYSWYG editor for JUCE GUIs including Visualisers
Public Member Functions | Public Attributes | List of all members
ParameterAttachment< ValueType > Class Template Reference

The ParameterAttachment is a class you can use to have a value synchronised with an AudioProcessorParameter. More...

Inherits Listener, and AsyncUpdater.

Public Member Functions

 ParameterAttachment ()
 
virtual ~ParameterAttachment () override
 
ValueType getValue () const
 Thread safe way to read the current value. More...
 
ValueType getNormalisedValue () const
 Thread safe way to read the normalised value of the current value. More...
 
void setValue (ValueType newValue)
 Set the value from a not normalised range.min..range.max value. More...
 
void setNormalisedValue (ValueType newValue)
 Set the value from a normalised 0..1 value. More...
 
void attachToParameter (juce::RangedAudioParameter *parameterToUse)
 Make this value attached to the parameter with the supplied parameterID. More...
 
void detachFromParameter ()
 
void beginGesture ()
 Make sure to call this before you send changes (e.g. More...
 
void endGesture ()
 Make sure to call this after finishing your changes (e.g. More...
 
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. More...
 
std::function< void()> onParameterChangedAsync
 Set this lambda to be called from the message thread via AsyncUpdater. More...
 

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()

◆ ~ParameterAttachment()

virtual ~ParameterAttachment ( )
overridevirtual

Member Function Documentation

◆ getValue()

ValueType getValue ( ) const

Thread safe way to read the current value.

◆ getNormalisedValue()

ValueType getNormalisedValue ( ) const

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

◆ setValue()

void setValue ( ValueType  newValue)

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

References ParameterAttachment< ValueType >::parameterValueChanged().

◆ setNormalisedValue()

void setNormalisedValue ( ValueType  newValue)

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

References ParameterAttachment< ValueType >::parameterValueChanged().

Referenced by XYDragComponent::mouseDrag().

◆ attachToParameter()

void attachToParameter ( juce::RangedAudioParameter *  parameterToUse)

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

References ParameterAttachment< ValueType >::detachFromParameter().

◆ detachFromParameter()

void detachFromParameter ( )

◆ beginGesture()

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.

◆ endGesture()

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()

void parameterValueChanged ( int  parameterIndex,
float  newValue 
)
override

◆ parameterGestureChanged()

void parameterGestureChanged ( int  parameterIndex,
bool  gestureIsStarting 
)
override

◆ handleAsyncUpdate()

void handleAsyncUpdate ( )
override

Member Data Documentation

◆ onParameterChanged

std::function<void()> onParameterChanged

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

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

◆ onParameterChangedAsync

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: