diff --git a/plugins/Cardinal/src/HostParameters.cpp b/plugins/Cardinal/src/HostParameters.cpp index 5ae63cc..a2e57ae 100644 --- a/plugins/Cardinal/src/HostParameters.cpp +++ b/plugins/Cardinal/src/HostParameters.cpp @@ -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; iparameters[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(Vec(x, y), module, i)); + addOutput(createOutput(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 {