module Synthesizer.Basic.DistortionControlled (
clip, logit,
zigZag, sine,
quantize,
) where
import qualified Synthesizer.Basic.Distortion as Dist
import qualified Algebra.Transcendental as Trans
import qualified Algebra.RealField as RealField
import qualified Algebra.Field as Field
import qualified Algebra.RealRing as RealRing
import qualified Algebra.Ring as Ring
import qualified Algebra.Additive as Additive
import Data.Ord.HT (limit, )
import NumericPrelude.Numeric
clip :: (RealRing.C a) => a -> a -> a
clip c = limit (negate c, c)
logit :: (Trans.C a) => a -> a -> a
logit k = rescale k Dist.logit
zigZag :: (RealField.C a) => a -> a -> a
zigZag k = rescale k Dist.zigZag
sine :: (Trans.C a) => a -> a -> a
sine k = rescale k Dist.sine
quantize :: (RealField.C a) => a -> a -> a
quantize k = rescale k Dist.quantize
rescale :: (Field.C a) => a -> (a -> a) -> a -> a
rescale k f x = k * f (x/k)