Portability | requires multi-parameter type classes |
---|---|

Stability | provisional |

Maintainer | synthesizer@henning-thielemann.de |

- 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
- ratioFreqToVariance :: C a => a -> a -> a
- 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
- inverseFrequencyModulationGen :: (Ord t, C t) => (t -> Bool) -> 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

# Envelope application

amplifyVector :: C a v => a -> T v -> T vSource

# Smoothing

ratioFreqToVariance :: C a => a -> a -> aSource

Compute the variance of the Gaussian
such that its Fourier transform has value `ratio`

at frequency `freq`

.

sums :: C v => Int -> T v -> T vSource

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 vSource

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)

# Filter operators from calculus

differentiate :: C v => T v -> T vSource

Forward difference quotient.
Shortens the signal by one.
Inverts `Synthesizer.State.Filter.Recursive.Integration.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 vSource

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 vSource

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

but `differentiate2`

should be faster.