Normalized Range Mapper
A Rust helper than maps ranges of values to and from the normalized range [0.0, 1.0] using various gradients, useful for DSP applications.
(currently in beta)
Gradient Types
LinearMap
- Linear mapping. This can use either generic or decibel units.PowerMap
- Exponential mapping where the normalized value is raised to the supplied exponent. This can use either generic or decibel units.Log2Map
- Logarithmic mapping usinglog2
. This is useful for frequency (Hz) values.Discrete
- Discreteisize
integer mapping. A supplied enum may also be used as well as long as it implementsFrom<isize> + Into<isize> + Copy + Clone
. This mapper has methods for converting to and from either float values orisize
/enum
values.
Installation
Add normal_map
as a dependency in your Cargo.toml
:
= 0.2
Example
// Import normal mappers that use internal f32 values.
// (f64 is available as well)
use *;
// Linear mapper
let lin_map = new;
assert!;
assert!;
// Efficiently map an array/slice of values.
let in_normals = ;
let mut out_values = ;
lin_map.denormalize_array;
// Generic type for any mapper
let normal_map = ;
assert!;