1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

SoundPlayer: Adjust peaking logic for bars visualization

This should give us better peaks by also reducing the energy on lower
frequency bars.
This commit is contained in:
kleines Filmröllchen 2022-03-04 00:20:04 +01:00 committed by Andreas Kling
parent 21266f42f1
commit 9f856f3e45

View file

@ -46,11 +46,11 @@ void BarsVisualizationWidget::render(GUI::PaintEvent& event, FixedArray<double>
groups[i / values_per_bar] /= values_per_bar;
}
double const max_peak_value = AK::sqrt(static_cast<double>(fft_size));
double const max_peak_value = AK::sqrt(static_cast<double>(fft_size * 2));
for (size_t i = 0; i < bar_count; i++) {
groups[i] = AK::log(groups[i] + 1) / AK::log(max_peak_value);
if (m_adjust_frequencies)
groups[i] *= 1 + 3.0 * i / bar_count;
groups[i] *= 1 + 2.0 * (static_cast<double>(i) - static_cast<double>(bar_count / 3)) / static_cast<double>(bar_count);
}
int const horizontal_margin = 30;