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

    This file was auto-generated by the Introjucer!

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

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

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"

using namespace juce::dsp;


#define PARAM_ENABLE        "enable"
#define PARAM_BANDLIMIT     "bandlimit"
#define PARAM_FREQ          "freq"
#define PARAM_SINE_LEVEL    "sine"
#define PARAM_TRI_LEVEL     "triangle"
#define PARAM_SAW_UP_LEVEL  "sawup"
#define PARAM_SAW_DN_LEVEL  "sawdn"
#define PARAM_SQUARE_LEVEL  "square"
#define PARAM_NOISE_LEVEL   "noise"

class slToneAudioProcessorEditor;
//==============================================================================
/**
*/
class slToneAudioProcessor : public gin::Processor
{
public:
    //==============================================================================
    slToneAudioProcessor();
    ~slToneAudioProcessor() override;

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

    void processBlock (juce::AudioSampleBuffer&, juce::MidiBuffer&) override;

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

    //==============================================================================
    gin::AudioFifo fifo {1, 44100};

private:
    bool bandLimited = true;

    Oscillator<float> sine;
    Oscillator<float> triangle;
    Oscillator<float> sawUp;
    Oscillator<float> sawDown;
    Oscillator<float> square;
    Oscillator<float> noise;

    juce::Component::SafePointer<slToneAudioProcessorEditor> editor;

    juce::LinearSmoothedValue<float> enableVal;
    juce::LinearSmoothedValue<float> sineVal;
    juce::LinearSmoothedValue<float> triangleVal;
    juce::LinearSmoothedValue<float> sawUpVal;
    juce::LinearSmoothedValue<float> sawDownVal;
    juce::LinearSmoothedValue<float> squareVal;
    juce::LinearSmoothedValue<float> noiseVal;

    //==============================================================================
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (slToneAudioProcessor)
};
