spencersalazar / chuck

28 stars 8 forks source link

Add dbtogain and gaintodb methods to Std #38

Closed heuermh closed 10 years ago

heuermh commented 10 years ago

From a very old thread on the chuck-users@ email list

https://lists.cs.princeton.edu/pipermail/chuck-users/2006-March/000431.html

fun float dbtogain( float db )
{ return math.pow( 2, db/3 ); }

fun float gaintodb( float gain )
{ return 3 * math.log(gain) / math.log(2); }

Slightly optimized

fun float gaintodb( float gain )
{ return 4.3280851226668906 * math.log(gain); }
spencersalazar commented 10 years ago

I just added linear <-> db (ccrma/chuck@0604f615af19fbe00382389dd059140b7d2db9c4) -- I think this the same thing, at least conceptual if not mathematically.

heuermh commented 10 years ago

Yep, looks great, thanks @spencersalazar