From dddd66c3f827ef38ed27ef12e22806b7aee880b4 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 21 Jun 2015 20:45:31 +0200 Subject: Fixed db/lin conversion --- src/Trivmix/Types.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Trivmix/Types.hs') diff --git a/src/Trivmix/Types.hs b/src/Trivmix/Types.hs index 9822449..874eb42 100644 --- a/src/Trivmix/Types.hs +++ b/src/Trivmix/Types.hs @@ -44,23 +44,23 @@ withResolution :: (HasResolution a) => (Integer -> f a) -> f a withResolution f = withType (f . resolution) linToDb :: Float -> Float -linToDb x = 10 ** (0.05 * x) +linToDb x = 20 * (logBase 10 x) dBToLin :: Float -> Float -dBToLin x = 20 * (logBase 10 x) +dBToLin x = 10 ** (0.05 * x) instance Show Level where show (Lin x) = show x show (DB x) = (show $ (withPrec x' :: Milli)) ++ "dB" where - x' = dBToLin x + x' = linToDb x instance Read Level where readsPrec i = map toL . readsPrec i where toL :: (Float, String) -> (Level, String) toL (f, str) - | ((==) `on` CI.mk) prec unit = (DB $ linToDb f, rest) + | ((==) `on` CI.mk) prec unit = (DB $ dBToLin f, rest) | otherwise = (Lin f, str) where prec = take lU str -- cgit v1.2.3