shithub: leaf

ref: 3c8c5ec4983d71b56b8c1f969c4aa7eb87ada9cd
dir: /TestPlugin/Source/LEAFLink.cpp/

View raw version
/*
  ==============================================================================

    LEAFLink.c
    Created: 18 Jan 2017 11:25:00am
    Author:  Michael R Mulshine

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

#include "LEAFLink.h"

#define MYTEST 0
#define FM     1

std::vector<juce::String> cButtonNames =  std::vector<juce::String>
{
    "load"
};

std::vector<juce::String> cSliderNames =  std::vector<juce::String>
{
    "slider1",
    "slider2",
    "slider3"
};

std::vector<juce::String> cComboBoxNames =  std::vector<juce::String>
{
    
};

std::vector<juce::String> cWaveformTypes =  std::vector<juce::String>
{
    
};

std::vector<float> cSliderModelValues(cSliderNames.size());
std::vector<float> cSliderValues(cSliderNames.size());
std::vector<bool> cButtonStates(cButtonNames.size());
std::vector<int> cComboBoxStates(cComboBoxNames.size());

Array<AudioBuffer<float>> loadedAudio;

void setSliderModelValue(String name, float val)
{
    for (int i = 0; i < cSliderNames.size(); i++)
    {
        if (name == cSliderNames[i])
        {
            cSliderModelValues[i] = val;
            break;
        }
    }
}

void printSliderValues(void)
{
    for (int i = 0; i < cSliderNames.size(); i++)
    {
        DBG(String(cSliderNames[i]) + ": " + String(cSliderValues[i]));
    }
}

bool getButtonState(String name)
{
    for (int i = 0; i < cButtonNames.size(); i++)
    {
        if (name == cButtonNames[i])
        {
            return cButtonStates[i];
        }
    }
    
    return false;
}

void setButtonState(String name, bool on)
{
    for (int i = 0; i < cButtonNames.size(); i++)
    {
        if (name == cButtonNames[i])
        {
            cButtonStates[i] = on;
            break;
        }
    }
}

int getComboBoxState(String name)
{
    for (int i = 0; i < cComboBoxNames.size(); i++)
    {
        if (name == cComboBoxNames[i])
        {
            return cComboBoxStates[i];
        }
    }
    return -1;
}

void setComboBoxState(String name, int idx)
{
    DBG("set state: " + name + " " + String(idx));
    for (int i = 0; i < cComboBoxNames.size(); i++)
    {
        if (name == cComboBoxNames[i])
        {
            cComboBoxStates[i] = idx;
            break;
        }
    }
}

void setSliderValue(String name, float val)
{
    for (int i = 0; i < cSliderNames.size(); i++)
    {
        if (name == cSliderNames[i])
        {
            cSliderValues[i] = val;
            break;
        }
    }
}

float getSliderValue(String name)
{
    float value = 0.0f;
    
    for (int i = 0; i < cSliderNames.size(); i++)
    {
        if (name == cSliderNames[i])
        {
            value = cSliderValues[i];
            break;
        }
    }
    
    return value;
}

float getRandomFloat(void)
{
    return ((float)rand()/RAND_MAX);
}