utils Class
Item Index
Methods
dB2Ratio
-
i_dB
Converts db values in [-inf, 0] into "gain" values in [0,1] for example, 0 dB yields 1, -6 dB yields .5
Parameters:
-
i_dB
Number
Returns:
gain value 10^(dB/20)
getRequestAnimationFrameFunc
()
Function
Get the requestAnimationFunction
Returns:
the correct version of the requestAnimationFrame funciton for the browser being used
mapconstrain
-
f1
-
f2
-
f1
-
f1
-
x
Maps a domain of numbers [f1, f2] linearly onto a range [t1, t2]
Parameters:
-
f1
Numberfirst endpoint of domain
-
f2
Numbersecond endpoint of domain
-
f1
Numberfirst endpoint of range
-
f1
Numbersecond endpoint of range
-
x
Numbernumber to map
Returns:
result of mapping x (not actually limited to range!)
mtof
-
m
Convert midi note number (can be floating point) to a frequency value
Parameters:
-
m
NumberMIDI note number
Returns:
the frequency of the MIDI note number
nrand
-
m
-
sd
Get a norally distributed random number
Parameters:
-
m
Numbermean
-
sd
Numberstandard deviation
Returns:
normally distributed random number
rational_tanh
-
x
This is a rational function to approximate a tanh-like soft clipper. It is based on the pade-approximation of the tanh function with tweaked coefficients. The function is in the range x=-3..3 and outputs the range y=-1..1. Beyond this range the output must be clamped to -1..1. The first to derivatives of the function vanish at -3 and 3, so the transition to the hard clipped region is C2-continuous. http://stackoverflow.com/questions/6118028/fast-hyperbolic-tangent-approximation-in-javascript.
Parameters:
-
x
Numbernumber to be mapped
Returns:
tanh(x)