RandomMod

Contains classes to generate samples of a Random Function real-time. Smoothness of the function and a characteristic timescale (How quickly the function varies) can be adjusted.

Scale can be adjusted smoothly, while smoothness will generate a discontinuity in the function.

Usage

Derived RandomLFOSingle supports a lower output sample rate:

RandomLFOSingle rlfo;
rlfo.init(44100.0f, 1.0);
rlfo.setOutFreq(1000.0f);
rlfo.seed(0);
rlfo.setScale(1.0f);
rlfo.setSmoothness(2.0f);

for(int i=0; i< num_audio_samples;i++){
  //Gives samples at frequency of out_freq.
  if (rlfo.processSingle(&tmp))
    doSomething(tmp);
}

Base class RandomLFO can be used to generate one sample for each audio sample:

RandomLFO rlfo;
rlfo.init(44100.0f, 1.0);

rlfo.seed(0);
rlfo.setScale(1.0f);
rlfo.setSmoothness(2.0f);

float buf [64];
rlfo.generateSamples(buf, 64 );

Theory

The classes outputs samples of a so called Gaussian Process using a Matern covariance function. Scale corresponds to the length-scale of the Matern covariance function (p) and smoothness corresponds to v - 0.5 for smoothness =0,1,2. For smoothness > 2, v = inf.

Algorithm

Samples of a Gaussian Process is generated by convolving gaussian white noise samples, using the covariance function as the FIR.

The FIR should be normalized by the sum square of its samples. This will give the same variance as the input white-noise.