Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::ParameterRange Class Reference

Public Types

enum class  Type : std::uint8_t {
  Linear , Toggle , Integer , GainAmplitude ,
  Logarithmic , Enumeration , Trigger
}
enum class  Unit : std::uint8_t {
  None , Hz , MHz , Db ,
  Degrees , Seconds , Ms , Us
}
 Unit to be displayed in the UI. More...

Public Member Functions

 ParameterRange (Type type, float min, float max, float zero=0.f, float def=0.f)
Q_INVOKABLE size_t enumCount () const
 Returns the number of enum entries.
Q_INVOKABLE size_t enumIndex (float normalized_val) const
 Converts a normalized value to an enum index.
Q_INVOKABLE float normalizedEnumValue (size_t index) const
 Returns the normalized value for a given enum index.
const auto & enum_label (size_t index) const
 Returns the label for a given enum index.
Q_INVOKABLE QString enumLabel (int index) const
template<EnumType E>
float normalized_from_enum (E value) const
template<EnumType E>
enum_value (float normalized_val) const
constexpr float clamp_to_range (float val) const
Q_INVOKABLE float convertFrom0To1 (float normalized_val) const
Q_INVOKABLE float convertTo0To1 (float real_val) const
Q_INVOKABLE bool isToggled (float normalized_val) const

Static Public Member Functions

static utils::Utf8String unit_to_string (Unit unit)
static ParameterRange make_toggle (bool default_val)
static ParameterRange make_gain (float max_val)
static ParameterRange make_enumeration (std::vector< utils::Utf8String > labels, size_t default_index=0)

Data Fields

Type type_ { Type::Linear }
Unit unit_ {}
 Parameter unit.
float minf_ { 0.f }
 Minimum, maximum and zero values for this parameter.
float maxf_ { 1.f }
float zerof_ { 0.f }
 The zero position of the port.
float deff_ { 0.f }
 Default value.
std::vector< utils::Utf8Stringenum_labels_
 Labels for Enumeration type parameters.

Friends

void to_json (nlohmann::json &j, const ParameterRange &p)
void from_json (const nlohmann::json &j, ParameterRange &p)

Detailed Description

Definition at line 22 of file parameter.h.

Member Enumeration Documentation

◆ Type

enum class zrythm::dsp::ParameterRange::Type : std::uint8_t
strong
Enumerator
Linear 

Linearly-scaled float parameter.

Toggle 

Whether the port is a toggle (on/off).

See also
Trigger
Integer 

Whether the port is an integer.

GainAmplitude 

Parameter is a gain amplitude (0-2.0).

Note
This is a special logarithmic-scaled parameter for gain parameters.
Logarithmic 

Logarithmic-scaled float parameter.

Enumeration 

Port's only reasonable values are its scale points.

Trigger 

Trigger parameters are set to on to trigger a change during processing and then turned off at the end of each cycle.

Used trigger eg, transport play/pause.

Definition at line 28 of file parameter.h.

◆ Unit

enum class zrythm::dsp::ParameterRange::Unit : std::uint8_t
strong

Unit to be displayed in the UI.

Enumerator
Ms 

Milliseconds.

Us 

Microseconds.

Definition at line 72 of file parameter.h.

Constructor & Destructor Documentation

◆ ParameterRange()

zrythm::dsp::ParameterRange::ParameterRange ( Type type,
float min,
float max,
float zero = 0.f,
float def = 0.f )
inline

Definition at line 93 of file parameter.h.

Member Function Documentation

◆ clamp_to_range()

float zrythm::dsp::ParameterRange::clamp_to_range ( float val) const
inlineconstexpr

Definition at line 187 of file parameter.h.

◆ enum_label()

const auto & zrythm::dsp::ParameterRange::enum_label ( size_t index) const
inline

Returns the label for a given enum index.

Definition at line 161 of file parameter.h.

◆ enum_value()

template<EnumType E>
E zrythm::dsp::ParameterRange::enum_value ( float normalized_val) const
inline

Definition at line 181 of file parameter.h.

◆ enumCount()

Q_INVOKABLE size_t zrythm::dsp::ParameterRange::enumCount ( ) const
inline

Returns the number of enum entries.

Definition at line 134 of file parameter.h.

◆ enumIndex()

Q_INVOKABLE size_t zrythm::dsp::ParameterRange::enumIndex ( float normalized_val) const
inline

Converts a normalized value to an enum index.

Definition at line 139 of file parameter.h.

◆ enumLabel()

Q_INVOKABLE QString zrythm::dsp::ParameterRange::enumLabel ( int index) const
inline

Definition at line 166 of file parameter.h.

◆ isToggled()

Q_INVOKABLE bool zrythm::dsp::ParameterRange::isToggled ( float normalized_val) const
inline

Definition at line 195 of file parameter.h.

◆ make_enumeration()

ParameterRange zrythm::dsp::ParameterRange::make_enumeration ( std::vector< utils::Utf8String > labels,
size_t default_index = 0 )
inlinestatic

Definition at line 108 of file parameter.h.

◆ make_gain()

ParameterRange zrythm::dsp::ParameterRange::make_gain ( float max_val)
inlinestatic

Definition at line 103 of file parameter.h.

◆ make_toggle()

ParameterRange zrythm::dsp::ParameterRange::make_toggle ( bool default_val)
inlinestatic

Definition at line 99 of file parameter.h.

◆ normalized_from_enum()

template<EnumType E>
float zrythm::dsp::ParameterRange::normalized_from_enum ( E value) const
inline

Definition at line 173 of file parameter.h.

◆ normalizedEnumValue()

Q_INVOKABLE float zrythm::dsp::ParameterRange::normalizedEnumValue ( size_t index) const
inline

Returns the normalized value for a given enum index.

Definition at line 150 of file parameter.h.

Field Documentation

◆ deff_

float zrythm::dsp::ParameterRange::deff_ { 0.f }

Default value.

Definition at line 226 of file parameter.h.

◆ enum_labels_

std::vector<utils::Utf8String> zrythm::dsp::ParameterRange::enum_labels_

Labels for Enumeration type parameters.

Definition at line 231 of file parameter.h.

◆ maxf_

float zrythm::dsp::ParameterRange::maxf_ { 1.f }

Definition at line 214 of file parameter.h.

◆ minf_

float zrythm::dsp::ParameterRange::minf_ { 0.f }

Minimum, maximum and zero values for this parameter.

Definition at line 213 of file parameter.h.

◆ type_

Type zrythm::dsp::ParameterRange::type_ { Type::Linear }

Definition at line 205 of file parameter.h.

◆ unit_

Unit zrythm::dsp::ParameterRange::unit_ {}

Parameter unit.

Definition at line 208 of file parameter.h.

◆ zerof_

float zrythm::dsp::ParameterRange::zerof_ { 0.f }

The zero position of the port.

For example, in balance controls, this will be the middle.

Definition at line 221 of file parameter.h.


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