cava test

This commit is contained in:
Zacharias-Brohn
2026-02-26 14:52:24 +01:00
parent dd02b2636e
commit 74ee1b48f9
+13 -19
View File
@@ -45,10 +45,19 @@ void CavaProcessor::process() {
auto* b = tmp.data(); auto* b = tmp.data();
auto* e = b + tmp.size(); auto* e = b + tmp.size();
auto pct = [&](double p) { auto pct = [&](double p) -> double {
const int k = std::clamp(int(std::chrono::round(p * (tmp.size() - 1))), 0, tmp.size() - 1); const qsizetype n = tmp.size();
std::nth_element(b, b + k, e); if (n <= 0) return 0.0;
return b[k];
// p in [0,1] -> index in [0, n-1]
const double pos = p * double(n - 1);
qsizetype k = static_cast<qsizetype>(std::llround(pos));
k = std::clamp<qsizetype>(k, 0, n - 1);
auto first = tmp.begin();
auto nth = first + k;
std::nth_element(first, nth, tmp.end());
return *nth;
}; };
const double floor = pct(0.25); const double floor = pct(0.25);
@@ -62,21 +71,6 @@ void CavaProcessor::process() {
values[i] = std::pow(x, gamma); values[i] = std::pow(x, gamma);
} }
// Left to right pass
// const double inv = 1.0 / 1.5;
// double carry = 0.0;
// for (int i = 0; i < m_bars; ++i) {
// carry = std::max(m_out[i], carry * inv);
// values[i] = carry;
// }
//
// // Right to left pass and combine
// carry = 0.0;
// for (int i = m_bars - 1; i >= 0; --i) {
// carry = std::max(m_out[i], carry * inv);
// values[i] = std::max(values[i], carry);
// }
// Update values // Update values
if (values != m_values) { if (values != m_values) {
m_values = std::move(values); m_values = std::move(values);