feat(fx): add effect rack and effect units

This commit is contained in:
2026-09-08 14:55:22 +02:00
parent 4021b9cdf7
commit 5a80534a2e
21 changed files with 1104 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
#pragma once
#include <JuceHeader.h>
#include "Params.h"
namespace serum
{
// ===========================================================================
// Base class for a stereo effect unit. Each unit processes a full-wet buffer.
// ===========================================================================
class FXUnit
{
public:
virtual ~FXUnit() = default;
virtual void prepare (double sampleRate, int maxBlockSize) = 0;
virtual void reset() = 0;
virtual void process (float* l, float* r, int numSamples, const float p[4]) = 0;
};
// ===========================================================================
// Snapshot of one FX slot.
// ===========================================================================
struct FxSlotParams
{
int type = (int) FxType::Off;
float mix = 0.0f;
float p[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
};
// ===========================================================================
// Reorderable effects rack. Slots are processed in list order; reordering is
// simply swapping FxSlotParams entries. Nine effect unit implementations are
// owned here and shared across slots.
// ===========================================================================
class FXProcessor
{
public:
FXProcessor();
~FXProcessor();
void prepare (double sampleRate, int maxBlockSize);
void reset();
void process (juce::AudioBuffer<float>& buffer, const FxSlotParams* slots, int numSlots);
static juce::String fxTypeName (int type);
private:
std::array<std::unique_ptr<FXUnit>, 9> units;
juce::AudioBuffer<float> dry, wet;
};
} // namespace serum