plugin/cp: O(n) monstercat
Closes #708 Looks slightly worse I think, but not by much
This commit is contained in:
parent
d4dde2c02d
commit
e13e346eba
1 changed files with 15 additions and 9 deletions
|
|
@ -32,18 +32,24 @@ void CavaProcessor::process() {
|
||||||
cava_execute(m_in, count, m_out, m_plan);
|
cava_execute(m_in, count, m_out, m_plan);
|
||||||
|
|
||||||
// Apply monstercat filter
|
// Apply monstercat filter
|
||||||
for (int i = 0; i < m_bars; i++) {
|
QVector<double> values(m_bars);
|
||||||
for (int j = i - 1; j >= 0; j--) {
|
|
||||||
m_out[j] = std::max(m_out[i] / std::pow(1.5, i - j), m_out[j]);
|
// Left to right pass
|
||||||
}
|
const double inv = 1.0 / 1.5;
|
||||||
for (int j = i + 1; j < m_bars; j++) {
|
double carry = 0.0;
|
||||||
m_out[j] = std::max(m_out[i] / std::pow(1.5, j - i), m_out[j]);
|
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
|
||||||
QVector<double> values(m_bars);
|
|
||||||
std::copy(m_out, m_out + m_bars, values.begin());
|
|
||||||
if (values != m_values) {
|
if (values != m_values) {
|
||||||
m_values = std::move(values);
|
m_values = std::move(values);
|
||||||
emit valuesChanged(m_values);
|
emit valuesChanged(m_values);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue