summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-06-21 20:45:31 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-06-21 20:46:05 +0200
commitdddd66c3f827ef38ed27ef12e22806b7aee880b4 (patch)
tree341c7cdc5a7ba2d4f6873dc089542d57496bfe88
parentb354971344fbeaf3ca4061910796dee38b7ae025 (diff)
downloadtrivmix-dddd66c3f827ef38ed27ef12e22806b7aee880b4.tar
trivmix-dddd66c3f827ef38ed27ef12e22806b7aee880b4.tar.gz
trivmix-dddd66c3f827ef38ed27ef12e22806b7aee880b4.tar.bz2
trivmix-dddd66c3f827ef38ed27ef12e22806b7aee880b4.tar.xz
trivmix-dddd66c3f827ef38ed27ef12e22806b7aee880b4.zip
Fixed db/lin conversion
-rw-r--r--src/Trivmix/Types.hs8
-rw-r--r--trivmix.cabal2
-rw-r--r--trivmix.nix2
3 files changed, 6 insertions, 6 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
44withResolution f = withType (f . resolution) 44withResolution f = withType (f . resolution)
45 45
46linToDb :: Float -> Float 46linToDb :: Float -> Float
47linToDb x = 10 ** (0.05 * x) 47linToDb x = 20 * (logBase 10 x)
48 48
49dBToLin :: Float -> Float 49dBToLin :: Float -> Float
50dBToLin x = 20 * (logBase 10 x) 50dBToLin x = 10 ** (0.05 * x)
51 51
52instance Show Level where 52instance 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
58instance Read Level where 58instance 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
diff --git a/trivmix.cabal b/trivmix.cabal
index 3f3da68..9b2d723 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
4name: trivmix 4name: trivmix
5version: 2.5.4 5version: 2.5.5
6-- synopsis: 6-- synopsis:
7-- description: 7-- description:
8license: PublicDomain 8license: PublicDomain
diff --git a/trivmix.nix b/trivmix.nix
index 35aa4f1..1e329ab 100644
--- a/trivmix.nix
+++ b/trivmix.nix
@@ -6,7 +6,7 @@
6 6
7cabal.mkDerivation (self: { 7cabal.mkDerivation (self: {
8 pname = "trivmix"; 8 pname = "trivmix";
9 version = "2.5.4"; 9 version = "2.5.5";
10 src = ./.; 10 src = ./.;
11 isLibrary = true; 11 isLibrary = true;
12 isExecutable = true; 12 isExecutable = true;