{-# LANGUAGE NoImplicitPrelude #-}
module Synthesizer.State.Displacement where
import qualified Synthesizer.State.Signal as Sig
import qualified Algebra.Transcendental as Trans
import qualified Algebra.Ring as Ring
import qualified Algebra.Additive as Additive
import NumericPrelude.Numeric
import NumericPrelude.Base
{-# INLINE mix #-}
mix :: (Additive.C v) => Sig.T v -> Sig.T v -> Sig.T v
mix = Sig.mix
{-# INLINE mixMulti #-}
mixMulti :: (Additive.C v) => [Sig.T v] -> Sig.T v
mixMulti = foldl mix Sig.empty
{-# INLINE raise #-}
raise :: (Additive.C v) => v -> Sig.T v -> Sig.T v
raise x = Sig.map ((+) x)
{-# INLINE distort #-}
distort :: (c -> a -> a) -> Sig.T c -> Sig.T a -> Sig.T a
distort = Sig.zipWith
{-# INLINE mapLinear #-}
mapLinear :: (Ring.C a) =>
a ->
a ->
Sig.T a ->
Sig.T a
mapLinear depth center =
Sig.map (\x -> center*(one+x*depth))
{-# INLINE mapExponential #-}
mapExponential :: (Trans.C a) =>
a ->
a ->
Sig.T a ->
Sig.T a
mapExponential depth center =
let logDepth = log depth
in Sig.map ((center*) . exp . (logDepth*))