You can get an HPF for example by subtracting the LPF signal from the original signal:
Code: Select all
testLPF.setFc(40.0 / sampleRate);
output = output - testLPF.processSample(output);
Here's his code exactly copied over to Juce format:
Code: Select all
#ifndef OnePole_h
#define OnePole_h
#include <JuceHeader.h>
class OnePole {
public:
OnePole() { a0 = 1.0; b1 = 0.0; z1 = 0.0; };
OnePole(double Fc) { z1 = 0.0; setFc(Fc); };
//~OnePole();
void setFc(double Fc);
void setFc_HPF(double Fc);
void setInitialValue(double initial_z1);
double process(double in);
protected:
double a0, b1, z1;
};
inline void OnePole::setInitialValue(double initial_z1) {
z1 = initial_z1;
}
inline void OnePole::setFc(double Fc) {
b1 = exp(-2.0 * MathConstants<float>::pi * Fc);
a0 = 1.0 - b1;
}
inline void OnePole::setFc_HPF(double Fc) {
b1 = -exp(-2.0 * MathConstants<float>::pi * (0.5 - Fc));
a0 = 1.0 + b1;
}
inline double OnePole::process(double in) {
return z1 = in * a0 + z1 * b1;
}
#endif
https://www.earlevel.com/main/2012/12/1 ... le-filter/
That's exactly what I did for setting the coefficients for a high pass in "setFc_HPF" but it doesn't actually work.It’s trivial to add one-pole highpass response, if you’d like—just negate the lowpass calculation; this inverts the spectrum, so you’ll need to flip the frequency range by subtracting Fc from 0.5:
b1 = -exp(-2.0 * M_PI * (0.5 - Fc));
a0 = 1.0 + b1;
Any idea why or what the error is? It's just frustrating to not have it working.
Thanks.