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

Piano: Use LibDSP to implement delay

This is the first step in transitioning Piano to a full LibDSP backend.
For now, the delay effect is replaced with a (mostly identical)
implementation in LibDSP.

The new ProcessorParameterSlider attaches to a LibDSP::Processor's
range parameter (LibDSP::ProcessorRangeParameter) and changes it
automatically. It also has the ability to update an external GUI::Label.
This is used for the three delay parameters and it will become useful
for auto-generating UI for Processors.
This commit is contained in:
kleines Filmröllchen 2021-08-27 16:20:09 +02:00 committed by Ali Mohammad Pur
parent a749b16674
commit 0dc6fe9102
8 changed files with 84 additions and 49 deletions

View file

@ -12,6 +12,7 @@
#include <AK/Noncopyable.h>
#include <AK/SinglyLinkedList.h>
#include <LibAudio/Buffer.h>
#include <LibDSP/Effects.h>
using RollIter = AK::SinglyLinkedListIterator<SinglyLinkedList<RollNote>, RollNote>;
@ -31,7 +32,7 @@ public:
int decay() const { return m_decay; }
int sustain() const { return m_sustain; }
int release() const { return m_release; }
int delay() const { return m_delay; }
NonnullRefPtr<LibDSP::Effects::Delay> delay() { return m_delay; }
void fill_sample(Sample& sample);
void reset();
@ -45,7 +46,6 @@ public:
void set_decay(int decay);
void set_sustain(int sustain);
void set_release(int release);
void set_delay(int delay);
private:
Audio::Frame sine(size_t note);
@ -58,8 +58,6 @@ private:
void sync_roll(int note);
void set_sustain_impl(int sustain);
Vector<Sample> m_delay_buffer;
Vector<Audio::Frame> m_recorded_sample;
u8 m_note_on[note_count] { 0 };
@ -79,12 +77,12 @@ private:
double m_sustain_level;
int m_release;
double m_release_step[note_count];
int m_delay { 0 };
size_t m_delay_samples { 0 };
size_t m_delay_index { 0 };
const u32& m_time;
NonnullRefPtr<LibDSP::Transport> m_temporary_transport;
NonnullRefPtr<LibDSP::Effects::Delay> m_delay;
SinglyLinkedList<RollNote> m_roll_notes[note_count];
RollIter m_roll_iterators[note_count];
};