diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix.hs | 7 |
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 | ||
49 | data Level = Lin Float | DB Float | 49 | data Level = Lin Float | DB Float |
50 | 50 | ||
51 | fixedPrecision :: (RealFrac a, Num a) => a -> a | ||
52 | fixedPrecision x = (fromInteger $ round $ p * x) / p | ||
53 | where | ||
54 | p = 1e3 | ||
55 | |||
51 | instance Show Level where | 56 | instance 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 | ||