Value-range mapping helpers.
More...
|
| 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).
|
Value-range mapping helpers.
◆ 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
-
| v | Input value. |
| in_lo | Input range low. |
| in_hi | Input range high. |
| out_lo | Output range low. |
| out_hi | Output 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
-
| v | Input value. |
| in_lo | Input range low. |
| in_hi | Input range high (must differ from in_lo). |
| out_lo | Output range low. |
| out_hi | Output 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
-
| v | Input value. |
| in_lo | Input range low. |
| in_hi | Input range high. |
| out_lo | Output range low. |
| out_hi | Output range high. |
- Returns
- Mapped value, or out_lo when the input range collapses to a point.