Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Control

UI control / parameter. More...

#include <klang.h>

Classes

struct  Size
 Control size. More...
 

Public Types

enum  Type {
  NONE , ROTARY , BUTTON , TOGGLE ,
  SLIDER , MENU , METER , WHEEL
}
 
typedef Array< Caption, 128 > Options
 

Public Member Functions

 operator signal & ()
 
 operator const signal & () const
 
 operator param () const
 
 operator float () const
 
signal smooth ()
 
 operator Control * ()
 
Controlset (float x)
 
Controloperator+= (float x)
 
Controloperator*= (float x)
 
Controloperator-= (float x)
 
Controloperator/= (float x)
 
template<typename TYPE >
signal operator+ (const Control &x) const
 
template<typename TYPE >
signal operator* (const Control &x) const
 
template<typename TYPE >
signal operator- (const Control &x) const
 
template<typename TYPE >
signal operator/ (const Control &x) const
 
template<typename TYPE >
float operator+ (TYPE x) const
 
template<typename TYPE >
float operator* (TYPE x) const
 
template<typename TYPE >
float operator- (TYPE x) const
 
template<typename TYPE >
float operator/ (TYPE x) const
 
template<typename TYPE >
Controloperator<< (TYPE &in)
 
template<typename TYPE >
Controloperator<< (const TYPE &in)
 
template<typename TYPE >
TYPE & operator>> (TYPE &in)
 
template<typename TYPE >
const TYPE & operator>> (const TYPE &in)
 

Public Attributes

Caption name
 
Type type = NONE
 
float min
 
float max
 
float initial
 
Size size
 
Options options
 
signal value
 
signal smoothed
 

Static Public Attributes

static constexpr float smoothing = 0.999f
 

Detailed Description

Definition at line 953 of file klang.h.

Member Typedef Documentation

◆ Options

Definition at line 981 of file klang.h.

Member Enumeration Documentation

◆ Type

Values
NONE 
ROTARY 
BUTTON 
TOGGLE 
SLIDER 
MENU 
METER 
WHEEL 

Definition at line 955 of file klang.h.

956 {
957 NONE, // no control (list terminator)
958 ROTARY, // rotary knob (dial/pot)
959 BUTTON, // push button (trigger)
960 TOGGLE, // on/off switch (toggle)
961 SLIDER, // linear slider (fader)
962 MENU, // drop-down list (menu; up to 128 items)
963 METER, // level meter (read-only: use setParameter() to set value)
964 WHEEL, // MIDI control (Pitch Bend / Mod Wheel only)
965 };

Member Function Documentation

◆ operator const signal &()

klang::Control::operator const signal & ( ) const
inline

Definition at line 997 of file klang.h.

997{ return value; }
signal value
Definition klang.h:993

References value.

◆ operator Control *()

klang::Control::operator Control * ( )
inline

Definition at line 1004 of file klang.h.

1004{ return this; }

◆ operator float()

klang::Control::operator float ( ) const
inline

Definition at line 999 of file klang.h.

999{ return value.value; }
float value
Definition klang.h:363

References value, and klang::signal::value.

◆ operator param()

klang::Control::operator param ( ) const
inline

Definition at line 998 of file klang.h.

998{ return value; }

References value.

◆ operator signal &()

klang::Control::operator signal & ( )
inline

Definition at line 996 of file klang.h.

996{ return value; }

References value.

◆ operator*() [1/2]

template<typename TYPE >
signal klang::Control::operator* ( const Control & x) const
inline

Definition at line 1022 of file klang.h.

1022{ return value * x; }

◆ operator*() [2/2]

template<typename TYPE >
float klang::Control::operator* ( TYPE x) const
inline

Definition at line 1027 of file klang.h.

1027{ return value * x; }

◆ operator*=()

Control & klang::Control::operator*= ( float x)
inline

Definition at line 1012 of file klang.h.

1012{ value *= x; return *this; }

References klang::signal::operator*=(), and value.

◆ operator+() [1/2]

template<typename TYPE >
signal klang::Control::operator+ ( const Control & x) const
inline

Definition at line 1021 of file klang.h.

1021{ return value + x; }

◆ operator+() [2/2]

template<typename TYPE >
float klang::Control::operator+ ( TYPE x) const
inline

