summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-06-21 18:00:34 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-06-21 18:00:34 +0200
commitc683c73c489243e869b39888a37be827599d6879 (patch)
tree514fdf44a16d9f1a54569476910db6e09dc39787 /src
parent459e5043f730ae00d7d78e08b57ce56238e3a264 (diff)
downloadtrivmix-c683c73c489243e869b39888a37be827599d6879.tar
trivmix-c683c73c489243e869b39888a37be827599d6879.tar.gz
trivmix-c683c73c489243e869b39888a37be827599d6879.tar.bz2
trivmix-c683c73c489243e869b39888a37be827599d6879.tar.xz
trivmix-c683c73c489243e869b39888a37be827599d6879.zip
Show instance for level now has fixed precision for dB
Diffstat (limited to 'src')
-rw-r--r--src/Trivmix.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs
index 0f84f62..cedc3e3 100644
--- a/src/Trivmix.hs
+++ b/src/Trivmix.hs
@@ -48,9 +48,14 @@ data Options = Options
48 48
49data Level = Lin Float | DB Float 49data Level = Lin Float | DB Float
50 50
51fixedPrecision :: (RealFrac a, Num a) => a -> a
52fixedPrecision x = (fromInteger $ round $ p * x) / p
53 where
54 p = 1e3
55
51instance Show Level where 56instance Show Level where
52 show (Lin x) = show x 57 show (Lin x) = show x
53 show (DB x) = (show x') ++ "dB" 58 show (DB x) = (show $ fixedPrecision x') ++ "dB"
54 where 59 where
55 x' = 20 * (logBase 10 x) 60 x' = 20 * (logBase 10 x)
56 61