Gin
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Parameter Class Reference

Advanced parameter class with modulation, real-time callbacks, and host automation. More...

#include <gin_parameter.h>

Inheritance diagram for Parameter:

Classes

class  ParameterListener
 
struct  ParamState
 

Public Types

using Ptr = Parameter *
 

Public Member Functions

 Parameter (Processor &, juce::String uid, juce::String name, juce::String shortName, juce::String label, float minValue, float maxValue, float intervalValue, float defaultValue, float skewFactor=1.0f, std::function< juce::String(const Parameter &, float)> textFunction=nullptr)
 
 Parameter (Processor &, juce::String uid, juce::String name, juce::String shortName, juce::String label, juce::NormalisableRange< float > range, float defaultValue, std::function< juce::String(const Parameter &, float)> textFunction=nullptr)
 
juce::String getUid () const
 
void setInternal (bool i)
 
bool isInternal () const
 
void setModIndex (int i)
 
int getModIndex () const
 
void setModMatrix (ModMatrix *m)
 
ModMatrixgetModMatrix () const
 
virtual void prepareToPlay (double, int)
 
virtual void reset ()
 
float getProcValue ()
 
virtual float getProcValue (int)
 
float getUserValue () const
 
int getUserValueInt () const
 
bool getUserValueBool () const
 
float getUserDefaultValue () const
 
virtual void setUserValue (float v)
 
virtual void setUserValueNotifingHost (float f)
 
void setUserValueAsUserAction (float f)
 
juce::String getUserValueText () const
 
juce::String userValueToText (float val)
 
bool isOnOff ()
 
bool isOn ()
 
virtual bool isSmoothingActive ()
 
void beginUserAction ()
 
void beginUserTimedAction ()
 
void endUserAction ()
 
juce::NormalisableRange< floatgetUserRange () const
 
float getUserRangeStart () const
 
float getUserRangeEnd () const
 
void addListener (ParameterListener *listener)
 
void removeListener (ParameterListener *listener)
 
ParamState getState ()
 
void setState (const ParamState &state)
 
juce::String getParameterID () const override
 
float getValue () const override
 
bool getBoolValue () const
 
void setValue (float newValue) override
 
float getDefaultValue () const override
 
juce::String getName (int maximumStringLength) const override
 
juce::String getShortName () const
 
juce::String getLabel () const override
 
int getNumSteps () const override
 
juce::String getText (float value, int) const override
 
float getValueForText (const juce::String &text) const override
 
bool isOrientationInverted () const override
 
bool isAutomatable () const override
 
bool isMetaParameter () const override
 
float getSkew ()
 
bool isSkewSymmetric ()
 
- Public Member Functions inherited from RealtimeAsyncUpdater
 RealtimeAsyncUpdater ()
 Creates a RealtimeAsyncUpdater.
 
virtual ~RealtimeAsyncUpdater ()
 Destructor.
 
void triggerAsyncUpdate ()
 Triggers an asynchronous update.
 
void cancelPendingUpdate () noexcept
 Cancels any pending update.
 
void handleUpdateNowIfNeeded ()
 Handles the update immediately if one is pending.
 
bool isUpdatePending () const noexcept
 Checks if an update is currently pending.
 

Public Attributes

std::function< float(float)> conversionFunction
 

Protected Member Functions

void handleAsyncUpdate () override
 Called asynchronously when an update is triggered.
 
void timerCallback () override
 
virtual void changed ()
 

Protected Attributes

Processorprocessor
 
const juce::NormalisableRange< floatrange
 
bool internal = false
 
ModMatrixmodMatrix = nullptr
 
int modIndex = -1
 
std::atomic< floatvalue {0.0f}
 
const float defaultValue = 0.0f
 
const juce::String uid
 
const juce::String name
 
const juce::String shortName
 
const juce::String label
 
const std::function< juce::String(const Parameter &, float)> textFunction
 
int userActionCount = 0
 
juce::ListenerList< ParameterListenerlisteners
 

Detailed Description

Advanced parameter class with modulation, real-time callbacks, and host automation.

