Make Host Parameters smoothing optional
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
e768dbd0e6
commit
8d1138f926
1 changed files with 34 additions and 4 deletions
|
@ -38,6 +38,7 @@ struct HostParameters : TerminalModule {
|
|||
rack::dsp::SlewLimiter parameters[kModuleParameters];
|
||||
bool parametersConnected[kModuleParameters] = {};
|
||||
bool bypassed = false;
|
||||
bool smooth = true;
|
||||
uint32_t lastProcessCounter = 0;
|
||||
|
||||
HostParameters()
|
||||
|
@ -76,7 +77,8 @@ struct HostParameters : TerminalModule {
|
|||
for (uint32_t i=0; i<kModuleParameters; ++i)
|
||||
{
|
||||
if (parametersConnected[i])
|
||||
outputs[i].setVoltage(parameters[i].process(args.sampleTime, pcontext->parameters[i]));
|
||||
outputs[i].setVoltage(smooth ? parameters[i].process(args.sampleTime, pcontext->parameters[i])
|
||||
: pcontext->parameters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +95,25 @@ struct HostParameters : TerminalModule {
|
|||
parameters[i].setRiseFall(fall, fall);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// save and load json stuff
|
||||
|
||||
json_t* dataToJson() override
|
||||
{
|
||||
json_t* const rootJ = json_object();
|
||||
DISTRHO_SAFE_ASSERT_RETURN(rootJ != nullptr, nullptr);
|
||||
|
||||
json_object_set_new(rootJ, "smooth", json_boolean(smooth));
|
||||
|
||||
return rootJ;
|
||||
}
|
||||
|
||||
void dataFromJson(json_t* const rootJ) override
|
||||
{
|
||||
if (json_t* const smoothJ = json_object_get(rootJ, "smooth"))
|
||||
smooth = json_boolean_value(smoothJ);
|
||||
}
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -117,9 +138,12 @@ struct HostParametersWidget : ModuleWidgetWith9HP {
|
|||
static constexpr const float paddingH = 30.0f;
|
||||
static constexpr const float paddingV = 49.0f;
|
||||
|
||||
HostParametersWidget(HostParameters* const module)
|
||||
HostParameters* const module;
|
||||
|
||||
HostParametersWidget(HostParameters* const m)
|
||||
: module(m)
|
||||
{
|
||||
setModule(module);
|
||||
setModule(m);
|
||||
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostParameters.svg")));
|
||||
createAndAddScrews();
|
||||
|
||||
|
@ -127,7 +151,7 @@ struct HostParametersWidget : ModuleWidgetWith9HP {
|
|||
{
|
||||
const float x = startX + int(i / 6) * paddingH;
|
||||
const float y = startY + int(i % 6) * paddingV;
|
||||
addOutput(createOutput<CardinalParameterPJ301MPort>(Vec(x, y), module, i));
|
||||
addOutput(createOutput<CardinalParameterPJ301MPort>(Vec(x, y), m, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,6 +184,12 @@ struct HostParametersWidget : ModuleWidgetWith9HP {
|
|||
|
||||
ModuleWidgetWith9HP::draw(args);
|
||||
}
|
||||
|
||||
void appendContextMenu(Menu* const menu) override
|
||||
{
|
||||
menu->addChild(new MenuSeparator);
|
||||
menu->addChild(createBoolPtrMenuItem("Smooth", "", &module->smooth));
|
||||
}
|
||||
};
|
||||
#else
|
||||
struct HostParametersWidget : ModuleWidget {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue