```{-# OPTIONS -fno-implicit-prelude #-}
{- |
<http://en.wikipedia.org/wiki/Particle_displacement>
-}
module Synthesizer.Generic.Displacement where

import qualified Synthesizer.Generic.Signal as SigG
import qualified Synthesizer.Generic.SampledValue as Sample

-- import qualified Prelude as P
import PreludeBase
import NumericPrelude

{- * Mixing -}

{-| Mix two signals.
In opposition to 'zipWith' the result has the length of the longer signal. -}
mix :: (Additive.C v, Sample.C v, SigG.C sig) =>
sig v -> sig v -> sig v
mix = SigG.mix

{- relict from Prelude98's Num
mixMono :: Ring.C a => [a] -> [a] -> [a]
mixMono [] x  = x
mixMono x  [] = x
mixMono (x:xs) (y:ys) = x+y : mixMono xs ys
-}

{-| Mix an arbitrary number of signals. -}
mixMulti :: (Additive.C v, Sample.C v, SigG.C sig) =>
[sig v] -> sig v
mixMulti = foldl mix SigG.empty

{-| Add a number to all of the signal values.
This is useful for adjusting the center of a modulation. -}
raise :: (Additive.C v, Sample.C v, SigG.C sig) =>
v -> sig v -> sig v
raise x = SigG.map ((+) x)

{- * Distortion -}
{- |
In "Synthesizer.Basic.Distortion" you find a collection
of appropriate distortion functions.
-}
distort :: (Sample.C c, Sample.C v, SigG.C sig) =>
(c -> v -> v) -> sig c -> sig v -> sig v
distort = SigG.zipWith
```