summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-08-29 17:36:52 +0200
committerRobin Gareus <robin@gareus.org>2013-08-29 17:36:52 +0200
commit2172700144a1b9d13c87bceb5be60f7632f640c4 (patch)
tree7a04e19505639d31a000778cdeba2b10e2d5212c
parent03c26762e6c602b0d815d074384b71abf773ee37 (diff)
protect meters against weird float values
-rw-r--r--libs/ardour/iec1ppmdsp.cc4
-rw-r--r--libs/ardour/iec2ppmdsp.cc4
-rw-r--r--libs/ardour/kmeterdsp.cc6
-rw-r--r--libs/ardour/vumeterdsp.cc6
4 files changed, 12 insertions, 8 deletions
diff --git a/libs/ardour/iec1ppmdsp.cc b/libs/ardour/iec1ppmdsp.cc
index bed825048f..47e953f1ab 100644
--- a/libs/ardour/iec1ppmdsp.cc
+++ b/libs/ardour/iec1ppmdsp.cc
@@ -45,8 +45,8 @@ void Iec1ppmdsp::process (float *p, int n)
{
float z1, z2, m, t;
- z1 = _z1;
- z2 = _z2;
+ z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1);
+ z1 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2);
m = _res ? 0: _m;
_res = false;
diff --git a/libs/ardour/iec2ppmdsp.cc b/libs/ardour/iec2ppmdsp.cc
index 76862cccd2..bb934166fc 100644
--- a/libs/ardour/iec2ppmdsp.cc
+++ b/libs/ardour/iec2ppmdsp.cc
@@ -45,8 +45,8 @@ void Iec2ppmdsp::process (float *p, int n)
{
float z1, z2, m, t;
- z1 = _z1;
- z2 = _z2;
+ z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1);
+ z1 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2);
m = _res ? 0: _m;
_res = false;
diff --git a/libs/ardour/kmeterdsp.cc b/libs/ardour/kmeterdsp.cc
index 181378cf76..35c95c2daf 100644
--- a/libs/ardour/kmeterdsp.cc
+++ b/libs/ardour/kmeterdsp.cc
@@ -52,8 +52,8 @@ void Kmeterdsp::process (float *p, int n)
float s, z1, z2;
// Get filter state.
- z1 = _z1;
- z2 = _z2;
+ z1 = _z1 > 50 ? 50 : (_z1 < 0 ? 0 : _z1);
+ z2 = _z2 > 50 ? 50 : (_z2 < 0 ? 0 : _z2);
// Perform filtering. The second filter is evaluated
// only every 4th sample - this is just an optimisation.
@@ -75,6 +75,8 @@ void Kmeterdsp::process (float *p, int n)
z2 += 4 * _omega * (z1 - z2); // Update second filter.
}
+ if (isnan(z1)) z1 = 0;
+ if (isnan(z2)) z2 = 0;
// Save filter state. The added constants avoid denormals.
_z1 = z1 + 1e-20f;
_z2 = z2 + 1e-20f;
diff --git a/libs/ardour/vumeterdsp.cc b/libs/ardour/vumeterdsp.cc
index 67d48f6c54..a3d0ec23c1 100644
--- a/libs/ardour/vumeterdsp.cc
+++ b/libs/ardour/vumeterdsp.cc
@@ -43,8 +43,8 @@ void Vumeterdsp::process (float *p, int n)
{
float z1, z2, m, t1, t2;
- z1 = _z1;
- z2 = _z2;
+ z1 = _z1 > 20 ? 20 : (_z1 < -20 ? -20 : _z1);
+ z2 = _z2 > 20 ? 20 : (_z2 < -20 ? -20 : _z2);
m = _res ? 0: _m;
_res = false;
@@ -64,6 +64,8 @@ void Vumeterdsp::process (float *p, int n)
if (z2 > m) m = z2;
}
+ if (isnan(z1)) z1 = 0;
+ if (isnan(z2)) z2 = 0;
_z1 = z1;
_z2 = z2 + 1e-10f;
_m = m;