Skip to content

Commit

Permalink
Make Twist optionally exclude Engine from Randomization (#885)
Browse files Browse the repository at this point in the history
* Make Twist optionally exclude Engine from Randomization

Closes #884
  • Loading branch information
baconpaul committed May 21, 2023
1 parent a18ac70 commit 7929a65
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/VCO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,6 @@ VCOWidget<oscType>::VCOWidget(VCOWidget<oscType>::M *module) : XTModuleWidget()
return "TRIG";
}
return VCOConfig<oscType>::retriggerLabel();
;
};
addChild(lab);
}
Expand Down
2 changes: 1 addition & 1 deletion src/VCO.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ template <int oscType> struct VCO : public modules::XTModule
configParamNoRand(ABSOLUTE_UNISON, 0, 1, 0, "Absolute Unison");
configParam(CHARACTER, 0, 2, 1, "Character Filter");
configParam(DRIFT, 0, 1, 0, "Oscillator Drift", "%", 0, 100);
configParam(FIXED_ATTENUATION, 0, 1, 1, "Output Attenuation");
configParam(FIXED_ATTENUATION, 0, 1, 1, "Output Level", "%", 0, 100);

VCOConfig<oscType>::configureVCOSpecificParameters(this);
config_osc->~Oscillator();
Expand Down
7 changes: 7 additions & 0 deletions src/XTModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ struct XTModule : public rack::Module
{
return configSwitch<T>(paramId, 0, 1, defaultValue, name, {"Off", "On"});
}
template <typename T = rack::SwitchQuantity>
T *configOnOffNoRand(int paramId, float defaultValue, const std::string &name)
{
auto r = configSwitch<T>(paramId, 0, 1, defaultValue, name, {"Off", "On"});
r->randomizeEnabled = false;
return r;
}

void snapCalculatedNames();

Expand Down
22 changes: 21 additions & 1 deletion src/vcoconfig/Twist.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ template <> void VCOConfig<ot_twist>::oscillatorSpecificSetup(VCO<ot_twist> *m)
template <> inline void VCOConfig<ot_twist>::configureVCOSpecificParameters(VCO<ot_twist> *m)
{
m->configOnOff(VCO<ot_twist>::ARBITRARY_SWITCH_0 + 0, 0, "Enable LPG on Trigger");
m->configOnOffNoRand(VCO<ot_twist>::ARBITRARY_SWITCH_0 + 1, 0, "Randomize Includes Engine");

m->intStateForConfig[0] = m->inputs[VCO<ot_twist>::RETRIGGER].isConnected();
m->intStateForConfig[1] = m->oscstorage->p[TwistOscillator::twist_lpg_response].deactivated;
for (int i = 1; i < VCO<ot_twist>::n_arbitrary_switches; ++i)
for (int i = 2; i < VCO<ot_twist>::n_arbitrary_switches; ++i)
{
m->configParam(VCO<ot_twist>::ARBITRARY_SWITCH_0 + i, 0, 1, 0, "Unused");
}
Expand Down Expand Up @@ -260,6 +261,13 @@ template <> void VCOConfig<ot_twist>::processVCOSpecificParameters(VCO<ot_twist>
deact = true;
s->p[TwistOscillator::twist_lpg_response].deactivated = deact;
}

auto l1 = (bool)(m->params[VCO<ot_twist>::ARBITRARY_SWITCH_0 + 1].getValue() > 0.5);
auto epq = m->paramQuantities[VCO<ot_twist>::OSC_CTRL_PARAM_0 + TwistOscillator::twist_engine];
if (epq->randomizeEnabled != l1)
{
epq->randomizeEnabled = l1;
}
}

template <> bool VCOConfig<ot_twist>::getVCOSpecificReInit(VCO<ot_twist> *m)
Expand Down Expand Up @@ -293,6 +301,18 @@ void VCOConfig<ot_twist>::oscillatorReInit(VCO<ot_twist> *m, Oscillator *o, floa
o->init(pitch0);
}
}

template <> void VCOConfig<ot_twist>::addMenuItems(VCO<ot_twist> *m, rack::ui::Menu *toThis)
{
auto l1 = (int)std::round(m->params[VCO<ot_twist>::ARBITRARY_SWITCH_0 + 1].getValue());

toThis->addChild(rack::createMenuItem("Randomize Twist Engine", CHECKMARK(l1), [m, l1]() {
m->params[VCO<ot_twist>::ARBITRARY_SWITCH_0 + 1].setValue(l1 ? 0 : 1);
m->paramQuantities[VCO<ot_twist>::OSC_CTRL_PARAM_0 + TwistOscillator::twist_engine]
->randomizeEnabled = !l1;
}));
}

} // namespace sst::surgext_rack::vco

#endif

0 comments on commit 7929a65

Please sign in to comment.