/* Alpha Oscillator POC Copyright 2024 Gordon JC Pearce 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; } } void AlphaOsc::setParameterValue(uint32_t index, float value) { switch (index) { case pSqrMode: sqrmode = value; break; case pSawMode: sawmode = value; break; } // 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: return sqrmode; case pSawMode: return sawmode; } // if we fall all the way through... return 0; }