X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fkmeterdsp.cc;h=add026797d263cb3e5f96ef40109cc70ec96c083;hb=449b57d583b63507241939540da630511b8e335b;hp=181378cf76d55918cd38c87b10c8012f73e33103;hpb=6a436fd826d1c9d88b60287696cc0836ccce35aa;p=ardour.git diff --git a/libs/ardour/kmeterdsp.cc b/libs/ardour/kmeterdsp.cc index 181378cf76..add026797d 100644 --- a/libs/ardour/kmeterdsp.cc +++ b/libs/ardour/kmeterdsp.cc @@ -42,7 +42,7 @@ void Kmeterdsp::init (int fsamp) _omega = 9.72f / fsamp; // ballistic filter coefficient } -void Kmeterdsp::process (float *p, int n) +void Kmeterdsp::process (float const *p, int n) { // Called by JACK's process callback. // @@ -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;