1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:07:45 +00:00

Piano: Use Sample struct from LibDSP

Removes the Sample struct inside Piano and replaces it with the struct
from LibDSP.

It automatically scales the height of the wave depending on the maximum
amplitude, as the Samples now contain floats and not integers.
This commit is contained in:
Fabian Neundorf 2023-02-06 20:01:51 +01:00 committed by Jelle Raaijmakers
parent 0019b901a0
commit 885e35e92c
4 changed files with 30 additions and 16 deletions

View file

@ -8,6 +8,7 @@
#pragma once
#include <LibAudio/Sample.h>
#include <LibGUI/Frame.h>
class TrackManager;
@ -18,11 +19,14 @@ public:
virtual ~WaveWidget() override = default;
private:
// Scales the sample-y value down by a bit, so that it doesn't look like it is clipping.
static constexpr float rescale_factor = 1.2f;
explicit WaveWidget(TrackManager&);
virtual void paint_event(GUI::PaintEvent&) override;
int sample_to_y(int sample) const;
int sample_to_y(float sample, float sample_max) const;
TrackManager& m_track_manager;
};