SPKitWaveShaper
User's Guide
SPKitWaveShaper is a waveshaping (a.k.a. non-linear distortion) class.
SPKitWaveShaper is connected to its input with a
setInputAndBuffer(SPKitProcessor* ip, SPKitReader* bufInput)
function,
where ip is the signal input
and bufInput is a pointer to an instance of
SPKitReader
that supplies a transfer function
used by the waveshaping algorithm.
bufInput
will typically supply a short signal containing sweep
starting from a sample value of -1.0 and ending up at a value of 1.0.
SPKitWaveShaper reads signal from bufInput
at initialization time
and stores it in a lookup table.
SPKitWaveShaper processes the input signal
by matching the input sample values with
the values stored in the lookup table.
The input samples are converted to indeces for
the lookup table so that an input sample value of -1.0
is taken to be the index of the first item
and a value of 1.0 is taken to be the index of the last item.
Linear interpolation is used to smooth out
the output signal.
For a more detailed description of waveshaping,
see Dodge & Jerse(1985:128-149).
Programmer's Reference
Defined in <spkit/waveshap.h>
Inherits from SPKitProcessor
SPKitWaveShaper
defines a
setInputAndBuffer(SPKitProcessor* ip, SPKitReader* bufInput)
function
for initializing and connecting
the object to its input
and to a SPKitReader object which
supplies a transformation table.
SPKitWaveShaper also overrides
getSample().
Public Members
- SPKitError
setInputAndBuffer(SPKitProcessor* ip,
SPKitReader* bufInput)
- connect an input to the object and initialize it.
The function initializes the transfer function storage
buffer
by reading it from bufInput.
Calls
SPKitProcessor::setInput().
- int getSample(SPKitSample& outputSample)
- retrieve a processed audio sample
getSample() requests a sample from its input and
calculates a new value from a lookup table
using linear interpolation.
The lookup table is stored in buffer.
The result is stored in outputSample.
The function returns 0 when its input
runs out of samples, 1 otherwise.
Protected Members
- SPKitInt size
- size of buffer
- SPKitInt halfSize
- half the size of buffer
- SPKitSample* buffer
- buffer containing the waveshaping transfer function lookup table
- SPKitSample maxValue
- value of the last item stored in buffer
- SPKitSample minValue
- value of the first item stored in buffer