Improved: Parametric filter calculations (command "Filter") are now fully using double precision. This yields a great improvement in signal-to-noise ratio for practically no performance penalty.
Fixed: The method BiQuad::gainAt was returning wrong values. As this method was only used for testing purposes, this change is not user-visible.
This commit is contained in:
1 parent
7ae9879f55
commit
d68b958bc8
7 files changed
+157
-116
No files matched your search
+15
-12
@@ -19,9 +19,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
#include <string>
|
||||
|
||||
#define IS_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) == 0)
|
||||
#define IS_DENORMAL(d) (abs(d) < DBL_MIN)
|
||||
|
||||
class BiQuad
|
||||
{
|
||||
@@ -38,20 +41,20 @@ public:
|
||||
void removeDenormals()
|
||||
{
|
||||
if(IS_DENORMAL(x1))
|
||||
x1 = 0.0f;
|
||||
x1 = 0.0;
|
||||
if(IS_DENORMAL(x2))
|
||||
x2 = 0.0f;
|
||||
x2 = 0.0;
|
||||
if(IS_DENORMAL(y1))
|
||||
y1 = 0.0f;
|
||||
y1 = 0.0;
|
||||
if(IS_DENORMAL(y2))
|
||||
y2 = 0.0f;
|
||||
y2 = 0.0;
|
||||
}
|
||||
|
||||
__forceinline
|
||||
float process(float sample)
|
||||
double process(double sample)
|
||||
{
|
||||
// changed order of additions leads to better pipelining
|
||||
float result = a0 * sample + a[1] * x2 + a[0] * x1 - a[3] * y2 - a[2] * y1;
|
||||
double result = a0 * sample + a[1] * x2 + a[0] * x1 - a[3] * y2 - a[2] * y1;
|
||||
|
||||
x2 = x1;
|
||||
x1 = sample;
|
||||
@@ -62,12 +65,12 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
float gainAt(float freq, float srate);
|
||||
double gainAt(double freq, double srate);
|
||||
|
||||
private:
|
||||
__declspec(align(16)) float a[4];
|
||||
float a0;
|
||||
__declspec(align(16)) double a[4];
|
||||
double a0;
|
||||
|
||||
float x1, x2;
|
||||
float y1, y2;
|
||||
double x1, x2;
|
||||
double y1, y2;
|
||||
};
|
||||
Reference in new issue
Block a user