[chuck-users] Converting dB to chuck .gain

Graham Percival gpermus at gmail.com
Thu Mar 9 01:40:15 EST 2006


On 8-Mar-06, at 9:25 PM, Ge Wang wrote:
>   fun float dbtogain( float db )
>   { return math.pow( 2, db/3 ); }
>
>   fun float gaintodb( float gain )
>   { return 3 * math.log(gain) / math.log(2); }

Thanks, that's great!  Please add these to std, since there's already 
std.dbtorms and std.dbtopow in there.

I'm not certain how those functions are supposed to work, though.  The 
below code gives me "0.000 0.000 / 0.000 0.000".  This is with chuck 
1.2.0.4.

float f1, f2;
0 => f1;
-6 => f2;
std.dbtorms(f1) => f1;
std.dbtorms(f2) => f2;
<<< f1, f2>>>;
0 => f1;
-6 => f2;
std.dbtopow(f1) => f1;
std.dbtopow(f2) => f2;
<<< f1, f2>>>;



More information about the chuck-users mailing list