Expand description
Convenience functions for formatting and parsing parameter values in various common formats.
Functions prefixed with v2s_ are meant to be used with the .value_to_string() parameter
functions, while the s2v_ functions are meant to be used wit the .string_to_value().
functions. Most of these formatters come as a pair. Check each formatter’s documentation for any
additional usage information.
Functions§
- s2v_
bool_ bypass - Parse a string in the same format as
v2s_bool_bypass(). - s2v_
compression_ ratio - Parse a
x:ycompression ratio back to a floating point number. Used in conjunction withv2s_compression_ratio(). Plain numbers are parsed directly for UX’s sake. - s2v_
f32_ gain_ to_ db - Parse a decibel value to a linear voltage gain ratio. Handles the
dBordBFSunits for you. Used in conjunction withv2s_f32_gain_to_db().-inf dBwill be parsed to 0.0. - s2v_
f32_ hz_ then_ khz - Convert an input in the same format at that of
v2s_f32_hz_then_khz()to a Hertz value. This additionally also accepts note names in the same format ass2v_i32_note_formatter(), and optionally also with cents in the form ofD#5, -23 ct.. - s2v_
f32_ panning - Parse a pan value in the format of
v2s_f32_panning()to a linear value in the range[-1, 1]. - s2v_
f32_ percentage - Parse a
[0, 100]percentage to a[0, 1]number. Handles the percentage unit for you. Used in conjunction withv2s_f32_percentage(). - s2v_
i32_ note_ formatter - Parse a note name to a MIDI number using the inverse mapping from
v2s_i32_note_formatter(). - s2v_
i32_ power_ of_ two - Parse a parameter input string to a power of two. Useful in conjunction with
v2s_i32_power_of_two()to limit integer parameter ranges to be only powers of two. - v2s_
bool_ bypass - Display ‘Bypassed’ or ‘Not Bypassed’ depending on whether the parameter is true or false. ‘Enabled’ would have also been a possibility here, but that could be a bit confusing.
- v2s_
compression_ ratio - Format a positive number as a compression ratio. A value of 4 will be formatted as
4.0:1while 0.25 is formatted as1:4.0. - v2s_
f32_ gain_ to_ db - Turn an
f32value from voltage gain to decibels using the semantics described inutil::gain_to_db(). You should use either" dB"or" dBFS"for the parameter’s unit.0.0will be formatted as-inf. Avoids returning negative zero values to make sure string->value->string roundtrips work correctly. Otherwise-0.001rounded to two digits would result in-0.00. - v2s_
f32_ hz_ then_ khz - Format a
f32Hertz value as a roundedHzbelow 1000 Hz, and as a roundedkHzvalue above 1000 Hz. This already includes the unit. - v2s_
f32_ hz_ then_ khz_ with_ note_ name v2s_f32_hz_then_khz(), but also includes the note name. Can be used withs2v_f32_hz_then_khz().- v2s_
f32_ panning - Turn an
f32[-1, 1]value to a panning value where negative values are represented by[100L, 1L], 0 gets turned intoC, and positive values become[1R, 100R]values. - v2s_
f32_ percentage - Format a
[0, 1]number as a percentage. Does not include the percent sign, you should specify this as the parameter’s unit. - v2s_
f32_ rounded - Round an
f32value to always have a specific number of decimal digits. Avoids returning negative zero values to make sure string->value->string roundtrips work correctly. Otherwise-0.001rounded to two digits would result in-0.00. - v2s_
i32_ note_ formatter - Turns an integer MIDI note number (usually in the range [0, 127]) into a note name, where 60 is C4 and 69 is A4 (nice).
- v2s_
i32_ power_ of_ two - Format an order/power of two. Useful in conjunction with
s2v_i32_power_of_two()to limit integer parameter ranges to be only powers of two.