summaryrefslogtreecommitdiff
path: root/Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp
diff options
context:
space:
mode:
authorHendiadyoin1 <leon2002.la@gmail.com>2021-07-17 18:29:28 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-19 16:34:21 +0430
commited46d52252375be732841d980f9eec02ea7691f5 (patch)
tree60c8ff281cb3a07e2a33629184c6c0aec2a7f528 /Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp
parentc5f6ba6e71ee7ebce578828fd35ba119e9a6b41a (diff)
downloadserenity-ed46d52252375be732841d980f9eec02ea7691f5.zip
Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one. We avoid mixed usage for now though. Also clean up some stale math includes and improper floatingpoint usage.
Diffstat (limited to 'Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp')
-rw-r--r--Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp b/Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp
index a52eb5e8de..be4c09ba46 100644
--- a/Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp
+++ b/Userland/Applications/SoundPlayer/BarsVisualizationWidget.cpp
@@ -7,11 +7,11 @@
#include "BarsVisualizationWidget.h"
#include "AudioAlgorithms.h"
#include <AK/Complex.h>
+#include <AK/Math.h>
#include <LibGUI/Event.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Window.h>
-#include <math.h>
u32 round_previous_power_of_2(u32 x);
@@ -27,7 +27,7 @@ void BarsVisualizationWidget::paint_event(GUI::PaintEvent& event)
return;
fft(m_sample_buffer, false);
- double max = sqrt(m_sample_count * 2);
+ double max = AK::sqrt(m_sample_count * 2.);
double freq_bin = m_samplerate / m_sample_count;
@@ -45,10 +45,10 @@ void BarsVisualizationWidget::paint_event(GUI::PaintEvent& event)
int bins_per_group = ceil_div((m_sample_count - 1) / 2, group_count) * freq_bin;
for (int i = 1; i < m_sample_count / 2; i++) {
- groups[(i * freq_bin) / bins_per_group] += fabs(m_sample_buffer.data()[i].real());
+ groups[(i * freq_bin) / bins_per_group] += AK::fabs(m_sample_buffer.data()[i].real());
}
for (int i = 0; i < group_count; i++)
- groups[i] /= max * freq_bin / (m_adjust_frequencies ? (clamp(pow(M_E, (double)i / group_count * 3.) - 1.75, 1., 15.)) : 1.);
+ groups[i] /= max * freq_bin / (m_adjust_frequencies ? (clamp(AK::pow(AK::E<double>, (double)i / group_count * 3.) - 1.75, 1., 15.)) : 1.);
const int horizontal_margin = 30;
const int top_vertical_margin = 15;
@@ -102,7 +102,7 @@ void BarsVisualizationWidget::set_buffer(RefPtr<Audio::Buffer> buffer, int sampl
m_sample_count = round_previous_power_of_2(samples_to_use);
m_sample_buffer.resize(m_sample_count);
for (int i = 0; i < m_sample_count; i++) {
- m_sample_buffer.data()[i] = (fabs(buffer->samples()[i].left) + fabs(buffer->samples()[i].right)) / 2.;
+ m_sample_buffer.data()[i] = (AK::fabs(buffer->samples()[i].left) + AK::fabs(buffer->samples()[i].right)) / 2.;
}
update();