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

    This file was auto-generated by the Introjucer!

    It contains the basic framework code for a JUCE plugin processor.

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

#pragma once

#include <JuceHeader.h>

using namespace juce::dsp;

//==============================================================================
/**
*/
class CompensatedDelayAudioProcessor : public gin::Processor,
                                       private gin::Parameter::ParameterListener
{
public:
    //==============================================================================
    CompensatedDelayAudioProcessor();
    ~CompensatedDelayAudioProcessor() override;

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

    void processBlock (AudioSampleBuffer&, MidiBuffer&) override;

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

    //==============================================================================
    gin::Parameter::Ptr mode, time, samples;

private:
    void valueUpdated (gin::Parameter*) override { updateLatency(); }
    void numChannelsChanged () override;
    
    void updateLatency();
    
    gin::DelayLine delayLine { 2, 2 };
    
    //==============================================================================
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CompensatedDelayAudioProcessor)
};
