diff options
author | Robin Gareus <robin@gareus.org> | 2019-02-28 20:56:23 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-02-28 20:56:23 +0100 |
commit | 959947e7f84aa2af5821d31044e527554165d659 (patch) | |
tree | d6b9b5d8356b5ddd0c6c30fb7e20e42bbed0fdda /libs/ardour | |
parent | 9131cd17a02eb8721b75cbf57305f3d25f589982 (diff) |
NO-OP: whitespace (remove vi modelines)
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/iec1ppmdsp.cc | 113 | ||||
-rw-r--r-- | libs/ardour/iec2ppmdsp.cc | 113 | ||||
-rw-r--r-- | libs/ardour/kmeterdsp.cc | 137 |
3 files changed, 169 insertions, 194 deletions
diff --git a/libs/ardour/iec1ppmdsp.cc b/libs/ardour/iec1ppmdsp.cc index 842d33b8b5..f4dcc4b39a 100644 --- a/libs/ardour/iec1ppmdsp.cc +++ b/libs/ardour/iec1ppmdsp.cc @@ -20,81 +20,74 @@ #include <math.h> #include "ardour/iec1ppmdsp.h" - float Iec1ppmdsp::_w1; float Iec1ppmdsp::_w2; float Iec1ppmdsp::_w3; float Iec1ppmdsp::_g; +Iec1ppmdsp::Iec1ppmdsp (void) + : _z1 (0) + , _z2 (0) + , _m (0) + , _res (true) +{} -Iec1ppmdsp::Iec1ppmdsp (void) : - _z1 (0), - _z2 (0), - _m (0), - _res (true) -{ -} - +Iec1ppmdsp::~Iec1ppmdsp (void) {} -Iec1ppmdsp::~Iec1ppmdsp (void) +void +Iec1ppmdsp::process (float const* p, int n) { + float z1, z2, m, t; + + z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1); + z2 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2); + m = _res ? 0: _m; + _res = false; + + n /= 4; + while (n--) { + z1 *= _w3; + z2 *= _w3; + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = z1 + z2; + if (t > m) m = t; + } + + _z1 = z1 + 1e-10f; + _z2 = z2 + 1e-10f; + _m = m; } - -void Iec1ppmdsp::process (float const *p, int n) +float +Iec1ppmdsp::read (void) { - float z1, z2, m, t; - - z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1); - z2 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2); - m = _res ? 0: _m; - _res = false; - - n /= 4; - while (n--) - { - z1 *= _w3; - z2 *= _w3; - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = z1 + z2; - if (t > m) m = t; - } - - _z1 = z1 + 1e-10f; - _z2 = z2 + 1e-10f; - _m = m; -} - - -float Iec1ppmdsp::read (void) -{ - _res = true; - return _g * _m; + _res = true; + return _g * _m; } -void Iec1ppmdsp::reset () +void +Iec1ppmdsp::reset () { - _z1 = _z2 = _m = .0f; - _res = true; + _z1 = _z2 = _m = .0f; + _res = true; } -void Iec1ppmdsp::init (float fsamp) +void +Iec1ppmdsp::init (float fsamp) { - _w1 = 450.0f / fsamp; - _w2 = 1300.0f / fsamp; - _w3 = 1.0f - 5.4f / fsamp; - _g = 0.5108f; + _w1 = 450.0f / fsamp; + _w2 = 1300.0f / fsamp; + _w3 = 1.0f - 5.4f / fsamp; + _g = 0.5108f; } - -/* vi:set ts=8 sts=8 sw=4: */ diff --git a/libs/ardour/iec2ppmdsp.cc b/libs/ardour/iec2ppmdsp.cc index d65f51b3fa..28b9aa9611 100644 --- a/libs/ardour/iec2ppmdsp.cc +++ b/libs/ardour/iec2ppmdsp.cc @@ -20,81 +20,74 @@ #include <math.h> #include "ardour/iec2ppmdsp.h" - float Iec2ppmdsp::_w1; float Iec2ppmdsp::_w2; float Iec2ppmdsp::_w3; float Iec2ppmdsp::_g; +Iec2ppmdsp::Iec2ppmdsp (void) + : _z1 (0) + , _z2 (0) + , _m (0) + , _res (true) +{} -Iec2ppmdsp::Iec2ppmdsp (void) : - _z1 (0), - _z2 (0), - _m (0), - _res (true) -{ -} - +Iec2ppmdsp::~Iec2ppmdsp (void) {} -Iec2ppmdsp::~Iec2ppmdsp (void) +void +Iec2ppmdsp::process (float const* p, int n) { + float z1, z2, m, t; + + z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1); + z2 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2); + m = _res ? 0: _m; + _res = false; + + n /= 4; + while (n--) { + z1 *= _w3; + z2 *= _w3; + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = fabsf (*p++); + if (t > z1) z1 += _w1 * (t - z1); + if (t > z2) z2 += _w2 * (t - z2); + t = z1 + z2; + if (t > m) m = t; + } + + _z1 = z1 + 1e-10f; + _z2 = z2 + 1e-10f; + _m = m; } - -void Iec2ppmdsp::process (float const *p, int n) +float +Iec2ppmdsp::read (void) { - float z1, z2, m, t; - - z1 = _z1 > 20 ? 20 : (_z1 < 0 ? 0 : _z1); - z2 = _z2 > 20 ? 20 : (_z2 < 0 ? 0 : _z2); - m = _res ? 0: _m; - _res = false; - - n /= 4; - while (n--) - { - z1 *= _w3; - z2 *= _w3; - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = fabsf (*p++); - if (t > z1) z1 += _w1 * (t - z1); - if (t > z2) z2 += _w2 * (t - z2); - t = z1 + z2; - if (t > m) m = t; - } - - _z1 = z1 + 1e-10f; - _z2 = z2 + 1e-10f; - _m = m; -} - - -float Iec2ppmdsp::read (void) -{ - _res = true; - return _g * _m; + _res = true; + return _g * _m; } -void Iec2ppmdsp::reset () +void +Iec2ppmdsp::reset () { - _z1 = _z2 = _m = .0f; - _res = true; + _z1 = _z2 = _m = .0f; + _res = true; } -void Iec2ppmdsp::init (float fsamp) +void +Iec2ppmdsp::init (float fsamp) { - _w1 = 200.0f / fsamp; - _w2 = 860.0f / fsamp; - _w3 = 1.0f - 4.0f / fsamp; - _g = 0.5141f; + _w1 = 200.0f / fsamp; + _w2 = 860.0f / fsamp; + _w3 = 1.0f - 4.0f / fsamp; + _g = 0.5141f; } - -/* vi:set ts=8 sts=8 sw=4: */ diff --git a/libs/ardour/kmeterdsp.cc b/libs/ardour/kmeterdsp.cc index add026797d..5b5331660e 100644 --- a/libs/ardour/kmeterdsp.cc +++ b/libs/ardour/kmeterdsp.cc @@ -20,93 +20,82 @@ #include <math.h> #include "ardour/kmeterdsp.h" - float Kmeterdsp::_omega; +Kmeterdsp::Kmeterdsp (void) + : _z1 (0) + , _z2 (0) + , _rms (0) + , _flag (false) +{} -Kmeterdsp::Kmeterdsp (void) : - _z1 (0), - _z2 (0), - _rms (0), - _flag (false) -{ -} - - -Kmeterdsp::~Kmeterdsp (void) -{ -} +Kmeterdsp::~Kmeterdsp (void) {} -void Kmeterdsp::init (int fsamp) +void +Kmeterdsp::init (int fsamp) { - _omega = 9.72f / fsamp; // ballistic filter coefficient + _omega = 9.72f / fsamp; // ballistic filter coefficient } -void Kmeterdsp::process (float const *p, int n) +void +Kmeterdsp::process (float const* p, int n) { - // Called by JACK's process callback. - // - // p : pointer to sample buffer - // n : number of samples to process - - float s, z1, z2; - - // Get filter state. - 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. - n /= 4; // Loop is unrolled by 4. - while (n--) - { - s = *p++; - s *= s; - z1 += _omega * (s - z1); // Update first filter. - s = *p++; - s *= s; - z1 += _omega * (s - z1); // Update first filter. - s = *p++; - s *= s; - z1 += _omega * (s - z1); // Update first filter. - s = *p++; - s *= s; - z1 += _omega * (s - z1); // Update first filter. - 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; - - s = sqrtf (2.0f * z2); - - if (_flag) // Display thread has read the rms value. - { - _rms = s; - _flag = false; - } - else - { - // Adjust RMS value and update maximum since last read(). - if (s > _rms) _rms = s; - } + float s, z1, z2; + + // Get filter state. + 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. + n /= 4; // Loop is unrolled by 4. + while (n--) { + s = *p++; + s *= s; + z1 += _omega * (s - z1); // Update first filter. + s = *p++; + s *= s; + z1 += _omega * (s - z1); // Update first filter. + s = *p++; + s *= s; + z1 += _omega * (s - z1); // Update first filter. + s = *p++; + s *= s; + z1 += _omega * (s - z1); // Update first filter. + 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; + + s = sqrtf (2.0f * z2); + + if (_flag) { + // Display thread has read the rms value. + _rms = s; + _flag = false; + } else { + // Adjust RMS value and update maximum since last read(). + if (s > _rms) _rms = s; + } } /* Returns highest _rms value since last call */ -float Kmeterdsp::read () +float +Kmeterdsp::read () { - float rv= _rms; - _flag = true; // Resets _rms in next process(). - return rv; + float rv= _rms; + _flag = true; // Resets _rms in next process(). + return rv; } -void Kmeterdsp::reset () +void +Kmeterdsp::reset () { - _z1 = _z2 = _rms = .0f; - _flag = false; + _z1 = _z2 = _rms = .0f; + _flag = false; } - -/* vi:set ts=8 sts=8 sw=4: */ |