pub enum Formatter {
Float {
precision: usize,
},
Decibel {
precision: usize,
},
DecibelDirect {
precision: usize,
min_db: f64,
},
Frequency,
Milliseconds {
precision: usize,
},
Seconds {
precision: usize,
},
Percent {
precision: usize,
},
Pan,
Ratio {
precision: usize,
},
Semitones,
Boolean,
}Expand description
Parameter value formatter.
Defines how plain parameter values are converted to display strings and parsed back from user input.
Variants§
Float
Generic float with configurable precision (e.g., “1.23”).
Decibel
Decibel formatter for gain/level parameters.
Input is linear amplitude (0.0 = silence, 1.0 = unity).
Format: “-12.0”, “-inf” (unit “dB” via unit())
DecibelDirect
Direct decibel formatter where input is already in dB.
Used by FloatParameter::db() where the plain value is stored as dB.
Format: “+12.0”, “-60.0” (unit “dB” via unit())
Fields
Frequency
Frequency formatter with automatic Hz/kHz scaling.
Format: “440”, “1.50k” (unit “Hz” via unit())
Milliseconds
Milliseconds formatter.
Format: “10.0” (unit “ms” via unit())
Seconds
Seconds formatter.
Format: “1.50” (unit “s” via unit())
Percent
Percentage formatter.
Input is 0.0-1.0, display is 0-100.
Format: “75” (unit “%” via unit())
Pan
Pan formatter for stereo position.
Input is -1.0 (left) to +1.0 (right). Display: “L50”, “C”, “R50”
Ratio
Ratio formatter for compressors.
Display: “4.0:1”, “∞:1”
Semitones
Semitones formatter for pitch shifting.
Format: “+12”, “-7”, “0” (unit “st” via unit())
Boolean
Boolean formatter.
Display: “On”, “Off”
Implementations§
Source§impl Formatter
impl Formatter
Sourcepub fn text(&self, value: f64) -> String
pub fn text(&self, value: f64) -> String
Convert a plain value to a display string (without unit).
The interpretation of value depends on the formatter variant:
Decibel: linear amplitude (1.0 = 0 dB)Frequency: HzMilliseconds: msSeconds: sPercent: 0.0-1.0 (displayed as 0-100)Pan: -1.0 to +1.0Ratio: ratio value (4.0 = “4:1”)Semitones: integer semitonesBoolean: >0.5 = On, <=0.5 = Off
Source§impl Formatter
impl Formatter
Sourcepub fn with_precision(self, precision: usize) -> Self
pub fn with_precision(self, precision: usize) -> Self
Return a new Formatter with updated precision.
For formatter variants that have a precision field, this returns
a new formatter with the updated precision. For variants without
precision (e.g., Pan, Boolean, Semitones, Frequency), this
returns self unchanged.
§Example
let formatter = Formatter::DecibelDirect { precision: 1, min_db: -60.0 };
let high_precision = formatter.with_precision(3);
// high_precision is DecibelDirect { precision: 3, min_db: -60.0 }
let pan = Formatter::Pan;
let same_pan = pan.with_precision(2);
// same_pan is still Pan (no precision field)Sourcepub fn supports_precision(&self) -> bool
pub fn supports_precision(&self) -> bool
Check if this formatter variant supports precision customization.
Returns true for variants with a precision field, false otherwise.