Operator SDK
Build MIDI processing and UI modes for the Operator device
Loading...
Searching...
No Matches
op::sdk::math Namespace Reference

Value-range mapping helpers. More...

Functions

int32_t map_linear (int32_t v, int32_t in_lo, int32_t in_hi, int32_t out_lo, int32_t out_hi)
 Linearly map v from [in_lo, in_hi] to [out_lo, out_hi].
float map_exp (float v, float in_lo, float in_hi, float out_lo, float out_hi)
 Exponential-curve map (input perceived linearly, output bent toward out_lo).
float map_log (float v, float in_lo, float in_hi, float out_lo, float out_hi)
 Logarithmic-curve map (input perceived linearly, output bent toward out_hi).

Detailed Description

Value-range mapping helpers.

Function Documentation

◆ map_exp()

float op::sdk::math::map_exp ( float v,
float in_lo,
float in_hi,
float out_lo,
float out_hi )
inline

Exponential-curve map (input perceived linearly, output bent toward out_lo).

Useful for frequency, time, or volume controls, where it gives fine resolution near out_lo and coarse steps near out_hi.

Parameters
vInput value.
in_loInput range low.
in_hiInput range high.
out_loOutput range low.
out_hiOutput range high.
Returns
Mapped value, or out_lo when the input range collapses to a point.

◆ map_linear()

int32_t op::sdk::math::map_linear ( int32_t v,
int32_t in_lo,
int32_t in_hi,
int32_t out_lo,
int32_t out_hi )
inline

Linearly map v from [in_lo, in_hi] to [out_lo, out_hi].

Parameters
vInput value.
in_loInput range low.
in_hiInput range high (must differ from in_lo).
out_loOutput range low.
out_hiOutput range high.
Returns
Mapped value, or out_lo when the input range collapses to a point.

◆ map_log()

float op::sdk::math::map_log ( float v,
float in_lo,
float in_hi,
float out_lo,
float out_hi )
inline

Logarithmic-curve map (input perceived linearly, output bent toward out_hi).

Rises quickly and then flattens, so it gives coarse steps near out_lo and fine resolution near out_hi.

Parameters
vInput value.
in_loInput range low.
in_hiInput range high.
out_loOutput range low.
out_hiOutput range high.
Returns
Mapped value, or out_lo when the input range collapses to a point.