/* Peacock-8 VA polysynth 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 "ic29.hpp" #include "peacock.hpp" void Peacock::initParameter(uint32_t index, Parameter& parameter) { switch (index) { case p_lfoRate: parameter.hints = kParameterIsAutomatable; parameter.name = "LFO Rate"; parameter.symbol = "pfau_lforate"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 48.0f; parameter.midiCC = 3; break; case p_lfoDelay: parameter.hints = kParameterIsAutomatable; parameter.name = "LFO Delay"; parameter.symbol = "pfau_lfodelay"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 9; break; case p_vcoRange: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; parameter.name = "Range"; parameter.symbol = "pfau_vcorange"; parameter.ranges.min = 0.0f; parameter.ranges.max = 2.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 12; parameter.enumValues.count = 3; parameter.enumValues.restrictedMode = true; { ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[3]; enumValues[0].value = 0.0f; enumValues[0].label = "16'"; enumValues[1].value = 1.0f; enumValues[1].label = "8'"; enumValues[2].value = 2.0f; enumValues[2].label = "4'"; parameter.enumValues.values = enumValues; } break; case p_vcoLfoMod: parameter.hints = kParameterIsAutomatable; parameter.name = "LFO"; parameter.symbol = "pfau_lfo"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 10.0f; parameter.midiCC = 13; break; case p_pwmLfoMod: parameter.hints = kParameterIsAutomatable; parameter.name = "PWM"; parameter.symbol = "pfau_pwm"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 48.0f; parameter.midiCC = 14; break; case p_pwmMode: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "PWM Mode"; parameter.symbol = "pfau_pwmmode"; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 15; parameter.enumValues.count = 2; parameter.enumValues.restrictedMode = true; { ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; enumValues[0].value = 0.0f; enumValues[0].label = "LFO"; enumValues[1].value = 1.0f; enumValues[1].label = "MAN"; parameter.enumValues.values = enumValues; } break; case p_sawOn: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "Saw"; parameter.symbol = "pfau_saw"; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 17; break; case p_sqrOn: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "Square"; parameter.symbol = "pfau_sqr"; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 16; break; case p_subLevel: parameter.hints = kParameterIsAutomatable; parameter.name = "Sub Osc"; parameter.symbol = "pfau_sub"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 18; break; case p_noiseLevel: parameter.hints = kParameterIsAutomatable; parameter.name = "Noise"; parameter.symbol = "pfau_noise"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 19; break; case p_hpfMode: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; parameter.name = "HPF"; parameter.symbol = "pfau_hpf"; parameter.ranges.min = 0.0f; parameter.ranges.max = 3.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 20; break; case p_vcfCutoff: parameter.hints = kParameterIsAutomatable; parameter.name = "Freq"; parameter.symbol = "pfau_freq"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 60.0f; parameter.midiCC = 74; break; case p_vcfReso: parameter.hints = kParameterIsAutomatable; parameter.name = "Res"; parameter.symbol = "pfau_reso"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 71; break; case p_vcfEnvPol: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; parameter.name = "Polarity"; parameter.symbol = "pfau_vcfmode"; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 21; parameter.enumValues.count = 2; parameter.enumValues.restrictedMode = true; { ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; enumValues[0].value = 0.0f; enumValues[0].label = "POS"; enumValues[1].value = 1.0f; enumValues[1].label = "INV"; parameter.enumValues.values = enumValues; } break; case p_vcfEnvMod: parameter.hints = kParameterIsAutomatable; parameter.name = "Env"; parameter.symbol = "pfau_vcfenvmod"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 46.0f; parameter.midiCC = 22; break; case p_vcfLFoMod: parameter.hints = kParameterIsAutomatable; parameter.name = "LFO"; parameter.symbol = "pfau_vcflfomod"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 0.0f; parameter.midiCC = 23; break; case p_vcfKeyTrk: parameter.hints = kParameterIsAutomatable; parameter.name = "Kybd"; parameter.symbol = "pfau_vcfkeymod"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 71.0f; parameter.midiCC = 24; break; case p_attack: parameter.hints = kParameterIsAutomatable; parameter.name = "Attack"; parameter.symbol = "pfau_attack"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 27.0f; parameter.midiCC = 73; break; case p_decay: parameter.hints = kParameterIsAutomatable; parameter.name = "Decay"; parameter.symbol = "pfau_decay"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 57.0f; parameter.midiCC = 75; break; case p_sustain: parameter.hints = kParameterIsAutomatable; parameter.name = "Sustain"; parameter.symbol = "pfau_sustain"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 57.0f; parameter.midiCC = 27; break; case p_release: parameter.hints = kParameterIsAutomatable; parameter.name = "Release"; parameter.symbol = "pfau_release"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 48.0f; parameter.midiCC = 72; break; case p_vcaEnvGate: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; // | kParameterIsBoolean; parameter.name = "Gate"; parameter.symbol = "pfau_envgate"; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; parameter.ranges.def = 1.0f; parameter.midiCC = 25; parameter.enumValues.count = 2; parameter.enumValues.restrictedMode = true; { ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; enumValues[0].value = 0.0f; enumValues[0].label = "ENV"; enumValues[1].value = 1.0f; enumValues[1].label = "GATE"; parameter.enumValues.values = enumValues; } break; case p_vcaLevel: parameter.hints = kParameterIsAutomatable; parameter.name = "VCA Level"; parameter.symbol = "pfau_vcalevel"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 40.0f; parameter.midiCC = 26; break; case p_vcoBend: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; parameter.name = "VCO Bend"; parameter.symbol = "pfau_vcobend"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 43.0f; break; case p_vcfBend: parameter.hints = kParameterIsAutomatable | kParameterIsInteger; parameter.name = "VCF Bend"; parameter.symbol = "pfau_vcfbend"; parameter.ranges.min = 0.0f; parameter.ranges.max = 127.0f; parameter.ranges.def = 43.0f; break; } // chorus, porta, bend range, key mode still to do } void Peacock::setParameterValue(uint32_t index, float value) { // should be trapped by host, but let's be safe if (value < 0.0f) value = 0.0f; if (value > 127.0f) value = 127.0f; switch (index) { case p_lfoRate: ic29.patchRam.lfoRate = value; break; case p_lfoDelay: ic29.patchRam.lfoDelay = value; break; case p_vcoLfoMod: ic29.patchRam.vcoLfoMod = value; break; case p_pwmLfoMod: ic29.patchRam.pwmLfoMod = value / 1.27; break; case p_subLevel: ic29.patchRam.subLevel = value; break; case p_noiseLevel: ic29.patchRam.noiseLevel = value; break; case p_vcfCutoff: ic29.patchRam.vcfCutoff = value; break; case p_vcfReso: ic29.patchRam.vcfReso = value; break; case p_vcfEnvMod: ic29.patchRam.vcfEnvMod = value; break; case p_vcfLFoMod: ic29.patchRam.vcfLfoMod = value; break; case p_vcfKeyTrk: ic29.patchRam.vcfKeyTrk = value; break; case p_vcaLevel: ic29.patchRam.vcaLevel = value; break; case p_attack: ic29.patchRam.attack = value; break; case p_decay: ic29.patchRam.decay = value; break; case p_sustain: ic29.patchRam.sustain = value; break; case p_release: ic29.patchRam.release = value; break; // switch 1 params case p_vcoRange: // bits 0-2 of switch 1 // doesn't look great in Carla because of odd behaviour with small integer knobs ic29.patchRam.switch1 &= 0xf8; ic29.patchRam.switch1 |= (1 << (uint8_t)(value - 1)); break; case p_sqrOn: // bit 3 of switch 1 ic29.patchRam.switch1 &= 0xf7; ic29.patchRam.switch1 |= (value >= 0.5) << 3; break; case p_sawOn: // bit 4 of switch 1 ic29.patchRam.switch1 &= 0xef; ic29.patchRam.switch1 |= (value >= 0.5) << 4; break; // missing chorus switch // switch 2 params case p_pwmMode: // bit 0 of switch 2 ic29.patchRam.switch2 &= 0xfe; ic29.patchRam.switch2 |= (value >= 0.5); break; case p_vcfEnvPol: // bit 1 of switch 2 ic29.patchRam.switch2 &= 0xfd; ic29.patchRam.switch2 |= (value >= 0.5) << 1; break; case p_vcaEnvGate: ic29.patchRam.switch2 &= 0xfb; ic29.patchRam.switch2 |= (value >= 0.5) << 2; break; case p_hpfMode: // bits 3-4 of switch 2 // doesn't look great in Carla because of odd behaviour with small integer knobs if (value > 3) value = 3; ic29.patchRam.switch2 &= 0xf3; ic29.patchRam.switch2 |= (uint8_t)value << 3; break; case p_vcoBend: ic29.vcoBend = (uint8_t)value; break; } }