/*
 * Stone phaser audio effect based on DISTRHO Plugin Framework (DPF)
 *
 * SPDX-License-Identifier: BSL-1.0
 *
 * Copyright (C) 2019 Jean Pierre Cimalando <jp-dev@inbox.ru>
 */

#pragma once
#include "DistrhoPlugin.hpp"
#include "StonePhaserDsp.hpp"
#include <memory>

// -----------------------------------------------------------------------

class PhaserPlugin : public DISTRHO::Plugin {
public:
    PhaserPlugin();
    ~PhaserPlugin();

protected:
    // -------------------------------------------------------------------
    // Information

    const char *getLabel() const noexcept override
    {
#if DISTRHO_PLUGIN_NUM_INPUTS == 2
        return "stone-phaser-ext";
#elif DISTRHO_PLUGIN_NUM_INPUTS == 3
        return "stone-phaser-stereo-ext";
#endif
    }

    const char *getDescription() const noexcept override
    {
#if DISTRHO_PLUGIN_NUM_INPUTS == 2
        return "A classic analog phaser effect, external LFO input";
#elif DISTRHO_PLUGIN_NUM_INPUTS == 3
        return "A classic analog phaser effect (stereo), external LFO input";
#endif
    }

    const char *getMaker() const noexcept override
    {
        return "Jean Pierre Cimalando";
    }

    const char *getHomePage() const noexcept override
    {
        return "https://github.com/jpcima/stone-phaser";
    }

    const char *getLicense() const noexcept override
    {
        return "https://spdx.org/licenses/BSL-1.0";
    }

    uint32_t getVersion() const noexcept override
    {
        return d_version(0, 1, 2);
    }

    int64_t getUniqueId() const noexcept override
    {
#if DISTRHO_PLUGIN_NUM_INPUTS == 2
        return d_cconst('s', 's', 'p', '2');
#elif DISTRHO_PLUGIN_NUM_INPUTS == 3
        return d_cconst('s', 's', 'p', '3');
#endif
    }

    // -------------------------------------------------------------------
    // Init

    void initParameter(uint32_t index, DISTRHO::Parameter &parameter) override;

    // -------------------------------------------------------------------
    // Internal data

    float getParameterValue(uint32_t index) const override;
    void setParameterValue(uint32_t index, float value) override;

    // -------------------------------------------------------------------
    // Optional

    // Optional callback to inform the plugin about a sample rate change.
    void sampleRateChanged(double newSampleRate) override;

    // -------------------------------------------------------------------
    // Process

    void activate() override;

    void run(const float **inputs, float **outputs, uint32_t frames) override;


    // -------------------------------------------------------------------

private:
    StonePhaserDsp fDsp;
    bool fTrueBypass = false;

    DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PhaserPlugin)
};
