hsc3-lang-0.15: Haskell SuperCollider Language

Safe HaskellSafe-Inferred
LanguageHaskell98

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 -> t Source

Warp type

w_map :: Warp t -> t -> t Source

Forward warp.

w_unmap :: Warp t -> t -> t Source

Reverse warp.

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

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 a Source

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]
import Sound.SC3.Plot
plotTable1 (map (warpExponential 1 2 W_Map) [0,0.01 .. 1])

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

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]
plotTable1 (map (warpCosine 1 2 W_Map) [0,0.01 .. 1])

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

Sine warp

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

warpFader :: Floating a => a -> a -> Warp a Source

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

map (warpFader 0 1 W_Map) [0,0.5,1] == [0,0.25,1]
plotTable1 (map (warpFader 0 1 W_Map) [0,0.01 .. 1])
plotTable1 (map (warpFader 0 2 W_Map) [0,0.01 .. 1])

warpDbFader :: (TernaryOp a, Eq a, Floating a) => a -> a -> Warp a Source

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

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

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

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
plotTable1 (map (warpCurve (-3) 1 2 W_Map) [0,0.01 .. 1])
plotTable1 (map (warpCurve 9 1 2 W_Map) [0,0.01 .. 1])

warpNamed :: (TernaryOp a, Ord a, Eq a, RealFrac a, Floating a) => String -> Maybe (a -> a -> Warp a) Source

Select warp function by name. Numerical names are interpreted as curve values for warpCurve.

let Just w = warpNamed "lin"
let Just w = warpNamed "-3"
let Just w = warpNamed "6"
plotTable1 (map (w 1 2 W_Map) [0,0.01 .. 1])