Expand description
Parameter value formatting and parsing.
This module provides the Formatter enum for converting between
plain parameter values and display strings. Each formatter variant
handles a specific unit type (dB, Hz, ms, etc.) with appropriate
formatting and parsing logic.
§Design
The formatter separates value formatting from unit strings:
text()returns the bare value without units (e.g., “440”, “-6.0”)unit()returns the unit string (e.g., “Hz”, “dB”)- The host/UI combines them for display (e.g., “440 Hz”, “-6.0 dB”)
This separation allows proper VST3/AU parameter info where the units field is separate from the formatted value string.
§Example
ⓘ
use beamer_core::parameter_format::Formatter;
let db_formatter = Formatter::Decibel { precision: 1 };
assert_eq!(db_formatter.text(1.0), "0.0"); // Value only
assert_eq!(db_formatter.unit(), "dB"); // Unit separately
let hz_formatter = Formatter::Frequency;
assert_eq!(hz_formatter.text(440.0), "440");
assert_eq!(hz_formatter.text(1500.0), "1.50k"); // Auto-scaled with SI prefix
assert_eq!(hz_formatter.unit(), "Hz");Enums§
- Formatter
- Parameter value formatter.