Parameter provides a comprehensive plugin parameter implementation with features needed for professional audio plugins. It extends JUCE's parameter system with modulation support, user/processing value separation, and real-time safe callbacks.

Value Formats: Parameter values are represented in three formats:

By default, user value and proc value are identical. To provide custom processing values, set the conversionFunction (e.g., converting dB to linear gain).

Parameter Types:

Key Features:

Usage:

// Create a gain parameter with dB display but linear processing
auto* gain = new Parameter(processor,
"gain", "Gain", "Gain", "dB",
-100.0f, 10.0f, // User range: -100 to +10 dB
0.1f, // Step size
0.0f, // Default value
1.0f); // No skew
// Convert dB to linear for processing
gain->conversionFunction = [](float db) {
return juce::Decibels::decibelsToGain(db);
};
// In DSP code
float linearGain = gain->getProcValue();
// In UI
String displayText = gain->getUserValueText(); // "0.0 dB"
Advanced parameter class with modulation, real-time callbacks, and host automation.
Definition gin_parameter.h:67
Processor & processor
Definition gin_parameter.h:181
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
See also
Processor, ModMatrix, SmoothedParameter

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ Parameter() [1/2]

Parameter::Parameter ( Processor ,
juce::String  uid,
juce::String  name,
juce::String  shortName,
juce::String  label,
float  minValue,
float  maxValue,
float  intervalValue,
float  defaultValue,
float  skewFactor = 1.0f,
std::function< juce::String(const Parameter &, float)>  textFunction = nullptr 
)

◆ Parameter() [2/2]

Parameter::Parameter ( Processor ,
juce::String  uid,
juce::String  name,
juce::String  shortName,
juce::String  label,
juce::NormalisableRange< float range,
float  defaultValue,
std::function< juce::String(const Parameter &, float)>  textFunction = nullptr 
)

Member Function Documentation

◆ getUid()

juce::String Parameter::getUid ( ) const

References uid.

Referenced by ParamComponent::getUid().

◆ setInternal()

void Parameter::setInternal ( bool  i)

References internal.

◆ isInternal()

bool Parameter::isInternal ( ) const

References internal.

◆ setModIndex()

void Parameter::setModIndex ( int  i)

References modIndex.

◆ getModIndex()

int Parameter::getModIndex ( ) const

References modIndex.

◆ setModMatrix()

void Parameter::setModMatrix ( ModMatrix m)

References modMatrix.

◆ getModMatrix()

ModMatrix * Parameter::getModMatrix ( ) const

References modMatrix.

◆ prepareToPlay()

virtual void Parameter::prepareToPlay ( double  ,
int   
)
virtual

◆ reset()

virtual void Parameter::reset ( )
virtual

◆ getProcValue() [1/2]

float Parameter::getProcValue ( )

◆ getProcValue() [2/2]

virtual float Parameter::getProcValue ( int  )
virtual

◆ getUserValue()

float Parameter::getUserValue ( ) const

◆ getUserValueInt()

int Parameter::getUserValueInt ( ) const

References range, and value.

◆ getUserValueBool()

bool Parameter::getUserValueBool ( ) const

References range, and value.

◆ getUserDefaultValue()

float Parameter::getUserDefaultValue ( ) const

References defaultValue.

Referenced by PluginSlider::mouseDown().

◆ setUserValue()

virtual void Parameter::setUserValue ( float  v)
virtual

◆ setUserValueNotifingHost()

virtual void Parameter::setUserValueNotifingHost ( float  f)
virtual

◆ setUserValueAsUserAction()

void Parameter::setUserValueAsUserAction ( float  f)

◆ getUserValueText()

juce::String Parameter::getUserValueText ( ) const

◆ userValueToText()

juce::String Parameter::userValueToText ( float  val)

References getText(), label, and range.

Referenced by PluginComboBox::PluginComboBox().

◆ isOnOff()

bool Parameter::isOnOff ( )

References range.

◆ isOn()

bool Parameter::isOn ( )

References getUserValue(), and range.

◆ isSmoothingActive()

