Skip to main content

Module parameter_range

Module parameter_range 

Source
Expand description

Range mapping for parameter normalization.

This module provides traits and implementations for mapping between plain parameter values (in natural units like Hz, dB, ms) and normalized values (0.0 to 1.0) used for host communication.

§Available Mappers

  • LinearMapper - Simple linear interpolation (most parameters)
  • LogMapper - Logarithmic mapping for positive ranges (Hz)
  • PowerMapper - Power curve for non-linear UI feel (dB thresholds)
  • LogOffsetMapper - Logarithmic mapping for ranges including negatives

§Example

use beamer_core::parameter_range::{RangeMapper, LinearMapper, LogMapper, PowerMapper};

// Linear mapping for most parameters
let linear = LinearMapper::new(0.0..=100.0);
assert_eq!(linear.normalize(50.0), 0.5);
assert_eq!(linear.denormalize(0.5), 50.0);

// Logarithmic mapping for frequency parameters (positive ranges only)
let log = LogMapper::new(20.0..=20000.0);
// 632 Hz is roughly the geometric mean of 20 and 20000
assert!((log.denormalize(0.5) - 632.0).abs() < 1.0);

// Power curve for threshold parameters (more resolution at max)
let power = PowerMapper::new(-60.0..=0.0, 2.0);
// With exponent 2.0, slider midpoint is closer to 0 dB than -30 dB

Structs§

LinearMapper
Linear range mapping.
LogMapper
Logarithmic range mapping.
LogOffsetMapper
Logarithmic range mapping with offset for negative ranges.
PowerMapper
Power curve range mapping.

Traits§

RangeMapper
Trait for mapping between plain values and normalized values.