diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-21 18:00:34 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-21 18:00:34 +0200 |
commit | c683c73c489243e869b39888a37be827599d6879 (patch) | |
tree | 514fdf44a16d9f1a54569476910db6e09dc39787 | |
parent | 459e5043f730ae00d7d78e08b57ce56238e3a264 (diff) | |
download | trivmix-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
-rw-r--r-- | src/Trivmix.hs | 7 | ||||
-rw-r--r-- | trivmix.cabal | 2 | ||||
-rw-r--r-- | trivmix.nix | 2 |
3 files changed, 8 insertions, 3 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 | ||
diff --git a/trivmix.cabal b/trivmix.cabal index e6dcc3b..92388cc 100644 --- a/trivmix.cabal +++ b/trivmix.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: trivmix | 4 | name: trivmix |
5 | version: 2.4.3 | 5 | version: 2.4.4 |
6 | -- synopsis: | 6 | -- synopsis: |
7 | -- description: | 7 | -- description: |
8 | license: PublicDomain | 8 | license: PublicDomain |
diff --git a/trivmix.nix b/trivmix.nix index ec065eb..7f8d665 100644 --- a/trivmix.nix +++ b/trivmix.nix | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | cabal.mkDerivation (self: { | 7 | cabal.mkDerivation (self: { |
8 | pname = "trivmix"; | 8 | pname = "trivmix"; |
9 | version = "2.4.3"; | 9 | version = "2.4.4"; |
10 | src = ./.; | 10 | src = ./.; |
11 | isLibrary = false; | 11 | isLibrary = false; |
12 | isExecutable = true; | 12 | isExecutable = true; |