From c683c73c489243e869b39888a37be827599d6879 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 21 Jun 2015 18:00:34 +0200 Subject: Show instance for level now has fixed precision for dB --- src/Trivmix.hs | 7 ++++++- trivmix.cabal | 2 +- 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 data Level = Lin Float | DB Float +fixedPrecision :: (RealFrac a, Num a) => a -> a +fixedPrecision x = (fromInteger $ round $ p * x) / p + where + p = 1e3 + instance Show Level where show (Lin x) = show x - show (DB x) = (show x') ++ "dB" + show (DB x) = (show $ fixedPrecision x') ++ "dB" where x' = 20 * (logBase 10 x) diff --git a/trivmix.cabal b/trivmix.cabal index e6dcc3b..92388cc 100644 --- a/trivmix.cabal +++ b/trivmix.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: trivmix -version: 2.4.3 +version: 2.4.4 -- synopsis: -- description: license: PublicDomain diff --git a/trivmix.nix b/trivmix.nix index ec065eb..7f8d665 100644 --- a/trivmix.nix +++ b/trivmix.nix @@ -6,7 +6,7 @@ cabal.mkDerivation (self: { pname = "trivmix"; - version = "2.4.3"; + version = "2.4.4"; src = ./.; isLibrary = false; isExecutable = true; -- cgit v1.2.3