API Docs for: 0.0.1
Show:

utils Class

Defined in: jsaSndLib\utils.js:15
Module: utils.js

Methods

dB2Ratio

(
  • i_dB
)
Number

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:

Number:

gain value 10^(dB/20)

getRequestAnimationFrameFunc

() Function

Get the requestAnimationFunction

Returns:

Function:

the correct version of the requestAnimationFrame funciton for the browser being used

mapconstrain

(
  • f1
  • f2
  • f1
  • f1
  • x
)
Number

Maps a domain of numbers [f1, f2] linearly onto a range [t1, t2]

Parameters:

  • f1 Number

    first endpoint of domain

  • f2 Number

    second endpoint of domain

  • f1 Number

    first endpoint of range

  • f1 Number

    second endpoint of range

  • x Number

    number to map

Returns:

Number:

result of mapping x (not actually limited to range!)

mtof

(
  • m
)
Number

Convert midi note number (can be floating point) to a frequency value

Parameters:

  • m Number

    MIDI note number

Returns:

Number:

the frequency of the MIDI note number

nrand

(
  • m
  • sd
)
Number

Get a norally distributed random number

Parameters:

  • m Number

    mean

  • sd Number

    standard deviation

Returns:

Number:

normally distributed random number

rational_tanh

(
  • x
)
Number

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 Number

    number to be mapped

Returns:

Number:

tanh(x)