Krotos Modules 3
Loading...
Searching...
No Matches
krotos::KParameter Class Reference

Internal Kwidget parameter that can receive changes from a GenericParameter. More...

#include <KParameter.h>

Inheritance diagram for krotos::KParameter:

Classes

struct  AsyncListenerObject
 Used to create a KParameter listener for GUI or non time critical updates. More...
 
struct  AudioListenerObject
 A KParameter Listener which can be used to trigger a callback syncrhonously. More...
 

Public Member Functions

 KParameter (const String &parameterID, const String &parameterName, const NormalisableRange< float > &normalisableRange, float defaultValue, const String &parameterLabel=String(), std::function< String(float value, int maximumStringLength)> stringFromValue=nullptr, std::function< float(const String &text)> valueFromString=nullptr)
 
float get () const
 
float getValue () const override
 
bool isOn () const
 
void set (float newValue)
 
void notifyListeners ()
 
void attach (GenericParameter *p)
 
void detach ()
 
GenericParametergetAttachedParameter ()
 
const NormalisableRange< float > & getNormalisableRange () const override
 
void parameterValueChanged (int, float newValue) override
 
void parameterGestureChanged (int, bool) override
 

Private Member Functions

void setValue (float newValue) override
 
float getDefaultValue () const override
 
String getText (float value, int length) const override
 
float getValueForText (const String &text) const override
 

Private Attributes

NormalisableRange< float > m_range
 
std::atomic< float > m_value
 
std::atomic< float > m_normalisedValue
 
const float m_defaultValue
 
GenericParameterm_attachedParameter {nullptr}
 
std::function< String(float, int)> m_stringFromValueFunction
 
std::function< float(const String &)> m_valueFromStringFunction
 

Friends

class GenericParameter
 

Detailed Description

Internal Kwidget parameter that can receive changes from a GenericParameter.

KParameter is designed to be an audio parameter that is owned internally by a Kwidget, and can be assigned to an external or DAW-facing parameter to control the audio produced by that Kwidget.

KParameter works in tandem with GenericParameter to allow the ability to route external parameters to different internal parameters at runtime.

See also
GenericParameter

Constructor & Destructor Documentation

◆ KParameter()

krotos::KParameter::KParameter ( const String & parameterID,
const String & parameterName,
const NormalisableRange< float > & normalisableRange,
float defaultValue,
const String & parameterLabel = String(),
std::function< String(float value, int maximumStringLength)> stringFromValue = nullptr,
std::function< float(const String &text)> valueFromString = nullptr )

Constructor.

Member Function Documentation

◆ attach()

void krotos::KParameter::attach ( GenericParameter * p)

Link this parameter to a GenericParameter.

When this object is linked to a GenericParameter, the GenericParameter will receive the name, range, etc. from this parameter, and this parameter will receive changes in value from the GenericParameter.

◆ detach()

void krotos::KParameter::detach ( )

Detach from the current GenericParameter.

◆ get()

float krotos::KParameter::get ( ) const

Returns the current denormalised parameter value.

◆ getAttachedParameter()

GenericParameter * krotos::KParameter::getAttachedParameter ( )

Get the GenericParameter this KParameter is currently attached to, or nullptr if it isn't attached to anything.

◆ getDefaultValue()

float krotos::KParameter::getDefaultValue ( ) const
overrideprivate

◆ getNormalisableRange()

const NormalisableRange< float > & krotos::KParameter::getNormalisableRange ( ) const
override

Get this parameter's range.

◆ getText()

String krotos::KParameter::getText ( float value,
int length ) const
overrideprivate

◆ getValue()

float krotos::KParameter::getValue ( ) const
override

Returns the current normalised parameter value.

◆ getValueForText()

float krotos::KParameter::getValueForText ( const String & text) const
overrideprivate

◆ isOn()

bool krotos::KParameter::isOn ( ) const

Helper function for "boolean" parameters. Returns true if the normalised value is > 0.5

◆ notifyListeners()

void krotos::KParameter::notifyListeners ( )

Calls the parameter's ValueChanged listeners with the current value.

◆ parameterGestureChanged()

void krotos::KParameter::parameterGestureChanged ( int ,
bool  )
inlineoverride

◆ parameterValueChanged()

void krotos::KParameter::parameterValueChanged ( int ,
float newValue )
override

Updates the parameter's value when a linked GenericParameter changes.

◆ set()

void krotos::KParameter::set ( float newValue)

Sets the current denormalised parameter value, and sends a notification.

◆ setValue()

void krotos::KParameter::setValue ( float newValue)
overrideprivate

Friends And Related Symbol Documentation

◆ GenericParameter

friend class GenericParameter
friend

Member Data Documentation

◆ m_attachedParameter

GenericParameter* krotos::KParameter::m_attachedParameter {nullptr}
private

◆ m_defaultValue

const float krotos::KParameter::m_defaultValue
private

◆ m_normalisedValue

std::atomic<float> krotos::KParameter::m_normalisedValue
private

◆ m_range

NormalisableRange<float> krotos::KParameter::m_range
private

◆ m_stringFromValueFunction

std::function<String(float, int)> krotos::KParameter::m_stringFromValueFunction
private

◆ m_value

std::atomic<float> krotos::KParameter::m_value
private

◆ m_valueFromStringFunction

std::function<float(const String&)> krotos::KParameter::m_valueFromStringFunction
private

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