diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix/Types.hs | 8 |
1 files changed, 4 insertions, 4 deletions
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 | |||
44 | withResolution f = withType (f . resolution) | 44 | withResolution f = withType (f . resolution) |
45 | 45 | ||
46 | linToDb :: Float -> Float | 46 | linToDb :: Float -> Float |
47 | linToDb x = 10 ** (0.05 * x) | 47 | linToDb x = 20 * (logBase 10 x) |
48 | 48 | ||
49 | dBToLin :: Float -> Float | 49 | dBToLin :: Float -> Float |
50 | dBToLin x = 20 * (logBase 10 x) | 50 | dBToLin x = 10 ** (0.05 * x) |
51 | 51 | ||
52 | instance Show Level where | 52 | instance Show Level where |
53 | show (Lin x) = show x | 53 | show (Lin x) = show x |
54 | show (DB x) = (show $ (withPrec x' :: Milli)) ++ "dB" | 54 | show (DB x) = (show $ (withPrec x' :: Milli)) ++ "dB" |
55 | where | 55 | where |
56 | x' = dBToLin x | 56 | x' = linToDb x |
57 | 57 | ||
58 | instance Read Level where | 58 | instance Read Level where |
59 | readsPrec i = map toL . readsPrec i | 59 | readsPrec i = map toL . readsPrec i |
60 | where | 60 | where |
61 | toL :: (Float, String) -> (Level, String) | 61 | toL :: (Float, String) -> (Level, String) |
62 | toL (f, str) | 62 | toL (f, str) |
63 | | ((==) `on` CI.mk) prec unit = (DB $ linToDb f, rest) | 63 | | ((==) `on` CI.mk) prec unit = (DB $ dBToLin f, rest) |
64 | | otherwise = (Lin f, str) | 64 | | otherwise = (Lin f, str) |
65 | where | 65 | where |
66 | prec = take lU str | 66 | prec = take lU str |