From 03c135954f023337a9a1efbdc1f2c39661657fc1 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 8 Nov 2021 15:36:56 -0500 Subject: [PATCH] Add backward compatible CV attenuverter deserialization to WTLFO, WTVCO, and ADSR. --- src/ADSR.cpp | 10 ++++++++++ src/Delay.cpp | 4 ++-- src/SEQ3.cpp | 22 +++++++++++----------- src/WTLFO.cpp | 6 ++++++ src/WTVCO.cpp | 6 ++++++ 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/ADSR.cpp b/src/ADSR.cpp index 13accbd..d6ddacb 100644 --- a/src/ADSR.cpp +++ b/src/ADSR.cpp @@ -183,6 +183,16 @@ struct ADSR : Module { lights[PUSH_LIGHT].setBrightness(anyGate); } } + + void paramsFromJson(json_t* rootJ) override { + // These attenuators didn't exist in version <2.0, so set to 1 in case they are not overwritten. + params[ATTACK_CV_PARAM].setValue(1.f); + params[DECAY_CV_PARAM].setValue(1.f); + params[SUSTAIN_CV_PARAM].setValue(1.f); + params[RELEASE_CV_PARAM].setValue(1.f); + + Module::paramsFromJson(rootJ); + } }; diff --git a/src/Delay.cpp b/src/Delay.cpp index 7238157..f0ab468 100644 --- a/src/Delay.cpp +++ b/src/Delay.cpp @@ -193,7 +193,7 @@ struct Delay : Module { } } - void fromJson(json_t* rootJ) override { + void paramsFromJson(json_t* rootJ) override { // These attenuators didn't exist in version <2.0, so set to 1 in case they are not overwritten. params[FEEDBACK_CV_PARAM].setValue(1.f); params[TONE_CV_PARAM].setValue(1.f); @@ -201,7 +201,7 @@ struct Delay : Module { // The time input scaling has changed, so don't set to 1. // params[TIME_CV_PARAM].setValue(1.f); - Module::fromJson(rootJ); + Module::paramsFromJson(rootJ); } }; diff --git a/src/SEQ3.cpp b/src/SEQ3.cpp index d0813e9..7be5e93 100644 --- a/src/SEQ3.cpp +++ b/src/SEQ3.cpp @@ -6,7 +6,7 @@ struct SEQ3 : Module { TEMPO_PARAM, RUN_PARAM, RESET_PARAM, - STEPS_PARAM, + TRIG_PARAM, ENUMS(CV_PARAMS, 3 * 8), ENUMS(GATE_PARAMS, 8), // added in 2.0 @@ -24,7 +24,7 @@ struct SEQ3 : Module { NUM_INPUTS }; enum OutputIds { - GATE_OUTPUT, + TRIG_OUTPUT, ENUMS(CV_OUTPUTS, 3), ENUMS(STEP_OUTPUTS, 8), // added in 2.0 @@ -69,18 +69,18 @@ struct SEQ3 : Module { getParamQuantity(TEMPO_CV_PARAM)->randomizeEnabled = false; configButton(RUN_PARAM, "Run"); configButton(RESET_PARAM, "Reset"); - configParam(STEPS_PARAM, 1.f, 8.f, 8.f, "Steps"); - getParamQuantity(STEPS_PARAM)->randomizeEnabled = false; + configParam(TRIG_PARAM, 1.f, 8.f, 8.f, "Steps"); + getParamQuantity(TRIG_PARAM)->randomizeEnabled = false; configParam(STEPS_CV_PARAM, 0.f, 1.f, 1.f, "Steps CV", "%", 0, 100); getParamQuantity(STEPS_CV_PARAM)->randomizeEnabled = false; - paramQuantities[STEPS_PARAM]->snapEnabled = true; + paramQuantities[TRIG_PARAM]->snapEnabled = true; for (int j = 0; j < 3; j++) { for (int i = 0; i < 8; i++) { configParam(CV_PARAMS + 8 * j + i, -10.f, 10.f, 0.f, string::f("CV %d step %d", j + 1, i + 1), " V"); } } for (int i = 0; i < 8; i++) { - configButton(GATE_PARAMS + i, string::f("Step %d gate", i + 1)); + configButton(GATE_PARAMS + i, string::f("Step %d trigger", i + 1)); } configInput(TEMPO_INPUT, "Tempo"); @@ -95,7 +95,7 @@ struct SEQ3 : Module { for (int j = 0; j < 3; j++) { configOutput(CV_OUTPUTS + j, string::f("CV %d", j + 1)); } - configOutput(GATE_OUTPUT, "Trigger"); + configOutput(TRIG_OUTPUT, "Trigger"); configOutput(STEPS_OUTPUT, "Steps"); configOutput(CLOCK_OUTPUT, "Clock"); configOutput(RUN_OUTPUT, "Run"); @@ -185,7 +185,7 @@ struct SEQ3 : Module { } // Get number of steps - float steps = params[STEPS_PARAM].getValue() + inputs[STEPS_INPUT].getVoltage() * params[STEPS_CV_PARAM].getValue(); + float steps = params[TRIG_PARAM].getValue() + inputs[STEPS_INPUT].getVoltage() * params[STEPS_CV_PARAM].getValue(); int numSteps = (int) clamp(std::round(steps), 1.f, 8.f); // Advance step @@ -215,7 +215,7 @@ struct SEQ3 : Module { outputs[CV_OUTPUTS + 0].setVoltage(params[CV_PARAMS + 8 * 0 + index].getValue()); outputs[CV_OUTPUTS + 1].setVoltage(params[CV_PARAMS + 8 * 1 + index].getValue()); outputs[CV_OUTPUTS + 2].setVoltage(params[CV_PARAMS + 8 * 2 + index].getValue()); - outputs[GATE_OUTPUT].setVoltage((clockGate && gates[index]) ? 10.f : 0.f); + outputs[TRIG_OUTPUT].setVoltage((clockGate && gates[index]) ? 10.f : 0.f); outputs[STEPS_OUTPUT].setVoltage((numSteps - 1) * 1.f); outputs[CLOCK_OUTPUT].setVoltage(clockGate ? 10.f : 0.f); @@ -273,7 +273,7 @@ struct SEQ3Widget : ModuleWidget { addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); addParam(createParamCentered(mm2px(Vec(11.753, 26.755)), module, SEQ3::TEMPO_PARAM)); - addParam(createParamCentered(mm2px(Vec(32.077, 26.782)), module, SEQ3::STEPS_PARAM)); + addParam(createParamCentered(mm2px(Vec(32.077, 26.782)), module, SEQ3::TRIG_PARAM)); addParam(createParamCentered(mm2px(Vec(49.372, 34.066)), module, SEQ3::TEMPO_CV_PARAM)); addParam(createLightParamCentered>>(mm2px(Vec(88.424, 33.679)), module, SEQ3::RUN_PARAM, SEQ3::RUN_LIGHT)); addParam(createParamCentered(mm2px(Vec(62.39, 34.066)), module, SEQ3::STEPS_CV_PARAM)); @@ -333,7 +333,7 @@ struct SEQ3Widget : ModuleWidget { addOutput(createOutputCentered(mm2px(Vec(10.319, 113.115)), module, SEQ3::CV_OUTPUTS + 0)); addOutput(createOutputCentered(mm2px(Vec(23.336, 113.115)), module, SEQ3::CV_OUTPUTS + 1)); addOutput(createOutputCentered(mm2px(Vec(36.354, 113.115)), module, SEQ3::CV_OUTPUTS + 2)); - addOutput(createOutputCentered(mm2px(Vec(49.371, 113.115)), module, SEQ3::GATE_OUTPUT)); + addOutput(createOutputCentered(mm2px(Vec(49.371, 113.115)), module, SEQ3::TRIG_OUTPUT)); addOutput(createOutputCentered(mm2px(Vec(62.389, 113.115)), module, SEQ3::STEPS_OUTPUT)); addOutput(createOutputCentered(mm2px(Vec(75.406, 113.115)), module, SEQ3::CLOCK_OUTPUT)); addOutput(createOutputCentered(mm2px(Vec(88.424, 113.115)), module, SEQ3::RUN_OUTPUT)); diff --git a/src/WTLFO.cpp b/src/WTLFO.cpp index 29cc063..16db004 100644 --- a/src/WTLFO.cpp +++ b/src/WTLFO.cpp @@ -223,6 +223,12 @@ struct WTLFO : Module { } } + void paramsFromJson(json_t* rootJ) override { + // In <2.0, there were no attenuverters, so set them to 1.0 in case they are not overwritten. + params[POS_CV_PARAM].setValue(1.f); + Module::paramsFromJson(rootJ); + } + json_t* dataToJson() override { json_t* rootJ = json_object(); // Merge wavetable diff --git a/src/WTVCO.cpp b/src/WTVCO.cpp index 6c8576a..63451f5 100644 --- a/src/WTVCO.cpp +++ b/src/WTVCO.cpp @@ -258,6 +258,12 @@ struct WTVCO : Module { } } + void paramsFromJson(json_t* rootJ) override { + // In <2.0, there were no attenuverters, so set them to 1.0 in case they are not overwritten. + params[POS_CV_PARAM].setValue(1.f); + Module::paramsFromJson(rootJ); + } + json_t* dataToJson() override { json_t* rootJ = json_object(); // Merge wavetable