ambivalence/Source/PluginProcessor.h
2026-08-15 18:31:51 +02:00

91 lines
No EOL
3.4 KiB
C++

#pragma once
#include <JuceHeader.h>
#include "DSP/UniversalEngine.h"
#include "PluginParameters.h"
class FDNReverbAudioProcessor : public juce::AudioProcessor
{
public:
FDNReverbAudioProcessor();
void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override { engine.reset(); }
void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
void processBlockBypassed(juce::AudioBuffer<float>&, juce::MidiBuffer&) override {}
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override { return true; }
const juce::String getName() const override { return "Ambivalence"; }
double getTailLengthSeconds() const override { return 20.0; }
bool acceptsMidi() const override { return false; }
bool producesMidi() const override { return false; }
bool isMidiEffect() const override { return false; }
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram(int) override {}
const juce::String getProgramName(int) override { return {}; }
void changeProgramName(int, const juce::String&) override {}
void getStateInformation(juce::MemoryBlock& destData) override;
void setStateInformation(const void* data, int sizeInBytes) override;
juce::AudioProcessorValueTreeState apvts;
std::array<float, FDNReverb::NUM_BANDS> getRT60ForDisplay() const noexcept {
return engine.getEffectiveRT60();
}
float getInputRMSL() const noexcept { return inputRMS_L.load(); }
float getInputRMSR() const noexcept { return inputRMS_R.load(); }
float getOutputRMSL() const noexcept { return outputRMS_L.load(); }
float getOutputRMSR() const noexcept { return outputRMS_R.load(); }
float getD50() const noexcept { return engine.getD50(); }
float getC50() const noexcept { return engine.getC50(); }
float getC80() const noexcept { return engine.getC80(); }
float getEDT() const noexcept { return engine.getEDT(); }
const FDNReverb::UniversalEngine& getEngine() const noexcept { return engine; }
void loadPresetDefaults(int algorithmIndex);
private:
void updateEngineParams();
FDNReverb::UniversalEngine engine;
// --- dirty flag: skip setParams() when no parameter changed ---
// processBlock() calls updateEngineParams() every buffer,
// but the designStage2() x 16 WLS computation is skipped when nothing changed
FDNReverb::DSPParams lastSentParams;
bool paramsNeedUpdate{ true }; // the first run
int lastAlgorithmIndex{ -1 };
std::unique_ptr<juce::dsp::Oversampling<float>> oversampler;
juce::AudioBuffer<float> wetBuffer;
juce::SmoothedValue<float> smoothWetGain, smoothDryGain;
std::atomic<float> inputRMS_L{ 0.f }, inputRMS_R{ 0.f };
std::atomic<float> outputRMS_L{ 0.f }, outputRMS_R{ 0.f };
double lastSampleRate{ 0.0 };
// * added : for session saving preset name
// PresetManager editor ,
// Processor preset name save support .
juce::String lastSavedPresetName;
public:
// editor call preset name Processor notify
void setLastSavedPresetName(const juce::String& name) noexcept {
lastSavedPresetName = name;
}
juce::String getLastSavedPresetName() const noexcept {
return lastSavedPresetName;
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FDNReverbAudioProcessor)
};