Skip to content

Commit 1ebf181

Browse files
author
Martin Klang
committed
added allpass filter configuration
1 parent 3e5d280 commit 1ebf181

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

LibSource/BiquadFilter.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FilterStage {
2727
setBandPass(coefficients, fc*M_PI/sr, q);
2828
}
2929

30+
void setAllPass(float fc, float q, float sr){
31+
setAllPass(coefficients, fc*M_PI/sr, q);
32+
}
33+
3034
void setNotch(float fc, float q, float sr){
3135
setNotch(coefficients, fc*M_PI/sr, q);
3236
}
@@ -82,6 +86,16 @@ class FilterStage {
8286
coefficients[4] = - (1 - K / q + K * K) * norm;
8387
}
8488

89+
static void setAllPass(float* coefficients, float omega, float q){
90+
float K = tanf(omega);
91+
float norm = 1 / (1 + K / Q + K * K);
92+
coefficients[0] = (1 - K / Q + K * K) * norm;
93+
coefficients[1] = 2 * (K * K - 1) * norm;
94+
coefficients[2] = 1;
95+
coefficients[3] = coefficients[1];
96+
coefficients[4] = coefficients[0];
97+
}
98+
8599
static void setNotch(float* coefficients, float omega, float q){
86100
float K = tanf(omega);
87101
float norm = 1 / (1 + K / q + K * K);
@@ -310,6 +324,13 @@ class BiquadFilter : public SignalProcessor {
310324
}
311325
}
312326

327+
void processAllPass(FloatArray in, FloatArray fc, float q, FloatArray out){
328+
for(size_t i = 0; i < in.getSize(); i++){
329+
setAllPass(fc[i], q);
330+
out[i] = process(in[i]);
331+
}
332+
}
333+
313334
/* process a single sample and return the result */
314335
float process(float input){
315336
float output;
@@ -332,6 +353,11 @@ class BiquadFilter : public SignalProcessor {
332353
copyCoefficients();
333354
}
334355

356+
void setAllPass(float fc, float q){
357+
FilterStage::setAllPass(coefficients, fc*pioversr, q);
358+
copyCoefficients();
359+
}
360+
335361
void setNotch(float fc, float q){
336362
FilterStage::setNotch(coefficients, fc*pioversr, q);
337363
copyCoefficients();

0 commit comments

Comments
 (0)