Odcblock
INSTRUMENT design -- DC-blocking filter object
Based in a design from Perry Cook and Gary Scavone's
Synthesis ToolKit (STK),
the Odcblock object is a simple one-pole/one-zero filter
set to remove a DC (0 Hz) offset component in the output signal.
The recursive filter equation used for this object is:
y[n] = x[n] - x[n-1] + 0.99*y[n-1]
where y[n] and y[n-1] are the current and previous
outputs of the equation, respectively, and x[n] and
x[n-1] are the current and previous sample inputs to the filter
equation.
This object is very useful in cases where the output of a signal-processing
or synthesis algorithm may not necessarily be symmetrical around
0.0. Many physical-modelling algorithms use this filter.
Constructors
Odcblock()
-
builds the object.
Access Methods
float Odcblock::next(float input)
-
returns the current output of the filter. input is
the current input to the filter.
float Odcblock::last()
-
returns the previous output from the filter.
void Odcblock::clear()
-
will reinitialize the filter by setting the 'past history' of this
recursive filter (both past inputs and past outputs) to 0.0.
Examples
#include <Ougens.h>
Odcblock *theBlocker;
int MYINSTRUMENT::init(float p[], int n_args)
{
...
theBlocker = new Odcblock();
...
}
int MYINSTRUMENT::run()
{
float out[2];
float sample;
...
for (int i = 0; i < framesToRun(); i++)
{
sample = someSampleGeneratingProcess();
out[0] = theBlocker->next(sample);
}
...
}
See Also