{-# LANGUAGE NoImplicitPrelude #-}
module Synthesizer.Basic.Filter.NonRecursive where
import qualified Data.List.Match as Match
import Data.Tuple.HT (sortPair, )
import qualified Algebra.Transcendental as Trans
import qualified Algebra.Additive as Additive
import NumericPrelude.Numeric
import NumericPrelude.Base
unitSizesFromPyramid :: [signal] -> [Int]
unitSizesFromPyramid pyr =
reverse $ Match.take pyr $ iterate (2*) 1
sumRangePrepare :: (Additive.C v) =>
((Int,Int) -> source -> v) ->
(source -> (Int,Int) -> v)
sumRangePrepare f pyr (l,r) =
case compare l r of
LT -> f (l,r) pyr
GT -> negate $ f (r,l) pyr
EQ -> zero
symmetricRangePrepare ::
((Int,Int) -> source -> v) ->
(source -> (Int,Int) -> v)
symmetricRangePrepare f pyr lr = f (sortPair lr) pyr
ratioFreqToVariance :: (Trans.C a) => a -> a -> a
ratioFreqToVariance ratio freq =
sqrt (-2 * log ratio) / (2*pi*freq)