module Synthesizer.Basic.Distortion (
clip, logit,
zigZag, sine,
quantize,
) where
import qualified Algebra.Transcendental as Trans
import qualified Algebra.RealField as RealField
import qualified Algebra.Field as Field
import qualified Algebra.Real as Real
import qualified Algebra.Ring as Ring
import qualified Algebra.Additive as Additive
import Data.Ord.HT (limit, )
import NumericPrelude
clip :: (Real.C a) => a -> a
clip = limit (negate one, one)
logit :: (Trans.C a) => a -> a
logit = tanh
zigZag :: (RealField.C a) => a -> a
zigZag x =
let (n,y) = splitFraction ((x+1)/2)
in if even (n::Int)
then 2*y 1
else 1 2*y
sine :: (Trans.C a) => a -> a
sine = sin
quantize :: (RealField.C a) => a -> a
quantize x = fromIntegral (round x :: Int)