Add DC Filter at the output #61

pull/1/head
asb2m10 8 years ago
parent b2a81f7da6
commit b9400cf51e
  1. 16
      Source/PluginFx.cpp
  2. 4
      Source/PluginFx.h

@ -81,6 +81,10 @@ void PluginFx::init(int sr) {
pCutoff = -1; pCutoff = -1;
pReso = -1; pReso = -1;
dc_r = 1.0-(126.0/sr);
dc_id = 0;
dc_od = 0;
} }
inline float PluginFx::NR24(float sample,float g,float lpc) { inline float PluginFx::NR24(float sample,float g,float lpc) {
@ -97,6 +101,18 @@ inline float PluginFx::NR(float sample, float g) {
} }
void PluginFx::process(float *work, int sampleSize) { void PluginFx::process(float *work, int sampleSize) {
// very basic DC filter
float t_fd = work[0];
work[0] = work[0] - dc_id + dc_r * dc_od;
dc_id = t_fd;
for (int i=1; i<sampleSize; i++) {
t_fd = work[i];
work[i] = work[i] - dc_id + dc_r * work[i-1];
dc_id = t_fd;
}
dc_od = work[sampleSize-1];
if ( uiGain != 1 ) { if ( uiGain != 1 ) {
for(int i=0; i < sampleSize; i++ ) for(int i=0; i < sampleSize; i++ )
work[i] *= uiGain; work[i] *= uiGain;

@ -55,6 +55,10 @@ class PluginFx {
float rcor,rcorInv; float rcor,rcorInv;
int R; int R;
float dc_id;
float dc_od;
float dc_r;
public: public:
PluginFx(); PluginFx();

Loading…
Cancel
Save