virtual bool Parameter::isSmoothingActive ( )
virtual

◆ beginUserAction()

void Parameter::beginUserAction ( )

◆ beginUserTimedAction()

void Parameter::beginUserTimedAction ( )

◆ endUserAction()

void Parameter::endUserAction ( )

◆ getUserRange()

juce::NormalisableRange< float > Parameter::getUserRange ( ) const

References range.

◆ getUserRangeStart()

float Parameter::getUserRangeStart ( ) const

◆ getUserRangeEnd()

float Parameter::getUserRangeEnd ( ) const

◆ addListener()

void Parameter::addListener ( ParameterListener listener)

◆ removeListener()

void Parameter::removeListener ( ParameterListener listener)

◆ getState()

ParamState Parameter::getState ( )

◆ setState()

void Parameter::setState ( const ParamState state)

◆ getParameterID()

juce::String Parameter::getParameterID ( ) const
override

References uid.

◆ getValue()

float Parameter::getValue ( ) const
override

References range, and value.

Referenced by getBoolValue(), and getUserValueText().

◆ getBoolValue()

bool Parameter::getBoolValue ( ) const

References getValue().

◆ setValue()

void Parameter::setValue ( float  newValue)
override

◆ getDefaultValue()

float Parameter::getDefaultValue ( ) const
override

References defaultValue, and range.

◆ getName()

juce::String Parameter::getName ( int  maximumStringLength) const
override

◆ getShortName()

juce::String Parameter::getShortName ( ) const

◆ getLabel()

juce::String Parameter::getLabel ( ) const
override

References label.

◆ getNumSteps()

int Parameter::getNumSteps ( ) const
override

◆ getText()

juce::String Parameter::getText ( float  value,
int   
) const
override

◆ getValueForText()

float Parameter::getValueForText ( const juce::String &  text) const
override

◆ isOrientationInverted()

bool Parameter::isOrientationInverted ( ) const
override

◆ isAutomatable()

bool Parameter::isAutomatable ( ) const
override

◆ isMetaParameter()

bool Parameter::isMetaParameter ( ) const
override

◆ getSkew()

float Parameter::getSkew ( )

References range.

◆ isSkewSymmetric()

bool Parameter::isSkewSymmetric ( )

References range.

◆ handleAsyncUpdate()

void Parameter::handleAsyncUpdate ( )
overrideprotectedvirtual

Called asynchronously when an update is triggered.

Override this method to perform your update logic. This will be called on a dedicated background thread (not the message thread).

Implements RealtimeAsyncUpdater.

◆ timerCallback()

void Parameter::timerCallback ( )
overrideprotected

◆ changed()

virtual void Parameter::changed ( )
protectedvirtual

Member Data Documentation

◆ conversionFunction

std::function<float (float)> Parameter::conversionFunction

Referenced by getProcValue(), and getProcValue().

◆ processor

Processor& Parameter::processor
protected

◆ range

const juce::NormalisableRange<float> Parameter::range
protected

◆ internal

bool Parameter::internal = false
protected

Referenced by isInternal(), and setInternal().

◆ modMatrix

ModMatrix* Parameter::modMatrix = nullptr
protected

Referenced by getModMatrix(), and setModMatrix().

◆ modIndex

int Parameter::modIndex = -1
protected

Referenced by getModIndex(), and setModIndex().

◆ value

std::atomic<float> Parameter::value {0.0f}
protected

◆ defaultValue

const float Parameter::defaultValue = 0.0f
protected

◆ uid

const juce::String Parameter::uid
protected

Referenced by getParameterID(), and getUid().

◆ name

const juce::String Parameter::name
protected

◆ shortName

const juce::String Parameter::shortName
protected

Referenced by getShortName().

◆ label

const juce::String Parameter::label
protected

◆ textFunction

const std::function<juce::String (const Parameter&, float)> Parameter::textFunction
protected

◆ userActionCount

int Parameter::userActionCount = 0
protected

◆ listeners

juce::ListenerList<ParameterListener> Parameter::listeners
protected

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