{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Synthesizer.Plain.Filter.Recursive where
import qualified Algebra.Module as Module
import qualified Algebra.Additive as Additive
import NumericPrelude.Numeric
import NumericPrelude.Base
data Pole a =
Pole {poleResonance :: !a
, poleFrequency :: !a }
deriving (Eq, Show, Read)
instance Additive.C v => Additive.C (Pole v) where
zero = Pole zero zero
(+) (Pole yr yf) (Pole xr xf) = Pole (yr + xr) (yf + xf)
(-) (Pole yr yf) (Pole xr xf) = Pole (yr - xr) (yf - xf)
negate (Pole xr xf) = Pole (negate xr) (negate xf)
instance Module.C a v => Module.C a (Pole v) where
s *> (Pole xr xf) = Pole (s *> xr) (s *> xf)
data Passband = Lowpass | Highpass
deriving (Show, Eq, Enum)