diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-21 20:45:31 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-21 20:46:05 +0200 |
commit | dddd66c3f827ef38ed27ef12e22806b7aee880b4 (patch) | |
tree | 341c7cdc5a7ba2d4f6873dc089542d57496bfe88 | |
parent | b354971344fbeaf3ca4061910796dee38b7ae025 (diff) | |
download | trivmix-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.hs | 8 | ||||
-rw-r--r-- | trivmix.cabal | 2 | ||||
-rw-r--r-- | trivmix.nix | 2 |
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 | |||
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 |
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 | ||
4 | name: trivmix | 4 | name: trivmix |
5 | version: 2.5.4 | 5 | version: 2.5.5 |
6 | -- synopsis: | 6 | -- synopsis: |
7 | -- description: | 7 | -- description: |
8 | license: PublicDomain | 8 | license: 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 | ||
7 | cabal.mkDerivation (self: { | 7 | cabal.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; |