/*
  ZynAddSubFX - a software synthesizer

  AlienWah.cpp - DPF + Zyn Plugin for AlienWah
  Copyright (C) 2015 Filipe Coelho
  Author: Filipe Coelho

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.
*/

// DPF includes
#include "../AbstractFX.hpp"

// ZynAddSubFX includes
#include "Effects/Alienwah.h"

/* ------------------------------------------------------------------------------------------------------------
 * AlienWah plugin class */

class AlienWahPlugin : public AbstractPluginFX<zyn::Alienwah>
{
public:
    AlienWahPlugin()
        : AbstractPluginFX(11, 4) {}

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

   /**
      Get the plugin label.
      This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.
    */
    const char* getLabel() const noexcept override
    {
        return "AlienWah";
    }

   /**
      Get an extensive comment/description about the plugin.
    */
    const char* getDescription() const noexcept override
    {
        // TODO
        return "";
    }

   /**
      Get the plugin unique Id.
      This value is used by LADSPA, DSSI and VST plugin formats.
    */
    int64_t getUniqueId() const noexcept override
    {
        return d_cconst('Z', 'X', 'a', 'w');
    }

   /* --------------------------------------------------------------------------------------------------------
    * Init */

   /**
      Initialize the parameter @a index.
      This function will be called once, shortly after the plugin is created.
    */
    void initParameter(uint32_t index, Parameter& parameter) noexcept override
    {
        parameter.hints = kParameterIsInteger;
        parameter.unit  = "";
        parameter.ranges.min = 0.0f;
        parameter.ranges.max = 127.0f;

        switch (index)
        {
        case 0:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "LFO Frequency";
            parameter.symbol = "lfofreq";
            parameter.ranges.def = 70.0f;
            break;
        case 1:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "LFO Randomness";
            parameter.symbol = "lforand";
            parameter.ranges.def = 0.0f;
            break;
        case 2:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "LFO Type";
            parameter.symbol = "lfotype";
            parameter.ranges.def = 0.0f;
            parameter.ranges.max = 1.0f;
            /*
            TODO: support for scalePoints in DPF
            scalePoints[0].label = "Sine";
            scalePoints[1].label = "Triangle";
            scalePoints[0].value = 0.0f;
            scalePoints[1].value = 1.0f;
            */
            break;
        case 3:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "LFO Stereo";
            parameter.symbol = "lfostereo";
            parameter.ranges.def = 62.0f;
            break;
        case 4:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "Depth";
            parameter.symbol = "depth";
            parameter.ranges.def = 60.0f;
            break;
        case 5:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "Feedback";
            parameter.symbol = "fb";
            parameter.ranges.def = 105.0f;
            break;
        case 6:
            parameter.name   = "Delay";
            parameter.symbol = "delay";
            parameter.ranges.def = 25.0f;
            parameter.ranges.min = 1.0f;
            parameter.ranges.max = 100.0f;
            break;
        case 7:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "L/R Cross";
            parameter.symbol = "lrcross";
            parameter.ranges.def = 0.0f;
            break;
        case 8:
            parameter.hints |= kParameterIsAutomable;
            parameter.name   = "Phase";
            parameter.symbol = "phase";
            parameter.ranges.def = 64.0f;
            break;
        }
    }

   /**
      Set the name of the program @a index.
      This function will be called once, shortly after the plugin is created.
    */
    void initProgramName(uint32_t index, String& programName) noexcept override
    {
        switch (index)
        {
        case 0:
            programName = "AlienWah 1";
            break;
        case 1:
            programName = "AlienWah 2";
            break;
        case 2:
            programName = "AlienWah 3";
            break;
        case 3:
            programName = "AlienWah 4";
            break;
        }
    }

    DISTRHO_DECLARE_NON_COPY_CLASS(AlienWahPlugin)
};

/* ------------------------------------------------------------------------------------------------------------
 * Create plugin, entry point */

START_NAMESPACE_DISTRHO

Plugin* createPlugin()
{
    return new AlienWahPlugin();
}

END_NAMESPACE_DISTRHO
