Settings window #20

Merged
Zacharias-Brohn merged 83 commits from settingsWindow into main 2026-03-06 23:27:24 +01:00
Showing only changes of commit 74ee1b48f9 - Show all commits
+13 -19
View File
@@ -45,10 +45,19 @@ void CavaProcessor::process() {
auto* b = tmp.data();
auto* e = b + tmp.size();
auto pct = [&](double p) {
const int k = std::clamp(int(std::chrono::round(p * (tmp.size() - 1))), 0, tmp.size() - 1);
std::nth_element(b, b + k, e);
return b[k];
auto pct = [&](double p) -> double {
const qsizetype n = tmp.size();
if (n <= 0) return 0.0;
// 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);
@@ -62,21 +71,6 @@ void CavaProcessor::process() {
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
if (values != m_values) {
m_values = std::move(values);