{-# LANGUAGE NoImplicitPrelude #-}
module Synthesizer.Causal.Oscillator.Core where
import qualified Synthesizer.Basic.Phase as Phase
import qualified Synthesizer.Causal.Process as Causal
import qualified Synthesizer.State.Signal as Sig
import Control.Arrow ((^<<), (&&&), second, returnA, )
import qualified Algebra.RealRing as RealRing
import NumericPrelude.Numeric
import NumericPrelude.Base
{-# INLINE static #-}
static :: RealRing.C a =>
Phase.T a -> a -> Sig.T (Phase.T a)
static phase freq =
Sig.iterate (Phase.increment freq) phase
{-# INLINE phaseMod #-}
phaseMod :: (RealRing.C a) =>
a -> Causal.T a (Phase.T a)
phaseMod freq =
uncurry Phase.increment ^<<
Causal.feedSnd (static zero freq)
{-# INLINE shapeMod #-}
shapeMod :: (RealRing.C a) =>
Phase.T a -> a -> Causal.T c (c, Phase.T a)
shapeMod phase freq =
Causal.feedSnd (static phase freq)
{-# INLINE freqMod #-}
freqMod :: RealRing.C a =>
Phase.T a -> Causal.T a (Phase.T a)
freqMod =
Causal.scanL (flip Phase.increment)
{-# INLINE freqModSync #-}
freqModSync :: RealRing.C a =>
Phase.T a -> Causal.T a (Phase.T a)
freqModSync =
Causal.crochetL
(\f p0 -> let p1 = Phase.increment f p0 in Just (p1,p1))
{-# INLINE freqModAntiAlias #-}
freqModAntiAlias :: (RealRing.C a) =>
Phase.T a -> Causal.T a (a, Phase.T a)
freqModAntiAlias phase =
returnA &&& freqMod phase
{-# INLINE phaseFreqMod #-}
phaseFreqMod :: (RealRing.C a) =>
Causal.T (a,a) (Phase.T a)
phaseFreqMod =
uncurry Phase.increment ^<<
second (freqMod zero)
{-# INLINE shapeFreqMod #-}
shapeFreqMod :: (RealRing.C a) =>
Phase.T a -> Causal.T (c,a) (c, Phase.T a)
shapeFreqMod phase =
second (freqMod phase)