packages feed

synthesizer-core-0.4.1: src/Synthesizer/Causal/Analysis.hs

{-# LANGUAGE NoImplicitPrelude #-}
module Synthesizer.Causal.Analysis where

import qualified Synthesizer.Causal.Filter.Recursive.Integration as Integration

import qualified Synthesizer.Causal.Process as Causal
import qualified Synthesizer.Plain.Analysis as Ana

import qualified Algebra.RealRing              as RealRing

import Control.Arrow (second, (^<<), (<<^), )

-- import qualified Prelude as P
import NumericPrelude.Base
import NumericPrelude.Numeric


deltaSigmaModulation ::
   RealRing.C y => Causal.T y Ana.BinaryLevel
deltaSigmaModulation =
   Causal.feedback
      ((Ana.binaryLevelFromBool . (zero <=)) ^<<
       Integration.run <<^
       uncurry (-))
      (Causal.consInit zero <<^ Ana.binaryLevelToNumber)

deltaSigmaModulationPositive ::
   RealRing.C y => Causal.T (y, y) y
deltaSigmaModulationPositive =
   Causal.feedback
      ((\(threshold,xi) -> if threshold<=xi then threshold else zero) ^<<
       second Integration.run <<^
       (\((threshold,xi),cum) -> (threshold,xi-cum)))
      (Causal.consInit zero)