Manual: Convolver

[ javadoc ]

Convolver is an effect that convolves a signal with a kernal. The kernal can be thought of as the impulse response of an audio filter, or simply as a set of weighting coefficients.

[snip java]
// Constructs a Convolver with the kernal k
// that expects buffers of length sigLength passed to process.
Convolver(float[] k, int sigLength)
// convolves signal with the kernal
void process(float[] signal)
// convolves sigLeft and sigRight with the kernal
void process(float[] sigLeft, float[] sigRight)
// Sets the kernal to k.
void setKernal(float[] k)
[/snip]

Convolver performs brute-force convolution, meaning that it is slow, relatively speaking. However, the algorithm is very straightforward. Each output sample i is calculated by multiplying each kernal value j with the input sample i - j and then summing the resulting values. The output will be kernal.length + signal.length - 1 samples long, so the extra samples are stored in an overlap array. The overlap array from the previous signal convolution is added into the beginning of the output array, which results in an output signal without pops.

Code Sample (online example)

[snip code_sample]http://code.compartmental.net/minim/examples/AudioEffect/LowPassConvolve/LowPassConvolve.pde[/snip]

3 thoughts on “Manual: Convolver

  1. Well, the effect isn’t written to do that, so there isn’t a particularly easy way. You could write your own AudioEffect that had two Convolvers in it and then when your effect is given stereo data pass each array to a different convolver using the process(float[]) method of each.

  2. Sorry I never got around to replying, but similar to what you suggested, I ended up modifying the Convolver class and doing stereo inside to make it as fast as possible.