Copyright | (c) Henning Thielemann 2008 |
---|---|

License | GPL |

Maintainer | synthesizer@henning-thielemann.de |

Stability | provisional |

Portability | requires multi-parameter type classes |

Safe Haskell | None |

Language | Haskell2010 |

- amplify :: C a => a -> T a -> T a
- amplifyVector :: C a v => a -> T v -> T v
- envelope :: C a => T a -> T a -> T a
- envelopeVector :: C a v => T a -> T v -> T v
- fadeInOut :: C a => Int -> Int -> Int -> T a -> T a
- generic :: C a v => T a -> T v -> T v
- binomial :: (C a, C a, C a v) => a -> a -> T v -> T v
- binomial1 :: C v => T v -> T v
- sums :: C v => Int -> T v -> T v
- inverseFrequencyModulationFloor :: (Ord t, C t) => T t -> T v -> T v
- inverseFrequencyModulationCeiling :: (Ord t, C t) => T t -> T v -> T v
- differentiate :: C v => T v -> T v
- differentiateCenter :: C v => T v -> T v
- differentiate2 :: C v => T v -> T v

# Documentation

sums :: C v => Int -> T v -> T v Source #

Moving (uniformly weighted) average in the most trivial form.
This is very slow and needs about `n * length x`

operations.

inverseFrequencyModulationFloor :: (Ord t, C t) => T t -> T v -> T v Source #

This is inverse to frequency modulation.
If all control values in `ctrl`

are above one, then it holds:
` frequencyModulation ctrl (inverseFrequencyModulationFloor ctrl xs) == xs `

.
Otherwise `inverseFrequencyModulationFloor`

is lossy.
For the precise property
we refer to Test.Sound.Synthesizer.Plain.Interpolation.
The modulation uses constant interpolation.
Other interpolation types are tricky to implement,
since they would need interpolation on non-equidistant grids.
Ok, at least linear interpolation could be supported
with acceptable effort,
but perfect reconstruction would be hard to get.
The process is not causal in any of its inputs,
however control and input are aligned.

If you use interpolation for resampling or frequency modulation, you may want to smooth the signal before resampling according to the local resampling factor. However you cannot simply use the resampling control to also control the smoothing, because of the subsequent distortion by resampling. Instead you have to stretch the control inversely to the resampling factor. This is the task of this function. It may be applied like:

frequencyModulation ctrl (smooth (inverseFrequencyModulationFloor ctrl ctrl) xs)

differentiate :: C v => T v -> T v Source #

Forward difference quotient.
Shortens the signal by one.
Inverts `run`

in the sense that
`differentiate (zero : integrate x) == x`

.
The signal is shifted by a half time unit.

differentiateCenter :: C v => T v -> T v Source #

Central difference quotient.
Shortens the signal by two elements,
and shifts the signal by one element.
(Which can be fixed by prepending an appropriate value.)
For linear functions this will yield
essentially the same result as `differentiate`

.
You obtain the result of `differentiateCenter`

if you smooth the one of `differentiate`

by averaging pairs of adjacent values.

ToDo: Vector variant

differentiate2 :: C v => T v -> T v Source #

Second derivative.
It is `differentiate2 == differentiate . differentiate`

but `differentiate2`

should be faster.