1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-29 15:52:07 +00:00
serenity/Userland/Applications/SoundPlayer/BarsVisualizationWidget.h
kleines Filmröllchen ab49fcfb7c LibAudio+Userland: Remove Audio::LegacyBuffer
The file is now renamed to Queue.h, and the Resampler APIs with
LegacyBuffer are also removed. These changes look large because nobody
actually needs Buffer.h (or Queue.h). It was mostly transitive
dependencies on the massive list of includes in that header, which are
now almost all gone. Instead, we include common things like Sample.h
directly, which should give faster compile times as very few files
actually need Queue.h.
2022-05-03 23:09:20 +02:00

41 lines
1.2 KiB
C++

/*
* Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "VisualizationWidget.h"
#include <AK/Array.h>
#include <AK/Complex.h>
#include <AK/FixedArray.h>
#include <LibGUI/Frame.h>
class BarsVisualizationWidget final : public VisualizationWidget {
C_OBJECT(BarsVisualizationWidget)
public:
~BarsVisualizationWidget() override = default;
private:
BarsVisualizationWidget();
void render(GUI::PaintEvent&, FixedArray<double> const&) override;
void context_menu_event(GUI::ContextMenuEvent& event) override;
static constexpr size_t fft_size = 512;
static constexpr size_t bar_count = 64;
// Things become weird near the Nyquist limit. Just don't use that FFT data.
static constexpr size_t cutoff = fft_size - 32;
Array<Complex<double>, fft_size> m_fft_samples {};
Array<double, fft_size> m_fft_window {};
Array<double, fft_size / 2> m_previous_samples {};
Array<int, bar_count> m_gfx_falling_bars {};
bool m_is_using_last;
bool m_adjust_frequencies;
bool m_logarithmic_spectrum;
RefPtr<GUI::Menu> m_context_menu;
};