Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::state::SkewedRange< T > Struct Template Reference

Skew-aware normalized range with optional symmetric center. More...

#include <parameter.hpp>

Public Member Functions

constexpr SkewedRange ()=default
constexpr SkewedRange (T lo, T hi, T step=T(0), T skew_value=T(1), bool symmetric=false)
T normalize (T value) const
 Map a real value in [min, max] to a normalized value in [0, 1].
T denormalize (T normalized) const
 Map a normalized [0, 1] value back to the real range.
T snap (T value) const
 Round a real value down to the nearest legal step.

Static Public Member Functions

static SkewedRange with_center (T lo, T hi, T center, T step=T(0))
 Build a SkewedRange whose normalized midpoint maps to the supplied real-valued center.

Public Attributes

T min = T(0)
T max = T(1)
T interval = T(0)
 Step size. 0 = continuous.
T skew = T(1)
 1 = linear, <1 weights min, >1 weights max.
bool symmetric_skew = false

Detailed Description

template<typename T = float>
struct pulp::state::SkewedRange< T >

Skew-aware normalized range with optional symmetric center.

SkewedRange<T> extends ParamRange with a non-linear mapping between the [0, 1] host-automation domain and the [min, max] parameter domain. Two shape controls:

  • skew: <1 weights toward `min`, >1 weights toward max, 1 = linear. Conventionally, a skew of log(0.5) / log((mid - min) / (max - min)) places mid at the center (0.5) of the normalized range.
  • symmetric_skew: when true, the curve is mirrored around the center, so values near 0.5 in normalized space land near the midpoint and values near the edges fan out symmetrically. Useful for bipolar parameters like pan, balance, detune.

Step quantization is honored on denormalize (matches ParamRange::step).

// Frequency knob: 20 Hz at min, 20 kHz at max, 1 kHz at center.
pulp::state::SkewedRange<float> freq{20.0f, 20000.0f, 1000.0f};
float normalized = freq.normalize(1000.0f); // ~= 0.5
float hz = freq.denormalize(0.5f); // ~= 1000.0f
Skew-aware normalized range with optional symmetric center.
Definition parameter.hpp:238
T denormalize(T normalized) const
Map a normalized [0, 1] value back to the real range.
Definition parameter.hpp:284
T normalize(T value) const
Map a real value in [min, max] to a normalized value in [0, 1].
Definition parameter.hpp:269

Constructor & Destructor Documentation

◆ SkewedRange() [1/2]

template<typename T = float>
pulp::state::SkewedRange< T >::SkewedRange ( )
constexprdefault

◆ SkewedRange() [2/2]

template<typename T = float>
pulp::state::SkewedRange< T >::SkewedRange ( T lo,
T hi,
T step = T(0),
T skew_value = T(1),
bool symmetric = false )
inlineconstexpr

Member Function Documentation

◆ denormalize()

template<typename T = float>
T pulp::state::SkewedRange< T >::denormalize ( T normalized) const
inline

Map a normalized [0, 1] value back to the real range.

Applies interval quantization when non-zero.

◆ normalize()

template<typename T = float>
T pulp::state::SkewedRange< T >::normalize ( T value) const
inline

Map a real value in [min, max] to a normalized value in [0, 1].

Skew convention: with skew < 1 the curve weights toward min (small real values cover more of the [0, 1] domain); with skew > 1 the curve weights toward max. skew == 1 is linear.

◆ snap()

template<typename T = float>
T pulp::state::SkewedRange< T >::snap ( T value) const
inline

Round a real value down to the nearest legal step.

◆ with_center()

template<typename T = float>
SkewedRange pulp::state::SkewedRange< T >::with_center ( T lo,
T hi,
T center,
T step = T(0) )
inlinestatic

Build a SkewedRange whose normalized midpoint maps to the supplied real-valued center.

Equivalent to choosing the skew that satisfies denormalize(0.5) == center.

Member Data Documentation

◆ interval

template<typename T = float>
T pulp::state::SkewedRange< T >::interval = T(0)

Step size. 0 = continuous.

◆ max

template<typename T = float>
T pulp::state::SkewedRange< T >::max = T(1)

◆ min

template<typename T = float>
T pulp::state::SkewedRange< T >::min = T(0)

◆ skew

template<typename T = float>
T pulp::state::SkewedRange< T >::skew = T(1)

1 = linear, <1 weights min, >1 weights max.

◆ symmetric_skew

template<typename T = float>
bool pulp::state::SkewedRange< T >::symmetric_skew = false

The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/state/include/pulp/state/parameter.hpp