From 4674dd85343845b90914439fe049a67102980ad9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 6 Mar 2020 04:13:09 +0100 Subject: [PATCH] Increase accuracy of analyzed true-peak positions --- libs/vamp-plugins/TruePeak.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/vamp-plugins/TruePeak.cpp b/libs/vamp-plugins/TruePeak.cpp index 9a9f6f93d8..ff5e7562ca 100644 --- a/libs/vamp-plugins/TruePeak.cpp +++ b/libs/vamp-plugins/TruePeak.cpp @@ -593,12 +593,18 @@ VampTruePeak::process(const float *const *inputBuffers, return FeatureSet(); } - _meter.process (inputBuffers[0], m_blockSize); + size_t remain = m_blockSize; + size_t processed = 0; + while (remain > 0) { + size_t to_proc = std::min ((size_t)48, remain); + _meter.process (&inputBuffers[0][processed], to_proc); + processed += to_proc; + remain -= to_proc; - // TODO optional (not rt safe) - if (_meter.read () >= .89125 /* -1dBTP */) { - long f = Vamp::RealTime::realTime2Frame (timestamp, m_rate); - _above_m1.values.push_back ((float) f); + if (_meter.read () >= .89125 /* -1dBTP */) { + long f = Vamp::RealTime::realTime2Frame (timestamp, m_rate); + _above_m1.values.push_back ((float) (f + processed)); + } } return FeatureSet();