mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 16:07:45 +00:00
SoundPlayer: Auto refresh visualization widgets
Visualization widgets should only have to tell how many samples they need per frame and have a render method which receives all data relevant to draw the next frame.
This commit is contained in:
parent
02462b6068
commit
9edaa033e5
7 changed files with 115 additions and 107 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "VisualizationWidget.h"
|
||||
#include <AK/Complex.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <LibAudio/Buffer.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
|
||||
|
@ -17,21 +18,15 @@ class BarsVisualizationWidget final : public VisualizationWidget {
|
|||
|
||||
public:
|
||||
~BarsVisualizationWidget() override = default;
|
||||
void set_buffer(RefPtr<Audio::Buffer> buffer) override;
|
||||
void set_samplerate(int samplerate) override;
|
||||
|
||||
private:
|
||||
BarsVisualizationWidget();
|
||||
void set_buffer(RefPtr<Audio::Buffer> buffer, int samples_to_use);
|
||||
|
||||
void paint_event(GUI::PaintEvent&) override;
|
||||
void render(GUI::PaintEvent&, FixedArray<double> const&) override;
|
||||
void context_menu_event(GUI::ContextMenuEvent& event) override;
|
||||
|
||||
Vector<Complex<double>> m_sample_buffer;
|
||||
FixedArray<Complex<double>> m_fft_samples;
|
||||
Vector<int> m_gfx_falling_bars;
|
||||
int m_last_id;
|
||||
int m_sample_count;
|
||||
int m_samplerate;
|
||||
bool m_is_using_last;
|
||||
bool m_adjust_frequencies;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue