hsc3-lang-0.12: Haskell SuperCollider Language

Safe HaskellSafe-Inferred

Sound.SC3.Lang.Math.Warp

Description

A warp is a mapping from the space [0,1] to a user defined space [l,r].

Synopsis

Documentation

data W_Direction Source

Warp direction. W_Map is forward, W_Unmap is reverse.

Constructors

W_Map 
W_Unmap 

type Warp t = W_Direction -> t -> tSource

Warp type

w_map :: Warp t -> t -> tSource

Forward warp.

w_unmap :: Warp t -> t -> tSource

Reverse warp.

warpLinear :: Fractional a => a -> a -> Warp aSource

A linear real value map.

 w = LinearWarp(ControlSpec(1,2))
 [0,0.5,1].collect{|n| w.map(n)} == [1,1.5,2]
 map (w_map (warpLinear 1 2)) [0,1/2,1] == [1,3/2,2]
 map (warpLinear (-1) 1 W_Map) [0,1/2,1] == [-1,0,1]

warpExponential :: Floating a => a -> a -> Warp aSource

The left and right must both be non zero and have the same sign.

 w = ExponentialWarp(ControlSpec(1,2))
 [0,0.5,1].collect{|n| w.map(n)} == [1,pow(2,0.5),2]
 map (warpExponential 1 2 W_Map) [0,0.5,1] == [1,2 ** 0.5,2]

warpCosine :: Floating a => a -> a -> Warp aSource

Cosine warp

 w = CosineWarp(ControlSpec(1,2))
 [0,0.25,0.5,0.75,1].collect{|n| w.map(n)}
 map (warpCosine 1 2 W_Map) [0,0.25,0.5,0.75,1]

warpSine :: Floating a => a -> a -> Warp aSource

Sine warp

 map (warpSine 1 2 W_Map) [0,0.25,0.5,0.75,1]

warpFader :: Floating a => Warp aSource

Fader warp. Left and right values are implicitly zero and one.

 map (warpFader W_Map) [0,0.5,1] == [0,0.25,1]

warpDbFader :: (Eq a, Floating a) => Warp aSource

DB fader warp. Left and right values are implicitly negative infinity and zero. An input of 0 gives -180.

 map (round . warpDbFader W_Map) [0,0.5,1] == [-180,-12,0]

warpCurve :: (Ord a, Floating a) => a -> a -> a -> Warp aSource

A curve warp given by a real n.

 w_map (warpCurve (-3) 1 2) 0.25 == 1.5552791692202022
 w_map (warpCurve (-3) 1 2) 0.50 == 1.8175744761936437