#pragma once

#include "../Parameters/DeepPluckParameters.h"

#include <juce_audio_basics/juce_audio_basics.h>
#include <juce_dsp/juce_dsp.h>

namespace deeppluck
{
class DeepPluckChorus final
{
public:
    void prepare (double sampleRate, int maximumBlockSize);
    void reset() noexcept;
    void setParameters (const DeepPluckParameterSnapshot& snapshot) noexcept;
    void process (juce::AudioBuffer<float>& buffer, int startSample, int numSamples) noexcept;

    [[nodiscard]] bool isIdle() const noexcept;

private:
    static constexpr float wetCalibration = 0.55f;
    static constexpr double smoothingSeconds = 0.020;

    juce::dsp::Chorus<float> leftChorus;
    juce::dsp::Chorus<float> rightChorus;
    juce::AudioBuffer<float> wetBuffer;
    juce::SmoothedValue<float, juce::ValueSmoothingTypes::Linear> mix;
    juce::SmoothedValue<float, juce::ValueSmoothingTypes::Linear> width;
    bool active = false;
};
}
