2025-01-07 12:04:48 +00:00
|
|
|
/*
|
|
|
|
Alpha Oscillator POC
|
|
|
|
|
|
|
|
Copyright 2024 Gordon JC Pearce <gordonjcp@gjcp.net>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "alphaosc.hpp"
|
|
|
|
|
|
|
|
void AlphaOsc::initParameter(uint32_t index, Parameter& parameter) {
|
|
|
|
// define all the different control input parameters
|
|
|
|
switch (index) {
|
|
|
|
case pSqrMode:
|
|
|
|
// set up Square slider
|
|
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
|
|
parameter.name = "Square";
|
|
|
|
parameter.symbol = "ao_sqr";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 4.0f;
|
|
|
|
parameter.ranges.def = 1.0f;
|
|
|
|
parameter.enumValues.count = 5;
|
|
|
|
parameter.enumValues.restrictedMode = true;
|
|
|
|
{
|
|
|
|
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[5];
|
|
|
|
enumValues[0].value = 0;
|
|
|
|
enumValues[0].label = "Off";
|
|
|
|
enumValues[1].value = 1;
|
|
|
|
enumValues[1].label = "50%";
|
|
|
|
enumValues[2].value = 2;
|
|
|
|
enumValues[2].label = "25%";
|
|
|
|
enumValues[3].value = 3;
|
|
|
|
enumValues[3].label = "PWM";
|
|
|
|
// dummy value because Carla won't display integer knobs with less than 5 steps
|
|
|
|
enumValues[4].value = 3;
|
|
|
|
enumValues[4].label = "Off";
|
|
|
|
parameter.enumValues.values = enumValues;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case pSawMode:
|
|
|
|
// set up Saw slider
|
|
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
|
|
parameter.name = "Saw";
|
|
|
|
parameter.symbol = "ao_saw";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 5.0f;
|
|
|
|
parameter.ranges.def = 1.0f;
|
|
|
|
parameter.enumValues.count = 6;
|
|
|
|
parameter.enumValues.restrictedMode = true;
|
|
|
|
{
|
|
|
|
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[6];
|
|
|
|
enumValues[0].value = 0;
|
|
|
|
enumValues[0].label = "Off";
|
|
|
|
enumValues[1].value = 1;
|
|
|
|
enumValues[1].label = "On";
|
|
|
|
enumValues[2].value = 2;
|
|
|
|
enumValues[2].label = "Oct1";
|
|
|
|
enumValues[3].value = 3;
|
|
|
|
enumValues[3].label = "PWM";
|
|
|
|
enumValues[3].value = 4;
|
|
|
|
enumValues[3].label = "Oct3";
|
|
|
|
enumValues[3].value = 5;
|
|
|
|
enumValues[3].label = "Oct1+3";
|
|
|
|
parameter.enumValues.values = enumValues;
|
|
|
|
}
|
|
|
|
break;
|
2025-01-07 14:02:31 +00:00
|
|
|
|
|
|
|
case pSubMode:
|
|
|
|
// set up Sub slider
|
|
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
|
|
parameter.name = "Sub";
|
|
|
|
parameter.symbol = "ao_sub";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 5.0f;
|
|
|
|
parameter.ranges.def = 1.0f;
|
|
|
|
parameter.enumValues.count = 6;
|
|
|
|
parameter.enumValues.restrictedMode = true;
|
|
|
|
{
|
|
|
|
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[6];
|
|
|
|
enumValues[0].value = 0;
|
|
|
|
enumValues[0].label = "-1 oct";
|
|
|
|
enumValues[1].value = 1;
|
|
|
|
enumValues[1].label = "-1 oct 25%";
|
|
|
|
enumValues[2].value = 2;
|
|
|
|
enumValues[2].label = "-1 oct + 2 oct";
|
|
|
|
enumValues[3].value = 3;
|
|
|
|
enumValues[3].label = "-1 oct + 3 oct";
|
|
|
|
enumValues[3].value = 4;
|
|
|
|
enumValues[3].label = "-2 oct";
|
|
|
|
enumValues[3].value = 5;
|
|
|
|
enumValues[3].label = "-2 oct 25%";
|
|
|
|
parameter.enumValues.values = enumValues;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case pSubLevel:
|
|
|
|
// set up Sub slider
|
|
|
|
parameter.hints = kParameterIsAutomatable;
|
|
|
|
parameter.name = "Sub Level";
|
|
|
|
parameter.symbol = "ao_sublev";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 1.0f;
|
|
|
|
parameter.ranges.def = 0.0f;
|
|
|
|
break;
|
|
|
|
case pPWMRate:
|
|
|
|
// set up PWM Rate slider
|
|
|
|
parameter.hints = kParameterIsAutomatable;
|
|
|
|
parameter.name = "PWM Rate";
|
|
|
|
parameter.symbol = "ao_pwmrate";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 1.0f;
|
|
|
|
parameter.ranges.def = 0.5f;
|
|
|
|
break;
|
|
|
|
case pPWMDepth:
|
|
|
|
// set up PWM Depth slider
|
|
|
|
parameter.hints = kParameterIsAutomatable;
|
|
|
|
parameter.name = "PWM Depth";
|
|
|
|
parameter.symbol = "ao_pwmdepth";
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
parameter.ranges.max = 1.0f;
|
|
|
|
parameter.ranges.def = 0.5f;
|
|
|
|
break;
|
2025-01-07 12:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AlphaOsc::setParameterValue(uint32_t index, float value) {
|
|
|
|
switch (index) {
|
|
|
|
case pSqrMode:
|
2025-01-08 01:24:12 +00:00
|
|
|
sqrmode = (uint8_t)value;
|
2025-01-07 12:04:48 +00:00
|
|
|
break;
|
|
|
|
case pSawMode:
|
2025-01-08 01:24:12 +00:00
|
|
|
sawmode = (uint8_t)value;
|
2025-01-07 12:04:48 +00:00
|
|
|
break;
|
2025-01-07 14:02:31 +00:00
|
|
|
case pSubMode:
|
2025-01-08 01:24:12 +00:00
|
|
|
submode = (uint8_t)value;
|
2025-01-07 14:02:31 +00:00
|
|
|
break;
|
|
|
|
case pSubLevel:
|
|
|
|
sublevel = value;
|
|
|
|
break;
|
|
|
|
case pPWMDepth:
|
|
|
|
pwmdepth = value;
|
|
|
|
break;
|
|
|
|
case pPWMRate:
|
|
|
|
pwmrate = value;
|
|
|
|
break;
|
2025-01-07 12:04:48 +00:00
|
|
|
}
|
|
|
|
// we don't need to handle a default condition
|
|
|
|
// if there's a parameter left unhandled, it's probably
|
|
|
|
// a mistake by the plugin host, and we don't much care
|
|
|
|
}
|
|
|
|
|
|
|
|
float AlphaOsc::getParameterValue(uint32_t index) const {
|
|
|
|
switch (index) {
|
|
|
|
case pSqrMode:
|
2025-01-08 01:24:12 +00:00
|
|
|
return (float)sqrmode;
|
2025-01-07 12:04:48 +00:00
|
|
|
case pSawMode:
|
2025-01-08 01:24:12 +00:00
|
|
|
return (float)sawmode;
|
|
|
|
case pSubMode:
|
|
|
|
return (float)submode;
|
|
|
|
case pSubLevel:
|
|
|
|
return sublevel;
|
|
|
|
case pPWMDepth:
|
|
|
|
return pwmdepth;
|
|
|
|
case pPWMRate:
|
|
|
|
return pwmrate;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
2025-01-07 12:04:48 +00:00
|
|
|
}
|
|
|
|
// if we fall all the way through...
|
2025-01-08 02:11:03 +00:00
|
|
|
return 2;
|
2025-01-07 12:04:48 +00:00
|
|
|
}
|