Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::state::ParamRange Struct Reference

Defines the numeric range of a parameter, including normalization. More...

#include <parameter.hpp>

Public Member Functions

bool is_linear () const
 True when this range is a plain affine (linear) map — the common case.
float normalize (float value) const
 Map a real value to the normalized [0, 1] range.
float denormalize (float normalized) const
 Map a normalized [0, 1] value back to the real range.

Static Public Member Functions

static ParamRange linear (float lo, float hi, float def=0.0f, float step_value=0.0f)
 Build a linear range covering [lo, hi] with the given default and step.
static ParamRange with_center (float lo, float hi, float center, float def=0.0f, float step_value=0.0f)
 Build a shaped range whose normalized midpoint (0.5) maps to center.

Public Attributes

float min = 0.0f
float max = 1.0f
float default_value = 0.0f
float step = 0.0f
 Quantization step. 0 = continuous.
float skew = 1.0f
 1 = linear, <1 weights min, >1 weights max.
bool symmetric_skew = false
 Mirror the curve around the center (bipolar).

Detailed Description

Defines the numeric range of a parameter, including normalization.

Normalization maps the [min, max] range to [0, 1] for host automation. If step is non-zero, denormalized values snap to the nearest step.

Shaped (non-linear) ranges

skew and symmetric_skew give the range a non-linear curve between the [0, 1] host-automation domain and the [min, max] parameter domain:

  • skew == 1 (default) is linear — the conversion is bit-identical to a plain affine map, so existing linear parameters are unchanged.
  • skew < 1 weights the curve toward min (small real values cover more of the [0, 1] domain — e.g. a frequency knob where the low end gets more resolution). skew > 1 weights toward max.
  • symmetric_skew == true mirrors the curve around the center, so the midpoint of the normalized domain lands at the midpoint of [min, max] and both halves fan out symmetrically. Useful for bipolar parameters (pan, detune, balance).

The shaping convention matches SkewedRange<T> below, which shares the same math. Use ParamRange::with_center() to derive the skew that places a chosen real value at the normalized midpoint (0.5).

Member Function Documentation

◆ denormalize()

float pulp::state::ParamRange::denormalize ( float normalized) const
inline

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

Applies step quantization if step > 0.

Parameters
normalizedValue in [0, 1].
Returns
Real value clamped to [min, max], optionally quantized.

◆ is_linear()

bool pulp::state::ParamRange::is_linear ( ) const
inline

True when this range is a plain affine (linear) map — the common case.

Used to take a bit-identical fast path that bypasses the skew math.

◆ linear()

ParamRange pulp::state::ParamRange::linear ( float lo,
float hi,
float def = 0.0f,
float step_value = 0.0f )
inlinestatic

Build a linear range covering [lo, hi] with the given default and step.

Provided so call sites can be explicit about the linear case alongside the shaped factories below.

◆ normalize()

float pulp::state::ParamRange::normalize ( float value) const
inline

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

Parameters
valueRaw parameter value in [min, max].
Returns
Normalized value clamped to [0, 1].

◆ with_center()

ParamRange pulp::state::ParamRange::with_center ( float lo,
float hi,
float center,
float def = 0.0f,
float step_value = 0.0f )
inlinestatic

Build a shaped range whose normalized midpoint (0.5) maps to center.

Equivalent to choosing the skew that satisfies denormalize(0.5) == center. Falls back to a linear range when center is not strictly inside the open interval (min, max).

Member Data Documentation

◆ default_value

float pulp::state::ParamRange::default_value = 0.0f

◆ max

float pulp::state::ParamRange::max = 1.0f

◆ min

float pulp::state::ParamRange::min = 0.0f

◆ skew

float pulp::state::ParamRange::skew = 1.0f

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

◆ step

float pulp::state::ParamRange::step = 0.0f

Quantization step. 0 = continuous.

◆ symmetric_skew

bool pulp::state::ParamRange::symmetric_skew = false

Mirror the curve around the center (bipolar).


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