refactor(fx): give each FX slot independent DSP history
Replace the single shared array of 9 effect units with a 2D array of kNumFxSlots × kNumEffectTypes, so each slot owns its own DSP state. This prevents state bleed when the same effect type appears in multiple slots and allows reordering without carrying over internal history. Track activeTypes to skip unchanged slots. Remove the dry buffer since it was unused.
This commit is contained in:
+14
-11
@@ -14,24 +14,27 @@ namespace serum
|
||||
|
||||
FXProcessor::FXProcessor()
|
||||
{
|
||||
units[0] = std::make_unique<HyperUnit>();
|
||||
units[1] = std::make_unique<ChorusUnit>();
|
||||
units[2] = std::make_unique<FlangerUnit>();
|
||||
units[3] = std::make_unique<PhaserUnit>();
|
||||
units[4] = std::make_unique<DistortionUnit>();
|
||||
units[5] = std::make_unique<EQUnit>();
|
||||
units[6] = std::make_unique<CompressorUnit>();
|
||||
units[7] = std::make_unique<DelayUnit>();
|
||||
units[8] = std::make_unique<ReverbUnit>();
|
||||
for (auto& slotUnits : units)
|
||||
{
|
||||
slotUnits[0] = std::make_unique<HyperUnit>();
|
||||
slotUnits[1] = std::make_unique<ChorusUnit>();
|
||||
slotUnits[2] = std::make_unique<FlangerUnit>();
|
||||
slotUnits[3] = std::make_unique<PhaserUnit>();
|
||||
slotUnits[4] = std::make_unique<DistortionUnit>();
|
||||
slotUnits[5] = std::make_unique<EQUnit>();
|
||||
slotUnits[6] = std::make_unique<CompressorUnit>();
|
||||
slotUnits[7] = std::make_unique<DelayUnit>();
|
||||
slotUnits[8] = std::make_unique<ReverbUnit>();
|
||||
}
|
||||
}
|
||||
|
||||
FXProcessor::~FXProcessor() = default;
|
||||
|
||||
void FXProcessor::prepare (double sampleRate, int maxBlockSize)
|
||||
{
|
||||
for (auto& u : units)
|
||||
for (auto& slotUnits : units)
|
||||
for (auto& u : slotUnits)
|
||||
u->prepare (sampleRate, maxBlockSize);
|
||||
dry.setSize (2, maxBlockSize, false, false, true);
|
||||
wet.setSize (2, maxBlockSize, false, false, true);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ struct FxSlotParams
|
||||
// ===========================================================================
|
||||
// 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.
|
||||
// preconstructed per slot with independent DSP history.
|
||||
// ===========================================================================
|
||||
class FXProcessor
|
||||
{
|
||||
@@ -47,8 +47,10 @@ public:
|
||||
static juce::String fxTypeName (int type);
|
||||
|
||||
private:
|
||||
std::array<std::unique_ptr<FXUnit>, 9> units;
|
||||
juce::AudioBuffer<float> dry, wet;
|
||||
static constexpr int kNumEffectTypes = (int) FxType::Count - 1;
|
||||
std::array<std::array<std::unique_ptr<FXUnit>, kNumEffectTypes>, kNumFxSlots> units;
|
||||
std::array<int, kNumFxSlots> activeTypes {};
|
||||
juce::AudioBuffer<float> wet;
|
||||
};
|
||||
|
||||
} // namespace serum
|
||||
|
||||
Reference in New Issue
Block a user