mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
42 lines
973 B
C++
42 lines
973 B
C++
/*******************************************/
|
|
/* DC Blocking Filter */
|
|
/* by Perry R. Cook, 1995-96 */
|
|
/* This guy is very helpful in, uh, */
|
|
/* blocking DC. Needed because a simple */
|
|
/* low-pass reflection filter allows DC */
|
|
/* to build up inside recursive */
|
|
/* structures. */
|
|
/*******************************************/
|
|
|
|
#include "DCBlock.h"
|
|
|
|
DCBlock :: DCBlock()
|
|
{
|
|
inputs = (MY_FLOAT *) malloc(MY_FLOAT_SIZE);
|
|
outputs = (MY_FLOAT *) malloc(MY_FLOAT_SIZE);
|
|
this->clear();
|
|
|
|
}
|
|
|
|
DCBlock :: ~DCBlock()
|
|
{
|
|
free(inputs);
|
|
free(outputs);
|
|
}
|
|
|
|
void DCBlock :: clear()
|
|
{
|
|
outputs[0] = (MY_FLOAT) 0.0;
|
|
inputs[0] = (MY_FLOAT) 0.0;
|
|
lastOutput = (MY_FLOAT) 0.0;
|
|
}
|
|
|
|
MY_FLOAT DCBlock :: tick(MY_FLOAT sample)
|
|
{
|
|
outputs[0] = sample - inputs[0] + ((MY_FLOAT) 0.99 * outputs[0]);
|
|
inputs[0] = sample;
|
|
lastOutput = outputs[0];
|
|
return lastOutput;
|
|
}
|
|
|