synthesizer-core-0.8.1: Audio signal processing coded in Haskell: Low level part

Copyright(c) Henning Thielemann 2006
LicenseGPL
Maintainersynthesizer@henning-thielemann.de
Stabilityprovisional
Portabilityrequires multi-parameter type classes
Safe HaskellNone
LanguageHaskell2010

Synthesizer.Plain.Oscillator

Contents

Description

Tone generators

Frequencies are always specified in ratios of the sample rate, e.g. the frequency 0.01 for the sample rate 44100 Hz means a physical frequency of 441 Hz.

Synopsis

Documentation

type Phase a = a Source #

Oscillators with arbitrary but constant waveforms

static :: C a => T a b -> Phase a -> a -> T b Source #

oscillator with constant frequency

freqMod :: C a => T a b -> Phase a -> T a -> T b Source #

oscillator with modulated frequency

phaseMod :: C a => T a b -> a -> T (Phase a) -> T b Source #

oscillator with modulated phase

shapeMod :: C a => (c -> T a b) -> Phase a -> a -> T c -> T b Source #

oscillator with modulated shape

phaseFreqMod :: C a => T a b -> T (Phase a) -> T a -> T b Source #

oscillator with both phase and frequency modulation

shapeFreqMod :: C a => (c -> T a b) -> Phase a -> T c -> T a -> T b Source #

oscillator with both shape and frequency modulation

staticSample :: C a => T a b -> [b] -> Phase a -> a -> T b Source #

oscillator with a sampled waveform with constant frequency This is essentially an interpolation with cyclic padding.

freqModSample :: C a => T a b -> [b] -> Phase a -> T a -> T b Source #

oscillator with a sampled waveform with modulated frequency Should behave homogenously for different types of interpolation.

shapeFreqModSample :: (C c, C b) => T c (T b a) -> [T b a] -> c -> Phase b -> T c -> T b -> T a Source #

Shape control is a list of relative changes, each of which must be non-negative in order to allow lazy processing. '1' advances by one wave. Frequency control can be negative. If you want to use sampled waveforms as well then use sample in the list of waveforms. With sampled waves this function is identical to HunkTranspose in Assampler.

Example: interpolate different versions of oddCosine and oddTriangle.

You could also chop a tone into single waves and use the waves as input for this function but you certainly want to use sampledTone or shapeFreqModFromSampledTone instead, because in the wave information for shapeFreqModSample shape and phase are strictly separated.

shapePhaseFreqModSample :: (C c, C b) => T c (T b a) -> [T b a] -> c -> T c -> T (Phase b) -> T b -> T a Source #

shapeFreqModFromSampledTone :: C t => T t y -> T t y -> t -> T y -> t -> t -> T t -> T t -> T y Source #

Time stretching and frequency modulation of a pure tone.

We consider a tone as the result of a shape modulated oscillator, and virtually reconstruct the waveform function (a function of time and phase) by interpolation and resample it. This way we can alter frequency and time progress of the tone independently.

This function is identical to using shapeFreqMod with a wave function constructed by sampledTone but it consumes the sampled source tone lazily and thus allows only relative shape control with non-negative control steps.

The function is similar to shapeFreqModSample but respects that in a sampled tone, phase and shape control advance synchronously. Actually we could re-use shapeFreqModSample with modified phase values. But we would have to cope with negative shape control jumps, and waves would be padded locally cyclically. The latter one is not wanted since we want padding according to the adjacencies in the source tone. Note that differently from shapeFreqModSample the shape control difference 1 does not mean to skip to the next wave, since this oscillator has no discrete waveforms. Instead 1 means that the shape alters as fast as in the prototype signal.

Although the shape difference values must be non-negative I hesitate to give them the type Number.NonNegative.T t because then you cannot call this function with other types of non-negative numbers like T.

The prototype tone signal is reproduced if freqs == repeat (1/period) and shapes == repeat 1.

shapePhaseFreqModFromSampledTone :: C t => T t y -> T t y -> t -> T y -> t -> t -> T t -> T t -> T t -> T y Source #

Oscillators with specific waveforms

staticSine :: (C a, C a) => a -> a -> T a Source #

sine oscillator with static frequency

freqModSine :: (C a, C a) => a -> T a -> T a Source #

sine oscillator with modulated frequency

phaseModSine :: (C a, C a) => a -> T a -> T a Source #

sine oscillator with modulated phase, useful for FM synthesis

staticSaw :: C a => a -> a -> T a Source #

saw tooth oscillator with modulated frequency

freqModSaw :: C a => a -> T a -> T a Source #

saw tooth oscillator with modulated frequency