Skip to Content
Soundor Components
Utils

Formatters and parsers

Show and read values in percent, Hz, dB, ms, and pan.

formatters and parsers are exported from @soundor/components; @soundor/components/chart re-exports formatters. Pass them as the format and parse props of Knob and the other range controls, or use them in your own displays. Negative numbers use a true minus sign (−).

formatters

Each takes a number and returns a string.

FormatterInputOutput
formatters.percent0.550%
formatters.frequency440, 2500440 Hz, 2.50 kHz
formatters.decibels-6−6.0 dB
formatters.timemilliseconds: 250, 1500250 ms, 1.50 s
formatters.pan-0.5, 0L 50, C

parsers

Each takes typed text and returns a number, or null when it cannot read it.

ParserAcceptsResult
parsers.number12, −3.5, 2k, 2 kHz, 1.5 s, 250 ms, -6 dB, 50%The number, with k, kHz and s multiplied by 1000 and % divided by 100. Hz, ms and dB are accepted and kept as typed. A comma may be the decimal mark.
parsers.panL 30, R 12, -30, C-0.3, 0.12, -0.3, 0
import { formatters, parsers } from '@soundor/components';

<ValueField
  parameter={parameters.pan}
  format={formatters.pan}
  parse={parsers.pan}
/>;

On this page