From 9d2518bb91457fa22bdab7d8000bf3341bed4d12 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 7 Sep 2006 20:51:41 +0200 Subject: [PATCH] Fix wrong scales in linear volume calculation Fixed wrong scales of dB values (TLV is 0.01dB unit) in the linear volume calculation. --- src/mixer/simple_none.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c index c1f45277..58ffe4af 100644 --- a/src/mixer/simple_none.c +++ b/src/mixer/simple_none.c @@ -1091,8 +1091,8 @@ static int do_convert_to_dB(unsigned int *tlv, long rangemin, long rangemax, maxdb; else { /* FIXME: precalculate and cache these values */ - double lmin = pow(10.0, mindb/20.0); - double lmax = pow(10.0, maxdb/20.0); + double lmin = pow(10.0, mindb/2000.0); + double lmax = pow(10.0, maxdb/2000.0); val = (lmax - lmin) * val + lmin; *db_gain = (long)(100.0 * 20.0 * log10(val)); } @@ -1293,9 +1293,9 @@ static int do_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax, /* FIXME: precalculate and cache vmin and vmax */ double vmin, vmax, v; vmin = (min <= SND_CTL_TLV_DB_GAIN_MUTE) ? 0.0 : - pow(10.0, (double)min / 20.0); - vmax = !max ? 1.0 : pow(10.0, (double)max / 20.0); - v = pow(10.0, (double)db_gain / 20.0); + pow(10.0, (double)min / 2000.0); + vmax = !max ? 1.0 : pow(10.0, (double)max / 2000.0); + v = pow(10.0, (double)db_gain / 2000.0); v = (v - vmin) * (rangemax - rangemin) / (vmax - vmin); if (xdir > 0) v = ceil(v); -- 2.47.1