Skip to main content

Module util

Module util 

Source
Expand description

General conversion functions and utilities.

Modules§

window
Windowing functions, useful in conjunction with StftHelper.

Structs§

StftHelper
Process the input buffer in equal sized blocks, running a callback on each block to transform the block and then writing back the results from the previous block to the buffer. This introduces latency equal to the size of the block.

Constants§

MINUS_INFINITY_DB
MINUS_INFINITY_GAIN
NOTES

Functions§

db_to_gain
Convert decibels to a voltage gain ratio, treating anything below -100 dB as minus infinity.
db_to_gain_fast
An approximation of db_to_gain() using exp(). Does not treat values below MINUS_INFINITY_DB as 0.0 gain to avoid branching. As a result this function will thus also never return 0.0 for normal input values. Will run faster on most architectures, but the result may be slightly different.
db_to_gain_fast_branching
db_to_gain_fast(), but this version does truncate values below MINUS_INFINITY_DB to 0.0. Bikeshedding over a better name is welcome.
f32_midi_note_to_freq
The same as midi_note_to_freq(), but for arbitrary note numbers including those outside of the MIDI range. This also supports fractional note numbers, which is useful when working with cents.
freq_to_midi_note
The inverse of f32_midi_note_to_freq(). This returns a fractional note number. Round to a whole number, subtract that from the result, and multiply the fractional part by 100 to get the number of cents.
gain_to_db
Convert a voltage gain ratio to decibels. Gain ratios that aren’t positive will be treated as MINUS_INFINITY_DB.
gain_to_db_fast
An approximation of gain_to_db() using ln(). Will run faster on most architectures, but the result may be slightly different.
gain_to_db_fast_epsilon
db_to_gain_fast(), but the minimum gain value is set to f32::EPSILONinstead of MINUS_INFINITY_GAIN. Useful in conjunction with db_to_gain_fast().
midi_note_to_freq
Convert a MIDI note ID to a frequency at A4 = 440 Hz equal temperament and middle C = note 60 = C4.
permit_alloc
Temporarily allow allocations within func if nice-plug was configured with the assert_process_allocs feature.