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

LibDSP: Fix potential slicing issue in volume_from_envelope

Use pointer or reference to avoid slicing from "PitchedEnvelope"
to "Envelope". This was found by SonarCloud.
This commit is contained in:
Brian Gianforcaro 2021-11-27 15:18:43 -08:00 committed by Brian Gianforcaro
parent a225b26d88
commit 55aecf5381
3 changed files with 3 additions and 3 deletions

View file

@ -50,7 +50,7 @@ struct Envelope {
constexpr void reset() { envelope = -1; } constexpr void reset() { envelope = -1; }
constexpr operator EnvelopeState() constexpr operator EnvelopeState() const
{ {
if (!is_active()) if (!is_active())
return EnvelopeState::Off; return EnvelopeState::Off;

View file

@ -64,7 +64,7 @@ Signal Classic::process_impl(Signal const& input_signal)
} }
// Linear ADSR envelope with no peak adjustment. // Linear ADSR envelope with no peak adjustment.
double Classic::volume_from_envelope(Envelope envelope) double Classic::volume_from_envelope(Envelope const& envelope)
{ {
switch (static_cast<EnvelopeState>(envelope)) { switch (static_cast<EnvelopeState>(envelope)) {
case EnvelopeState::Off: case EnvelopeState::Off:

View file

@ -49,7 +49,7 @@ public:
private: private:
virtual Signal process_impl(Signal const&) override; virtual Signal process_impl(Signal const&) override;
double volume_from_envelope(Envelope); double volume_from_envelope(Envelope const&);
double wave_position(u8 note); double wave_position(u8 note);
double samples_per_cycle(u8 note); double samples_per_cycle(u8 note);
double sin_position(u8 note); double sin_position(u8 note);