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

LibDSP+Piano: Convert DSP APIs to accept entire sample ranges

This has mainly performance benefits, so that we only need to call into
all processors once for every audio buffer segment. It requires
adjusting quite some logic in most processors and in Track, as we have
to consider a larger collection of notes and samples at each step.

There's some cautionary TODOs in the currently unused LibDSP tracks
because they don't do things properly yet.
This commit is contained in:
kleines Filmröllchen 2022-05-11 23:24:46 +02:00 committed by Linus Groh
parent 4d65607649
commit 9035d9e845
9 changed files with 123 additions and 75 deletions

View file

@ -23,8 +23,11 @@ public:
virtual bool check_processor_chain_valid() const = 0;
bool add_processor(NonnullRefPtr<Processor> new_processor);
// Creates the current signal of the track by processing current note or audio data through the processing chain
Sample current_signal();
// Creates the current signal of the track by processing current note or audio data through the processing chain.
void current_signal(FixedArray<Sample>& output_signal);
// We are informed of an audio buffer size change. This happens off-audio-thread so we can allocate.
ErrorOr<void> resize_internal_buffers_to(size_t buffer_size);
NonnullRefPtrVector<Processor> const& processor_chain() const { return m_processor_chain; }
NonnullRefPtr<Transport const> transport() const { return m_transport; }
@ -42,7 +45,13 @@ protected:
NonnullRefPtrVector<Processor> m_processor_chain;
NonnullRefPtr<Transport> m_transport;
// The current signal is stored here, to prevent unnecessary reallocation.
Signal m_current_signal { Audio::Sample {} };
Signal m_current_signal { FixedArray<Sample> {} };
// These are so that we don't have to allocate a secondary buffer in current_signal().
// A sample buffer possibly used by the processor chain.
Signal m_secondary_sample_buffer { FixedArray<Sample> {} };
// A note buffer possibly used by the processor chain.
Signal m_secondary_note_buffer { RollNotes {} };
};
class NoteTrack final : public Track {