Safe Haskell | Safe |
---|---|

Language | Haskell98 |

Interpolation functions, ie. for envelope segments.

- type Interpolation_F t = t -> t -> t -> t
- interpolate :: (Num t, Ord t) => Interpolation_F t -> (t, t) -> t -> t
- step :: Interpolation_F t
- linear :: Num t => Interpolation_F t
- exponential :: Floating t => Interpolation_F t
- exponential' :: (Eq t, Floating t) => Interpolation_F t
- exponential'' :: (Eq t, Floating t) => Interpolation_F t
- sine :: Floating t => Interpolation_F t
- welch :: (Ord t, Floating t) => Interpolation_F t
- curve :: (Ord t, Floating t) => t -> Interpolation_F t
- squared :: Floating t => Interpolation_F t
- cubed :: Floating t => Interpolation_F t
- hold :: (Num t, Ord t) => Interpolation_F t

# Documentation

type Interpolation_F t = t -> t -> t -> t Source #

An interpolation function takes three arguments. *x0* is the left
or begin value, *x1* is the right or end value, and *t* is a (0,1)
index.

interpolate :: (Num t, Ord t) => Interpolation_F t -> (t, t) -> t -> t Source #

Clip *x* to (0,1) and run *f*.

interpolate linear (-1,1) 0.5 == 0

step :: Interpolation_F t Source #

Step function, ignores *t* and returns *x1*.

linear :: Num t => Interpolation_F t Source #

Linear interpolation.

import Sound.SC3.Plot {- hsc3-plot -} plotTable1 (map (linear (-1) 1) [0,0.01 .. 1])

exponential :: Floating t => Interpolation_F t Source #

Exponential interpolation, *x0* must not be `0`

, (*x0*,*x1*) must
not span `0`

.

plotTable1 (map (exponential 0.001 1) [0,0.01 .. 1])

exponential' :: (Eq t, Floating t) => Interpolation_F t Source #

Variant that allows *x0* to be `0`

, though (*x0*,*x1*) must not
span `0`

.

plotTable1 (map (exponential' 0 1) [0,0.01 .. 1]) plotTable1 (map (exponential' 0 (-1)) [0,0.01 .. 1])

exponential'' :: (Eq t, Floating t) => Interpolation_F t Source #

`linear`

of `exponential'`

, ie. allows (*x0*,*x1*) to span `0`

.

plotTable1 (map (exponential'' (-1) 1) [0,0.01 .. 1])

sine :: Floating t => Interpolation_F t Source #

`linear`

with *t* transformed by sine function over (-pi*2,pi*2).

plotTable1 (map (sine (-1) 1) [0,0.01 .. 1])

welch :: (Ord t, Floating t) => Interpolation_F t Source #

If *x0* `<`

*x1* rising sine segment (0,pi/2), else falling
segment (pi/2,pi).

plotTable1 (map (welch (-1) 1) [0,0.01 .. 1]) plotTable1 (map (welch 1 (-1)) [0,0.01 .. 1])

curve :: (Ord t, Floating t) => t -> Interpolation_F t Source #

Curvature controlled by single parameter *c*. `0`

is `linear`

,
increasing *c* approaches `exponential`

.

plotTable (map (\c-> map (curve c (-1) 1) [0,0.01 .. 1]) [-6,-4 .. 6])

squared :: Floating t => Interpolation_F t Source #