Definition at line 1026 of file klang.h.

1026{ return value + x; }

◆ operator+=()

Control & klang::Control::operator+= ( float x)
inline

Definition at line 1011 of file klang.h.

1011{ value += x; return *this; }

References klang::signal::operator+=(), and value.

◆ operator-() [1/2]

template<typename TYPE >
signal klang::Control::operator- ( const Control & x) const
inline

Definition at line 1023 of file klang.h.

1023{ return value - x; }

◆ operator-() [2/2]

template<typename TYPE >
float klang::Control::operator- ( TYPE x) const
inline

Definition at line 1028 of file klang.h.

1028{ return value - x; }

◆ operator-=()

Control & klang::Control::operator-= ( float x)
inline

Definition at line 1013 of file klang.h.

1013{ value -= x; return *this; }

References klang::signal::operator-=(), and value.

◆ operator/() [1/2]

template<typename TYPE >
signal klang::Control::operator/ ( const Control & x) const
inline

Definition at line 1024 of file klang.h.

1024{ return value / x; }

◆ operator/() [2/2]

template<typename TYPE >
float klang::Control::operator/ ( TYPE x) const
inline

Definition at line 1029 of file klang.h.

1029{ return value / x; }

◆ operator/=()

Control & klang::Control::operator/= ( float x)
inline

Definition at line 1014 of file klang.h.

1014{ value /= x; return *this; }

References klang::signal::operator/=(), and value.

◆ operator<<() [1/2]

template<typename TYPE >
Control & klang::Control::operator<< ( const TYPE & in)
inline

Definition at line 1032 of file klang.h.

1032{ value = in; return *this; } // assign to control without/after processing

◆ operator<<() [2/2]

template<typename TYPE >
Control & klang::Control::operator<< ( TYPE & in)
inline

Definition at line 1031 of file klang.h.

1031{ value = in; return *this; } // assign to control with processing

◆ operator>>() [1/2]

template<typename TYPE >
const TYPE & klang::Control::operator>> ( const TYPE & in)
inline

Definition at line 1035 of file klang.h.

1035{ return value >> in; } // stream control to signal/object (no processing)

◆ operator>>() [2/2]

template<typename TYPE >
TYPE & klang::Control::operator>> ( TYPE & in)
inline

Definition at line 1034 of file klang.h.

1034{ return value >> in; } // stream control to signal/object (allows processing)

◆ set()

Control & klang::Control::set ( float x)
inline

Definition at line 1006 of file klang.h.

1006 {
1007 value = std::clamp(x, min, max);
1008 return *this;
1009 }
float max
Definition klang.h:987
float min
Definition klang.h:986

References max, min, and value.

◆ smooth()

signal klang::Control::smooth ( )
inline

Definition at line 1002 of file klang.h.

1002{ return smoothed = smoothed * smoothing + (1.f - smoothing) * value; }
static constexpr float smoothing
Definition klang.h:1001
signal smoothed
Definition klang.h:994

References klang::signal::operator*(), klang::signal::operator+(), smoothed, smoothing, and value.

Referenced by klang::ControlMap::smooth().

Member Data Documentation

◆ initial

float klang::Control::initial

Definition at line 988 of file klang.h.

Referenced by klang::Controls::add().

◆ max

float klang::Control::max

Definition at line 987 of file klang.h.

Referenced by klang::Controls::add(), and set().

◆ min

float klang::Control::min

Definition at line 986 of file klang.h.

Referenced by klang::Controls::add(), and set().

◆ name

Caption klang::Control::name

Definition at line 983 of file klang.h.

Referenced by klang::Controls::add().

◆ options

Options klang::Control::options

Definition at line 991 of file klang.h.

◆ size

Size klang::Control::size

Definition at line 990 of file klang.h.

Referenced by klang::Controls::add().

◆ smoothed

signal klang::Control::smoothed

Definition at line 994 of file klang.h.

Referenced by smooth().

◆ smoothing

float klang::Control::smoothing = 0.999f
staticconstexpr

Definition at line 1001 of file klang.h.

Referenced by smooth().

◆ type

Type klang::Control::type = NONE

Definition at line 984 of file klang.h.

Referenced by klang::Controls::add(), and klang::Controls::operator=().

◆ value