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