/*
  ==============================================================================

    This file contains the basic framework code for a JUCE plugin processor.

  ==============================================================================
*/

#pragma once

#include <JuceHeader.h>

//==============================================================================
/**
*/
class ReverbAudioProcessor  : public juce::AudioProcessor
{
public:
    //==============================================================================
    ReverbAudioProcessor();
    ~ReverbAudioProcessor() override;

    //==============================================================================
    void prepareToPlay (double sampleRate, int samplesPerBlock) override;
    void releaseResources() override;

   #ifndef JucePlugin_PreferredChannelConfigurations
    bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
   #endif

    void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;

    //==============================================================================
    juce::AudioProcessorEditor* createEditor() override;
    bool hasEditor() const override;

    //==============================================================================
    const juce::String getName() const override;

    bool acceptsMidi() const override;
    bool producesMidi() const override;
    bool isMidiEffect() const override;
    double getTailLengthSeconds() const override;

    //==============================================================================
    int getNumPrograms() override;
    int getCurrentProgram() override;
    void setCurrentProgram (int index) override;
    const juce::String getProgramName (int index) override;
    void changeProgramName (int index, const juce::String& newName) override;

    //==============================================================================
    void getStateInformation (juce::MemoryBlock& destData) override;
    void setStateInformation (const void* data, int sizeInBytes) override;

    void update_verb();
    void setup_filter();

private:

    const int sample_rate = 48000;
    juce::AudioParameterFloat* roomSize;
    juce::AudioParameterFloat* damping;
    juce::AudioParameterFloat* wet_dry;
    juce::AudioParameterFloat* width;
    juce::AudioParameterFloat* freezeMode;

    juce::AudioParameterBool* lofi;
    juce::AudioParameterFloat* tone_val;

    juce::AudioParameterFloat* out;

    juce::Reverb verb;
    juce::Reverb::Parameters params;

    juce::IIRFilter* filter_l;
    juce::IIRFilter* filter_r;

    std::vector<juce::IIRFilter*> filters_l;
    std::vector<juce::IIRFilter*> filters_r;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ReverbAudioProcessor)
};
