From 16c137947c71b71a5f9eda3ecb590dfa4f5d0818 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 4 Jan 2019 16:58:19 -0500 Subject: [PATCH] Update to Rack v1 compatibility header --- src/8vert.cpp | 74 ++++++++++++++-------------- src/ADSR.cpp | 48 +++++++++--------- src/Delay.cpp | 32 ++++++------ src/LFO.cpp | 78 +++++++++++++++--------------- src/Mutes.cpp | 102 +++++++++++++++++++-------------------- src/SEQ3.cpp | 64 ++++++++++++------------ src/Scope.cpp | 48 +++++++++--------- src/SequentialSwitch.cpp | 60 +++++++++++------------ src/Unity.cpp | 84 ++++++++++++++++---------------- src/VCA.cpp | 68 ++++++++++++++------------ src/VCF.cpp | 36 +++++++------- src/VCMixer.cpp | 48 +++++++++--------- src/VCO.cpp | 78 +++++++++++++++--------------- 13 files changed, 413 insertions(+), 407 deletions(-) diff --git a/src/8vert.cpp b/src/8vert.cpp index 4ae2e18..9b53c7e 100644 --- a/src/8vert.cpp +++ b/src/8vert.cpp @@ -38,47 +38,47 @@ struct _8vertWidget : ModuleWidget { _8vertWidget::_8vertWidget(_8vert *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/8vert.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x - 30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x - 30, 365))); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x - 30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x - 30, 365))); - addParam(ParamWidget::create(Vec(45.308, 47.753), module, 0, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 86.198), module, 1, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 124.639), module, 2, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 163.084), module, 3, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 201.529), module, 4, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 239.974), module, 5, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 278.415), module, 6, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(45.308, 316.86), module, 7, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 47.753), module, 0, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 86.198), module, 1, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 124.639), module, 2, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 163.084), module, 3, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 201.529), module, 4, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 239.974), module, 5, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 278.415), module, 6, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(45.308, 316.86), module, 7, -1.0f, 1.0f, 0.0f)); - addInput(Port::create(Vec(9.507, 50.397), Port::INPUT, module, 0)); - addInput(Port::create(Vec(9.507, 88.842), Port::INPUT, module, 1)); - addInput(Port::create(Vec(9.507, 127.283), Port::INPUT, module, 2)); - addInput(Port::create(Vec(9.507, 165.728), Port::INPUT, module, 3)); - addInput(Port::create(Vec(9.507, 204.173), Port::INPUT, module, 4)); - addInput(Port::create(Vec(9.507, 242.614), Port::INPUT, module, 5)); - addInput(Port::create(Vec(9.507, 281.059), Port::INPUT, module, 6)); - addInput(Port::create(Vec(9.507, 319.504), Port::INPUT, module, 7)); + addInput(createPort(Vec(9.507, 50.397), PortWidget::INPUT, module, 0)); + addInput(createPort(Vec(9.507, 88.842), PortWidget::INPUT, module, 1)); + addInput(createPort(Vec(9.507, 127.283), PortWidget::INPUT, module, 2)); + addInput(createPort(Vec(9.507, 165.728), PortWidget::INPUT, module, 3)); + addInput(createPort(Vec(9.507, 204.173), PortWidget::INPUT, module, 4)); + addInput(createPort(Vec(9.507, 242.614), PortWidget::INPUT, module, 5)); + addInput(createPort(Vec(9.507, 281.059), PortWidget::INPUT, module, 6)); + addInput(createPort(Vec(9.507, 319.504), PortWidget::INPUT, module, 7)); - addOutput(Port::create(Vec(86.393, 50.397), Port::OUTPUT, module, 0)); - addOutput(Port::create(Vec(86.393, 88.842), Port::OUTPUT, module, 1)); - addOutput(Port::create(Vec(86.393, 127.283), Port::OUTPUT, module, 2)); - addOutput(Port::create(Vec(86.393, 165.728), Port::OUTPUT, module, 3)); - addOutput(Port::create(Vec(86.393, 204.173), Port::OUTPUT, module, 4)); - addOutput(Port::create(Vec(86.393, 242.614), Port::OUTPUT, module, 5)); - addOutput(Port::create(Vec(86.393, 281.059), Port::OUTPUT, module, 6)); - addOutput(Port::create(Vec(86.393, 319.504), Port::OUTPUT, module, 7)); + addOutput(createPort(Vec(86.393, 50.397), PortWidget::OUTPUT, module, 0)); + addOutput(createPort(Vec(86.393, 88.842), PortWidget::OUTPUT, module, 1)); + addOutput(createPort(Vec(86.393, 127.283), PortWidget::OUTPUT, module, 2)); + addOutput(createPort(Vec(86.393, 165.728), PortWidget::OUTPUT, module, 3)); + addOutput(createPort(Vec(86.393, 204.173), PortWidget::OUTPUT, module, 4)); + addOutput(createPort(Vec(86.393, 242.614), PortWidget::OUTPUT, module, 5)); + addOutput(createPort(Vec(86.393, 281.059), PortWidget::OUTPUT, module, 6)); + addOutput(createPort(Vec(86.393, 319.504), PortWidget::OUTPUT, module, 7)); - addChild(ModuleLightWidget::create>(Vec(107.702, 50.414), module, 0)); - addChild(ModuleLightWidget::create>(Vec(107.702, 88.859), module, 2)); - addChild(ModuleLightWidget::create>(Vec(107.702, 127.304), module, 4)); - addChild(ModuleLightWidget::create>(Vec(107.702, 165.745), module, 6)); - addChild(ModuleLightWidget::create>(Vec(107.702, 204.19), module, 8)); - addChild(ModuleLightWidget::create>(Vec(107.702, 242.635), module, 10)); - addChild(ModuleLightWidget::create>(Vec(107.702, 281.076), module, 12)); - addChild(ModuleLightWidget::create>(Vec(107.702, 319.521), module, 14)); + addChild(createLight>(Vec(107.702, 50.414), module, 0)); + addChild(createLight>(Vec(107.702, 88.859), module, 2)); + addChild(createLight>(Vec(107.702, 127.304), module, 4)); + addChild(createLight>(Vec(107.702, 165.745), module, 6)); + addChild(createLight>(Vec(107.702, 204.19), module, 8)); + addChild(createLight>(Vec(107.702, 242.635), module, 10)); + addChild(createLight>(Vec(107.702, 281.076), module, 12)); + addChild(createLight>(Vec(107.702, 319.521), module, 14)); } -Model *model_8vert = Model::create<_8vert, _8vertWidget>("8vert"); +Model *model_8vert = createModel<_8vert, _8vertWidget>("8vert"); diff --git a/src/ADSR.cpp b/src/ADSR.cpp index 45fd064..1eee24c 100644 --- a/src/ADSR.cpp +++ b/src/ADSR.cpp @@ -109,30 +109,30 @@ struct ADSRWidget : ModuleWidget { ADSRWidget::ADSRWidget(ADSR *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/ADSR.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); - - addParam(ParamWidget::create(Vec(62, 57), module, ADSR::ATTACK_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(62, 124), module, ADSR::DECAY_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(62, 191), module, ADSR::SUSTAIN_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(62, 257), module, ADSR::RELEASE_PARAM, 0.0f, 1.0f, 0.5f)); - - addInput(Port::create(Vec(9, 63), Port::INPUT, module, ADSR::ATTACK_INPUT)); - addInput(Port::create(Vec(9, 129), Port::INPUT, module, ADSR::DECAY_INPUT)); - addInput(Port::create(Vec(9, 196), Port::INPUT, module, ADSR::SUSTAIN_INPUT)); - addInput(Port::create(Vec(9, 263), Port::INPUT, module, ADSR::RELEASE_INPUT)); - - addInput(Port::create(Vec(9, 320), Port::INPUT, module, ADSR::GATE_INPUT)); - addInput(Port::create(Vec(48, 320), Port::INPUT, module, ADSR::TRIG_INPUT)); - addOutput(Port::create(Vec(87, 320), Port::OUTPUT, module, ADSR::ENVELOPE_OUTPUT)); - - addChild(ModuleLightWidget::create>(Vec(94, 41), module, ADSR::ATTACK_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(94, 109), module, ADSR::DECAY_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(94, 175), module, ADSR::SUSTAIN_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(94, 242), module, ADSR::RELEASE_LIGHT)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); + + addParam(createParam(Vec(62, 57), module, ADSR::ATTACK_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(62, 124), module, ADSR::DECAY_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(62, 191), module, ADSR::SUSTAIN_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(62, 257), module, ADSR::RELEASE_PARAM, 0.0f, 1.0f, 0.5f)); + + addInput(createPort(Vec(9, 63), PortWidget::INPUT, module, ADSR::ATTACK_INPUT)); + addInput(createPort(Vec(9, 129), PortWidget::INPUT, module, ADSR::DECAY_INPUT)); + addInput(createPort(Vec(9, 196), PortWidget::INPUT, module, ADSR::SUSTAIN_INPUT)); + addInput(createPort(Vec(9, 263), PortWidget::INPUT, module, ADSR::RELEASE_INPUT)); + + addInput(createPort(Vec(9, 320), PortWidget::INPUT, module, ADSR::GATE_INPUT)); + addInput(createPort(Vec(48, 320), PortWidget::INPUT, module, ADSR::TRIG_INPUT)); + addOutput(createPort(Vec(87, 320), PortWidget::OUTPUT, module, ADSR::ENVELOPE_OUTPUT)); + + addChild(createLight>(Vec(94, 41), module, ADSR::ATTACK_LIGHT)); + addChild(createLight>(Vec(94, 109), module, ADSR::DECAY_LIGHT)); + addChild(createLight>(Vec(94, 175), module, ADSR::SUSTAIN_LIGHT)); + addChild(createLight>(Vec(94, 242), module, ADSR::RELEASE_LIGHT)); } -Model *modelADSR = createModel("ADSR", "ADSR", ENVELOPE_GENERATOR_TAG); +Model *modelADSR = createModel("ADSR"); diff --git a/src/Delay.cpp b/src/Delay.cpp index e5e99e7..4df5a6f 100644 --- a/src/Delay.cpp +++ b/src/Delay.cpp @@ -117,22 +117,22 @@ struct DelayWidget : ModuleWidget { DelayWidget::DelayWidget(Delay *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/Delay.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); - - addParam(ParamWidget::create(Vec(67, 57), module, Delay::TIME_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(67, 123), module, Delay::FEEDBACK_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(67, 190), module, Delay::COLOR_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(67, 257), module, Delay::MIX_PARAM, 0.0f, 1.0f, 0.5f)); - - addInput(Port::create(Vec(14, 63), Port::INPUT, module, Delay::TIME_INPUT)); - addInput(Port::create(Vec(14, 129), Port::INPUT, module, Delay::FEEDBACK_INPUT)); - addInput(Port::create(Vec(14, 196), Port::INPUT, module, Delay::COLOR_INPUT)); - addInput(Port::create(Vec(14, 263), Port::INPUT, module, Delay::MIX_INPUT)); - addInput(Port::create(Vec(14, 320), Port::INPUT, module, Delay::IN_INPUT)); - addOutput(Port::create(Vec(73, 320), Port::OUTPUT, module, Delay::OUT_OUTPUT)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); + + addParam(createParam(Vec(67, 57), module, Delay::TIME_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(67, 123), module, Delay::FEEDBACK_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(67, 190), module, Delay::COLOR_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(67, 257), module, Delay::MIX_PARAM, 0.0f, 1.0f, 0.5f)); + + addInput(createPort(Vec(14, 63), PortWidget::INPUT, module, Delay::TIME_INPUT)); + addInput(createPort(Vec(14, 129), PortWidget::INPUT, module, Delay::FEEDBACK_INPUT)); + addInput(createPort(Vec(14, 196), PortWidget::INPUT, module, Delay::COLOR_INPUT)); + addInput(createPort(Vec(14, 263), PortWidget::INPUT, module, Delay::MIX_INPUT)); + addInput(createPort(Vec(14, 320), PortWidget::INPUT, module, Delay::IN_INPUT)); + addOutput(createPort(Vec(73, 320), PortWidget::OUTPUT, module, Delay::OUT_OUTPUT)); } diff --git a/src/LFO.cpp b/src/LFO.cpp index 6c4094c..3193ce6 100644 --- a/src/LFO.cpp +++ b/src/LFO.cpp @@ -127,31 +127,31 @@ struct LFOWidget : ModuleWidget { LFOWidget::LFOWidget(LFO *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/LFO-1.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); - - addParam(ParamWidget::create(Vec(15, 77), module, LFO::OFFSET_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(119, 77), module, LFO::INVERT_PARAM, 0.0f, 1.0f, 1.0f)); - - addParam(ParamWidget::create(Vec(47, 61), module, LFO::FREQ_PARAM, -8.0f, 10.0f, 1.0f)); - addParam(ParamWidget::create(Vec(23, 143), module, LFO::FM1_PARAM, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(91, 143), module, LFO::PW_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(23, 208), module, LFO::FM2_PARAM, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(91, 208), module, LFO::PWM_PARAM, 0.0f, 1.0f, 0.0f)); - - addInput(Port::create(Vec(11, 276), Port::INPUT, module, LFO::FM1_INPUT)); - addInput(Port::create(Vec(45, 276), Port::INPUT, module, LFO::FM2_INPUT)); - addInput(Port::create(Vec(80, 276), Port::INPUT, module, LFO::RESET_INPUT)); - addInput(Port::create(Vec(114, 276), Port::INPUT, module, LFO::PW_INPUT)); - - addOutput(Port::create(Vec(11, 320), Port::OUTPUT, module, LFO::SIN_OUTPUT)); - addOutput(Port::create(Vec(45, 320), Port::OUTPUT, module, LFO::TRI_OUTPUT)); - addOutput(Port::create(Vec(80, 320), Port::OUTPUT, module, LFO::SAW_OUTPUT)); - addOutput(Port::create(Vec(114, 320), Port::OUTPUT, module, LFO::SQR_OUTPUT)); - - addChild(ModuleLightWidget::create>(Vec(99, 42.5f), module, LFO::PHASE_POS_LIGHT)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); + + addParam(createParam(Vec(15, 77), module, LFO::OFFSET_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(119, 77), module, LFO::INVERT_PARAM, 0.0f, 1.0f, 1.0f)); + + addParam(createParam(Vec(47, 61), module, LFO::FREQ_PARAM, -8.0f, 10.0f, 1.0f)); + addParam(createParam(Vec(23, 143), module, LFO::FM1_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(91, 143), module, LFO::PW_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(23, 208), module, LFO::FM2_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(91, 208), module, LFO::PWM_PARAM, 0.0f, 1.0f, 0.0f)); + + addInput(createPort(Vec(11, 276), PortWidget::INPUT, module, LFO::FM1_INPUT)); + addInput(createPort(Vec(45, 276), PortWidget::INPUT, module, LFO::FM2_INPUT)); + addInput(createPort(Vec(80, 276), PortWidget::INPUT, module, LFO::RESET_INPUT)); + addInput(createPort(Vec(114, 276), PortWidget::INPUT, module, LFO::PW_INPUT)); + + addOutput(createPort(Vec(11, 320), PortWidget::OUTPUT, module, LFO::SIN_OUTPUT)); + addOutput(createPort(Vec(45, 320), PortWidget::OUTPUT, module, LFO::TRI_OUTPUT)); + addOutput(createPort(Vec(80, 320), PortWidget::OUTPUT, module, LFO::SAW_OUTPUT)); + addOutput(createPort(Vec(114, 320), PortWidget::OUTPUT, module, LFO::SQR_OUTPUT)); + + addChild(createLight>(Vec(99, 42.5f), module, LFO::PHASE_POS_LIGHT)); } @@ -220,25 +220,25 @@ struct LFO2Widget : ModuleWidget { LFO2Widget::LFO2Widget(LFO2 *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/LFO-2.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); - addParam(ParamWidget::create(Vec(62, 150), module, LFO2::OFFSET_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(62, 215), module, LFO2::INVERT_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(62, 150), module, LFO2::OFFSET_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(62, 215), module, LFO2::INVERT_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(18, 60), module, LFO2::FREQ_PARAM, -8.0f, 10.0f, 1.0f)); - addParam(ParamWidget::create(Vec(11, 142), module, LFO2::WAVE_PARAM, 0.0f, 3.0f, 1.5f)); - addParam(ParamWidget::create(Vec(11, 207), module, LFO2::FM_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(18, 60), module, LFO2::FREQ_PARAM, -8.0f, 10.0f, 1.0f)); + addParam(createParam(Vec(11, 142), module, LFO2::WAVE_PARAM, 0.0f, 3.0f, 1.5f)); + addParam(createParam(Vec(11, 207), module, LFO2::FM_PARAM, 0.0f, 1.0f, 0.5f)); - addInput(Port::create(Vec(11, 276), Port::INPUT, module, LFO2::FM_INPUT)); - addInput(Port::create(Vec(54, 276), Port::INPUT, module, LFO2::RESET_INPUT)); - addInput(Port::create(Vec(11, 319), Port::INPUT, module, LFO2::WAVE_INPUT)); + addInput(createPort(Vec(11, 276), PortWidget::INPUT, module, LFO2::FM_INPUT)); + addInput(createPort(Vec(54, 276), PortWidget::INPUT, module, LFO2::RESET_INPUT)); + addInput(createPort(Vec(11, 319), PortWidget::INPUT, module, LFO2::WAVE_INPUT)); - addOutput(Port::create(Vec(54, 319), Port::OUTPUT, module, LFO2::INTERP_OUTPUT)); + addOutput(createPort(Vec(54, 319), PortWidget::OUTPUT, module, LFO2::INTERP_OUTPUT)); - addChild(ModuleLightWidget::create>(Vec(68, 42.5f), module, LFO2::PHASE_POS_LIGHT)); + addChild(createLight>(Vec(68, 42.5f), module, LFO2::PHASE_POS_LIGHT)); } diff --git a/src/Mutes.cpp b/src/Mutes.cpp index 6506fa0..9f93210 100644 --- a/src/Mutes.cpp +++ b/src/Mutes.cpp @@ -42,7 +42,7 @@ struct Mutes : Module { } } - json_t *toJson() override { + json_t *dataToJson() override { json_t *rootJ = json_object(); // states json_t *statesJ = json_array(); @@ -53,7 +53,7 @@ struct Mutes : Module { json_object_set_new(rootJ, "states", statesJ); return rootJ; } - void fromJson(json_t *rootJ) override { + void dataFromJson(json_t *rootJ) override { // states json_t *statesJ = json_object_get(rootJ, "states"); if (statesJ) { @@ -94,55 +94,55 @@ struct MutesWidget : ModuleWidget { MutesWidget::MutesWidget(Mutes *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/Mutes.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x - 30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x - 30, 365))); - - addParam(ParamWidget::create(mm2px(Vec(16.57, 18.165)), module, Mutes::MUTE_PARAM + 0, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 28.164)), module, Mutes::MUTE_PARAM + 1, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 38.164)), module, Mutes::MUTE_PARAM + 2, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 48.165)), module, Mutes::MUTE_PARAM + 3, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 58.164)), module, Mutes::MUTE_PARAM + 4, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 68.165)), module, Mutes::MUTE_PARAM + 5, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 78.164)), module, Mutes::MUTE_PARAM + 6, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 88.164)), module, Mutes::MUTE_PARAM + 7, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 98.165)), module, Mutes::MUTE_PARAM + 8, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(16.57, 108.166)), module, Mutes::MUTE_PARAM + 9, 0.0f, 1.0f, 0.0f)); - - addInput(Port::create(mm2px(Vec(4.214, 17.81)), Port::INPUT, module, Mutes::IN_INPUT + 0)); - addInput(Port::create(mm2px(Vec(4.214, 27.809)), Port::INPUT, module, Mutes::IN_INPUT + 1)); - addInput(Port::create(mm2px(Vec(4.214, 37.809)), Port::INPUT, module, Mutes::IN_INPUT + 2)); - addInput(Port::create(mm2px(Vec(4.214, 47.81)), Port::INPUT, module, Mutes::IN_INPUT + 3)); - addInput(Port::create(mm2px(Vec(4.214, 57.81)), Port::INPUT, module, Mutes::IN_INPUT + 4)); - addInput(Port::create(mm2px(Vec(4.214, 67.809)), Port::INPUT, module, Mutes::IN_INPUT + 5)); - addInput(Port::create(mm2px(Vec(4.214, 77.81)), Port::INPUT, module, Mutes::IN_INPUT + 6)); - addInput(Port::create(mm2px(Vec(4.214, 87.81)), Port::INPUT, module, Mutes::IN_INPUT + 7)); - addInput(Port::create(mm2px(Vec(4.214, 97.809)), Port::INPUT, module, Mutes::IN_INPUT + 8)); - addInput(Port::create(mm2px(Vec(4.214, 107.809)), Port::INPUT, module, Mutes::IN_INPUT + 9)); - - addOutput(Port::create(mm2px(Vec(28.214, 17.81)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 0)); - addOutput(Port::create(mm2px(Vec(28.214, 27.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 1)); - addOutput(Port::create(mm2px(Vec(28.214, 37.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 2)); - addOutput(Port::create(mm2px(Vec(28.214, 47.81)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 3)); - addOutput(Port::create(mm2px(Vec(28.214, 57.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 4)); - addOutput(Port::create(mm2px(Vec(28.214, 67.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 5)); - addOutput(Port::create(mm2px(Vec(28.214, 77.81)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 6)); - addOutput(Port::create(mm2px(Vec(28.214, 87.81)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 7)); - addOutput(Port::create(mm2px(Vec(28.214, 97.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 8)); - addOutput(Port::create(mm2px(Vec(28.214, 107.809)), Port::OUTPUT, module, Mutes::OUT_OUTPUT + 9)); - - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 18.915)), module, Mutes::MUTE_LIGHT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 28.916)), module, Mutes::MUTE_LIGHT + 1)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 38.915)), module, Mutes::MUTE_LIGHT + 2)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 48.915)), module, Mutes::MUTE_LIGHT + 3)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 58.916)), module, Mutes::MUTE_LIGHT + 4)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 68.916)), module, Mutes::MUTE_LIGHT + 5)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 78.915)), module, Mutes::MUTE_LIGHT + 6)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 88.916)), module, Mutes::MUTE_LIGHT + 7)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 98.915)), module, Mutes::MUTE_LIGHT + 8)); - addChild(ModuleLightWidget::create>(mm2px(Vec(17.32, 108.915)), module, Mutes::MUTE_LIGHT + 9)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x - 30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x - 30, 365))); + + addParam(createParam(mm2px(Vec(16.57, 18.165)), module, Mutes::MUTE_PARAM + 0, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 28.164)), module, Mutes::MUTE_PARAM + 1, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 38.164)), module, Mutes::MUTE_PARAM + 2, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 48.165)), module, Mutes::MUTE_PARAM + 3, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 58.164)), module, Mutes::MUTE_PARAM + 4, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 68.165)), module, Mutes::MUTE_PARAM + 5, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 78.164)), module, Mutes::MUTE_PARAM + 6, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 88.164)), module, Mutes::MUTE_PARAM + 7, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 98.165)), module, Mutes::MUTE_PARAM + 8, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(16.57, 108.166)), module, Mutes::MUTE_PARAM + 9, 0.0f, 1.0f, 0.0f)); + + addInput(createPort(mm2px(Vec(4.214, 17.81)), PortWidget::INPUT, module, Mutes::IN_INPUT + 0)); + addInput(createPort(mm2px(Vec(4.214, 27.809)), PortWidget::INPUT, module, Mutes::IN_INPUT + 1)); + addInput(createPort(mm2px(Vec(4.214, 37.809)), PortWidget::INPUT, module, Mutes::IN_INPUT + 2)); + addInput(createPort(mm2px(Vec(4.214, 47.81)), PortWidget::INPUT, module, Mutes::IN_INPUT + 3)); + addInput(createPort(mm2px(Vec(4.214, 57.81)), PortWidget::INPUT, module, Mutes::IN_INPUT + 4)); + addInput(createPort(mm2px(Vec(4.214, 67.809)), PortWidget::INPUT, module, Mutes::IN_INPUT + 5)); + addInput(createPort(mm2px(Vec(4.214, 77.81)), PortWidget::INPUT, module, Mutes::IN_INPUT + 6)); + addInput(createPort(mm2px(Vec(4.214, 87.81)), PortWidget::INPUT, module, Mutes::IN_INPUT + 7)); + addInput(createPort(mm2px(Vec(4.214, 97.809)), PortWidget::INPUT, module, Mutes::IN_INPUT + 8)); + addInput(createPort(mm2px(Vec(4.214, 107.809)), PortWidget::INPUT, module, Mutes::IN_INPUT + 9)); + + addOutput(createPort(mm2px(Vec(28.214, 17.81)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 0)); + addOutput(createPort(mm2px(Vec(28.214, 27.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 1)); + addOutput(createPort(mm2px(Vec(28.214, 37.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 2)); + addOutput(createPort(mm2px(Vec(28.214, 47.81)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 3)); + addOutput(createPort(mm2px(Vec(28.214, 57.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 4)); + addOutput(createPort(mm2px(Vec(28.214, 67.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 5)); + addOutput(createPort(mm2px(Vec(28.214, 77.81)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 6)); + addOutput(createPort(mm2px(Vec(28.214, 87.81)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 7)); + addOutput(createPort(mm2px(Vec(28.214, 97.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 8)); + addOutput(createPort(mm2px(Vec(28.214, 107.809)), PortWidget::OUTPUT, module, Mutes::OUT_OUTPUT + 9)); + + addChild(createLight>(mm2px(Vec(17.32, 18.915)), module, Mutes::MUTE_LIGHT + 0)); + addChild(createLight>(mm2px(Vec(17.32, 28.916)), module, Mutes::MUTE_LIGHT + 1)); + addChild(createLight>(mm2px(Vec(17.32, 38.915)), module, Mutes::MUTE_LIGHT + 2)); + addChild(createLight>(mm2px(Vec(17.32, 48.915)), module, Mutes::MUTE_LIGHT + 3)); + addChild(createLight>(mm2px(Vec(17.32, 58.916)), module, Mutes::MUTE_LIGHT + 4)); + addChild(createLight>(mm2px(Vec(17.32, 68.916)), module, Mutes::MUTE_LIGHT + 5)); + addChild(createLight>(mm2px(Vec(17.32, 78.915)), module, Mutes::MUTE_LIGHT + 6)); + addChild(createLight>(mm2px(Vec(17.32, 88.916)), module, Mutes::MUTE_LIGHT + 7)); + addChild(createLight>(mm2px(Vec(17.32, 98.915)), module, Mutes::MUTE_LIGHT + 8)); + addChild(createLight>(mm2px(Vec(17.32, 108.915)), module, Mutes::MUTE_LIGHT + 9)); } -Model *modelMutes = Model::create("Mutes"); +Model *modelMutes = createModel("Mutes"); diff --git a/src/SEQ3.cpp b/src/SEQ3.cpp index fca98de..97534e4 100644 --- a/src/SEQ3.cpp +++ b/src/SEQ3.cpp @@ -64,7 +64,7 @@ struct SEQ3 : Module { } } - json_t *toJson() override { + json_t *dataToJson() override { json_t *rootJ = json_object(); // running @@ -80,7 +80,7 @@ struct SEQ3 : Module { return rootJ; } - void fromJson(json_t *rootJ) override { + void dataFromJson(json_t *rootJ) override { // running json_t *runningJ = json_object_get(rootJ, "running"); if (runningJ) @@ -164,43 +164,43 @@ struct SEQ3Widget : ModuleWidget { SEQ3Widget(SEQ3 *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/SEQ3.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); - - addParam(ParamWidget::create(Vec(18, 56), module, SEQ3::CLOCK_PARAM, -2.0f, 6.0f, 2.0f)); - addParam(ParamWidget::create(Vec(60, 61-1), module, SEQ3::RUN_PARAM, 0.0f, 1.0f, 0.0f)); - addChild(ModuleLightWidget::create>(Vec(64.4f, 64.4f), module, SEQ3::RUNNING_LIGHT)); - addParam(ParamWidget::create(Vec(99, 61-1), module, SEQ3::RESET_PARAM, 0.0f, 1.0f, 0.0f)); - addChild(ModuleLightWidget::create>(Vec(103.4f, 64.4f), module, SEQ3::RESET_LIGHT)); - addParam(ParamWidget::create(Vec(132, 56), module, SEQ3::STEPS_PARAM, 1.0f, 8.0f, 8.0f)); - addChild(ModuleLightWidget::create>(Vec(179.4f, 64.4f), module, SEQ3::GATES_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(218.4f, 64.4f), module, SEQ3::ROW_LIGHTS)); - addChild(ModuleLightWidget::create>(Vec(256.4f, 64.4f), module, SEQ3::ROW_LIGHTS + 1)); - addChild(ModuleLightWidget::create>(Vec(295.4f, 64.4f), module, SEQ3::ROW_LIGHTS + 2)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); + + addParam(createParam(Vec(18, 56), module, SEQ3::CLOCK_PARAM, -2.0f, 6.0f, 2.0f)); + addParam(createParam(Vec(60, 61-1), module, SEQ3::RUN_PARAM, 0.0f, 1.0f, 0.0f)); + addChild(createLight>(Vec(64.4f, 64.4f), module, SEQ3::RUNNING_LIGHT)); + addParam(createParam(Vec(99, 61-1), module, SEQ3::RESET_PARAM, 0.0f, 1.0f, 0.0f)); + addChild(createLight>(Vec(103.4f, 64.4f), module, SEQ3::RESET_LIGHT)); + addParam(createParam(Vec(132, 56), module, SEQ3::STEPS_PARAM, 1.0f, 8.0f, 8.0f)); + addChild(createLight>(Vec(179.4f, 64.4f), module, SEQ3::GATES_LIGHT)); + addChild(createLight>(Vec(218.4f, 64.4f), module, SEQ3::ROW_LIGHTS)); + addChild(createLight>(Vec(256.4f, 64.4f), module, SEQ3::ROW_LIGHTS + 1)); + addChild(createLight>(Vec(295.4f, 64.4f), module, SEQ3::ROW_LIGHTS + 2)); static const float portX[8] = {20, 58, 96, 135, 173, 212, 250, 289}; - addInput(Port::create(Vec(portX[0]-1, 98), Port::INPUT, module, SEQ3::CLOCK_INPUT)); - addInput(Port::create(Vec(portX[1]-1, 98), Port::INPUT, module, SEQ3::EXT_CLOCK_INPUT)); - addInput(Port::create(Vec(portX[2]-1, 98), Port::INPUT, module, SEQ3::RESET_INPUT)); - addInput(Port::create(Vec(portX[3]-1, 98), Port::INPUT, module, SEQ3::STEPS_INPUT)); - addOutput(Port::create(Vec(portX[4]-1, 98), Port::OUTPUT, module, SEQ3::GATES_OUTPUT)); - addOutput(Port::create(Vec(portX[5]-1, 98), Port::OUTPUT, module, SEQ3::ROW1_OUTPUT)); - addOutput(Port::create(Vec(portX[6]-1, 98), Port::OUTPUT, module, SEQ3::ROW2_OUTPUT)); - addOutput(Port::create(Vec(portX[7]-1, 98), Port::OUTPUT, module, SEQ3::ROW3_OUTPUT)); + addInput(createPort(Vec(portX[0]-1, 98), PortWidget::INPUT, module, SEQ3::CLOCK_INPUT)); + addInput(createPort(Vec(portX[1]-1, 98), PortWidget::INPUT, module, SEQ3::EXT_CLOCK_INPUT)); + addInput(createPort(Vec(portX[2]-1, 98), PortWidget::INPUT, module, SEQ3::RESET_INPUT)); + addInput(createPort(Vec(portX[3]-1, 98), PortWidget::INPUT, module, SEQ3::STEPS_INPUT)); + addOutput(createPort(Vec(portX[4]-1, 98), PortWidget::OUTPUT, module, SEQ3::GATES_OUTPUT)); + addOutput(createPort(Vec(portX[5]-1, 98), PortWidget::OUTPUT, module, SEQ3::ROW1_OUTPUT)); + addOutput(createPort(Vec(portX[6]-1, 98), PortWidget::OUTPUT, module, SEQ3::ROW2_OUTPUT)); + addOutput(createPort(Vec(portX[7]-1, 98), PortWidget::OUTPUT, module, SEQ3::ROW3_OUTPUT)); for (int i = 0; i < 8; i++) { - addParam(ParamWidget::create(Vec(portX[i]-2, 157), module, SEQ3::ROW1_PARAM + i, 0.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(portX[i]-2, 198), module, SEQ3::ROW2_PARAM + i, 0.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(portX[i]-2, 240), module, SEQ3::ROW3_PARAM + i, 0.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(portX[i]+2, 278-1), module, SEQ3::GATE_PARAM + i, 0.0f, 1.0f, 0.0f)); - addChild(ModuleLightWidget::create>(Vec(portX[i]+6.4f, 281.4f), module, SEQ3::GATE_LIGHTS + i)); - addOutput(Port::create(Vec(portX[i]-1, 307), Port::OUTPUT, module, SEQ3::GATE_OUTPUT + i)); + addParam(createParam(Vec(portX[i]-2, 157), module, SEQ3::ROW1_PARAM + i, 0.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(portX[i]-2, 198), module, SEQ3::ROW2_PARAM + i, 0.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(portX[i]-2, 240), module, SEQ3::ROW3_PARAM + i, 0.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(portX[i]+2, 278-1), module, SEQ3::GATE_PARAM + i, 0.0f, 1.0f, 0.0f)); + addChild(createLight>(Vec(portX[i]+6.4f, 281.4f), module, SEQ3::GATE_LIGHTS + i)); + addOutput(createPort(Vec(portX[i]-1, 307), PortWidget::OUTPUT, module, SEQ3::GATE_OUTPUT + i)); } } }; -Model *modelSEQ3 = Model::create("SEQ3"); +Model *modelSEQ3 = createModel("SEQ3"); diff --git a/src/Scope.cpp b/src/Scope.cpp index ed85ff1..6a17245 100644 --- a/src/Scope.cpp +++ b/src/Scope.cpp @@ -48,14 +48,14 @@ struct Scope : Module { Scope() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} void step() override; - json_t *toJson() override { + json_t *dataToJson() override { json_t *rootJ = json_object(); json_object_set_new(rootJ, "lissajous", json_integer((int) lissajous)); json_object_set_new(rootJ, "external", json_integer((int) external)); return rootJ; } - void fromJson(json_t *rootJ) override { + void dataFromJson(json_t *rootJ) override { json_t *sumJ = json_object_get(rootJ, "lissajous"); if (sumJ) lissajous = json_integer_value(sumJ); @@ -306,10 +306,10 @@ struct ScopeWidget : ModuleWidget { ScopeWidget::ScopeWidget(Scope *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/Scope.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); { ScopeDisplay *display = new ScopeDisplay(); @@ -319,24 +319,24 @@ ScopeWidget::ScopeWidget(Scope *module) : ModuleWidget(module) { addChild(display); } - addParam(ParamWidget::create(Vec(15, 209), module, Scope::X_SCALE_PARAM, -2.0f, 8.0f, 0.0f)); - addParam(ParamWidget::create(Vec(15, 263), module, Scope::X_POS_PARAM, -10.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(61, 209), module, Scope::Y_SCALE_PARAM, -2.0f, 8.0f, 0.0f)); - addParam(ParamWidget::create(Vec(61, 263), module, Scope::Y_POS_PARAM, -10.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(107, 209), module, Scope::TIME_PARAM, -6.0f, -16.0f, -14.0f)); - addParam(ParamWidget::create(Vec(106, 262), module, Scope::LISSAJOUS_PARAM, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(153, 209), module, Scope::TRIG_PARAM, -10.0f, 10.0f, 0.0f)); - addParam(ParamWidget::create(Vec(152, 262), module, Scope::EXTERNAL_PARAM, 0.0f, 1.0f, 0.0f)); - - addInput(Port::create(Vec(17, 319), Port::INPUT, module, Scope::X_INPUT)); - addInput(Port::create(Vec(63, 319), Port::INPUT, module, Scope::Y_INPUT)); - addInput(Port::create(Vec(154, 319), Port::INPUT, module, Scope::TRIG_INPUT)); - - addChild(ModuleLightWidget::create>(Vec(104, 251), module, Scope::PLOT_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(104, 296), module, Scope::LISSAJOUS_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 251), module, Scope::INTERNAL_LIGHT)); - addChild(ModuleLightWidget::create>(Vec(150, 296), module, Scope::EXTERNAL_LIGHT)); + addParam(createParam(Vec(15, 209), module, Scope::X_SCALE_PARAM, -2.0f, 8.0f, 0.0f)); + addParam(createParam(Vec(15, 263), module, Scope::X_POS_PARAM, -10.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(61, 209), module, Scope::Y_SCALE_PARAM, -2.0f, 8.0f, 0.0f)); + addParam(createParam(Vec(61, 263), module, Scope::Y_POS_PARAM, -10.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(107, 209), module, Scope::TIME_PARAM, -6.0f, -16.0f, -14.0f)); + addParam(createParam(Vec(106, 262), module, Scope::LISSAJOUS_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(153, 209), module, Scope::TRIG_PARAM, -10.0f, 10.0f, 0.0f)); + addParam(createParam(Vec(152, 262), module, Scope::EXTERNAL_PARAM, 0.0f, 1.0f, 0.0f)); + + addInput(createPort(Vec(17, 319), PortWidget::INPUT, module, Scope::X_INPUT)); + addInput(createPort(Vec(63, 319), PortWidget::INPUT, module, Scope::Y_INPUT)); + addInput(createPort(Vec(154, 319), PortWidget::INPUT, module, Scope::TRIG_INPUT)); + + addChild(createLight>(Vec(104, 251), module, Scope::PLOT_LIGHT)); + addChild(createLight>(Vec(104, 296), module, Scope::LISSAJOUS_LIGHT)); + addChild(createLight>(Vec(150, 251), module, Scope::INTERNAL_LIGHT)); + addChild(createLight>(Vec(150, 296), module, Scope::EXTERNAL_LIGHT)); } -Model *modelScope = Model::create("Scope"); +Model *modelScope = createModel("Scope"); diff --git a/src/SequentialSwitch.cpp b/src/SequentialSwitch.cpp index 76e759e..884b570 100644 --- a/src/SequentialSwitch.cpp +++ b/src/SequentialSwitch.cpp @@ -83,28 +83,28 @@ SequentialSwitch1Widget::SequentialSwitch1Widget(SequentialSwitch<1> *module) : typedef SequentialSwitch<1> TSequentialSwitch; setPanel(SVG::load(assetPlugin(plugin, "res/SequentialSwitch1.svg"))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addParam(ParamWidget::create(mm2px(Vec(5.24619, 46.9153)), module, TSequentialSwitch::CHANNELS_PARAM, 0.0f, 2.0f, 0.0f)); + addParam(createParam(mm2px(Vec(5.24619, 46.9153)), module, TSequentialSwitch::CHANNELS_PARAM, 0.0f, 2.0f, 0.0f)); - addInput(Port::create(mm2px(Vec(3.51398, 17.694)), Port::INPUT, module, TSequentialSwitch::CLOCK_INPUT)); - addInput(Port::create(mm2px(Vec(3.51398, 32.1896)), Port::INPUT, module, TSequentialSwitch::RESET_INPUT)); - addInput(Port::create(mm2px(Vec(3.51536, 62.8096)), Port::INPUT, module, TSequentialSwitch::IN_INPUT + 0)); + addInput(createPort(mm2px(Vec(3.51398, 17.694)), PortWidget::INPUT, module, TSequentialSwitch::CLOCK_INPUT)); + addInput(createPort(mm2px(Vec(3.51398, 32.1896)), PortWidget::INPUT, module, TSequentialSwitch::RESET_INPUT)); + addInput(createPort(mm2px(Vec(3.51536, 62.8096)), PortWidget::INPUT, module, TSequentialSwitch::IN_INPUT + 0)); - addOutput(Port::create(mm2px(Vec(3.51536, 77.8095)), Port::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 0)); - addOutput(Port::create(mm2px(Vec(3.51398, 87.8113)), Port::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 1)); - addOutput(Port::create(mm2px(Vec(3.51398, 97.809)), Port::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 2)); - addOutput(Port::create(mm2px(Vec(3.51398, 107.809)), Port::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 3)); + addOutput(createPort(mm2px(Vec(3.51536, 77.8095)), PortWidget::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 0)); + addOutput(createPort(mm2px(Vec(3.51398, 87.8113)), PortWidget::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 1)); + addOutput(createPort(mm2px(Vec(3.51398, 97.809)), PortWidget::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 2)); + addOutput(createPort(mm2px(Vec(3.51398, 107.809)), PortWidget::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 3)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.8203, 77.7158)), module, TSequentialSwitch::CHANNEL_LIGHT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.8203, 87.7163)), module, TSequentialSwitch::CHANNEL_LIGHT + 1)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.8203, 97.7167)), module, TSequentialSwitch::CHANNEL_LIGHT + 2)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.8203, 107.716)), module, TSequentialSwitch::CHANNEL_LIGHT + 3)); + addChild(createLight>(mm2px(Vec(10.8203, 77.7158)), module, TSequentialSwitch::CHANNEL_LIGHT + 0)); + addChild(createLight>(mm2px(Vec(10.8203, 87.7163)), module, TSequentialSwitch::CHANNEL_LIGHT + 1)); + addChild(createLight>(mm2px(Vec(10.8203, 97.7167)), module, TSequentialSwitch::CHANNEL_LIGHT + 2)); + addChild(createLight>(mm2px(Vec(10.8203, 107.716)), module, TSequentialSwitch::CHANNEL_LIGHT + 3)); } -Model *modelSequentialSwitch1 = Model::create, SequentialSwitch1Widget>("SequentialSwitch1"); +Model *modelSequentialSwitch1 = createModel, SequentialSwitch1Widget>("SequentialSwitch1"); struct SequentialSwitch2Widget : ModuleWidget { @@ -115,25 +115,25 @@ SequentialSwitch2Widget::SequentialSwitch2Widget(SequentialSwitch<2> *module) : typedef SequentialSwitch<2> TSequentialSwitch; setPanel(SVG::load(assetPlugin(plugin, "res/SequentialSwitch2.svg"))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addParam(ParamWidget::create(mm2px(Vec(5.24619, 46.9153)), module, TSequentialSwitch::CHANNELS_PARAM, 0.0f, 2.0f, 0.0f)); + addParam(createParam(mm2px(Vec(5.24619, 46.9153)), module, TSequentialSwitch::CHANNELS_PARAM, 0.0f, 2.0f, 0.0f)); - addInput(Port::create(mm2px(Vec(3.51398, 17.694)), Port::INPUT, module, TSequentialSwitch::CLOCK_INPUT)); - addInput(Port::create(mm2px(Vec(3.51398, 32.191)), Port::INPUT, module, TSequentialSwitch::RESET_INPUT)); - addInput(Port::create(mm2px(Vec(3.51398, 62.811)), Port::INPUT, module, TSequentialSwitch::IN_INPUT + 0)); - addInput(Port::create(mm2px(Vec(3.51398, 72.8114)), Port::INPUT, module, TSequentialSwitch::IN_INPUT + 1)); - addInput(Port::create(mm2px(Vec(3.51398, 82.8091)), Port::INPUT, module, TSequentialSwitch::IN_INPUT + 2)); - addInput(Port::create(mm2px(Vec(3.51398, 92.8109)), Port::INPUT, module, TSequentialSwitch::IN_INPUT + 3)); + addInput(createPort(mm2px(Vec(3.51398, 17.694)), PortWidget::INPUT, module, TSequentialSwitch::CLOCK_INPUT)); + addInput(createPort(mm2px(Vec(3.51398, 32.191)), PortWidget::INPUT, module, TSequentialSwitch::RESET_INPUT)); + addInput(createPort(mm2px(Vec(3.51398, 62.811)), PortWidget::INPUT, module, TSequentialSwitch::IN_INPUT + 0)); + addInput(createPort(mm2px(Vec(3.51398, 72.8114)), PortWidget::INPUT, module, TSequentialSwitch::IN_INPUT + 1)); + addInput(createPort(mm2px(Vec(3.51398, 82.8091)), PortWidget::INPUT, module, TSequentialSwitch::IN_INPUT + 2)); + addInput(createPort(mm2px(Vec(3.51398, 92.8109)), PortWidget::INPUT, module, TSequentialSwitch::IN_INPUT + 3)); - addOutput(Port::create(mm2px(Vec(3.51398, 107.622)), Port::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 0)); + addOutput(createPort(mm2px(Vec(3.51398, 107.622)), PortWidget::OUTPUT, module, TSequentialSwitch::OUT_OUTPUT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.7321, 62.6277)), module, TSequentialSwitch::CHANNEL_LIGHT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.7321, 72.6281)), module, TSequentialSwitch::CHANNEL_LIGHT + 1)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.7321, 82.6285)), module, TSequentialSwitch::CHANNEL_LIGHT + 2)); - addChild(ModuleLightWidget::create>(mm2px(Vec(10.7321, 92.6276)), module, TSequentialSwitch::CHANNEL_LIGHT + 3)); + addChild(createLight>(mm2px(Vec(10.7321, 62.6277)), module, TSequentialSwitch::CHANNEL_LIGHT + 0)); + addChild(createLight>(mm2px(Vec(10.7321, 72.6281)), module, TSequentialSwitch::CHANNEL_LIGHT + 1)); + addChild(createLight>(mm2px(Vec(10.7321, 82.6285)), module, TSequentialSwitch::CHANNEL_LIGHT + 2)); + addChild(createLight>(mm2px(Vec(10.7321, 92.6276)), module, TSequentialSwitch::CHANNEL_LIGHT + 3)); } -Model *modelSequentialSwitch2 = Model::create, SequentialSwitch2Widget>("SequentialSwitch2"); +Model *modelSequentialSwitch2 = createModel, SequentialSwitch2Widget>("SequentialSwitch2"); diff --git a/src/Unity.cpp b/src/Unity.cpp index fe6b536..36fbf21 100644 --- a/src/Unity.cpp +++ b/src/Unity.cpp @@ -35,14 +35,14 @@ struct Unity : Module { merge = false; } - json_t *toJson() override { + json_t *dataToJson() override { json_t *rootJ = json_object(); // merge json_object_set_new(rootJ, "merge", json_boolean(merge)); return rootJ; } - void fromJson(json_t *rootJ) override { + void dataFromJson(json_t *rootJ) override { // merge json_t *mergeJ = json_object_get(rootJ, "merge"); if (mergeJ) @@ -98,48 +98,48 @@ struct UnityWidget : ModuleWidget { UnityWidget::UnityWidget(Unity *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/Unity.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x - 30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x - 30, 365))); - - addParam(ParamWidget::create(mm2px(Vec(12.867, 52.961)), module, Unity::AVG1_PARAM, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(mm2px(Vec(12.867, 107.006)), module, Unity::AVG2_PARAM, 0.0f, 1.0f, 0.0f)); - - addInput(Port::create(mm2px(Vec(2.361, 17.144)), Port::INPUT, module, Unity::IN1_INPUT + 0)); - addInput(Port::create(mm2px(Vec(19.907, 17.144)), Port::INPUT, module, Unity::IN1_INPUT + 1)); - addInput(Port::create(mm2px(Vec(2.361, 28.145)), Port::INPUT, module, Unity::IN1_INPUT + 2)); - addInput(Port::create(mm2px(Vec(19.907, 28.145)), Port::INPUT, module, Unity::IN1_INPUT + 3)); - addInput(Port::create(mm2px(Vec(2.361, 39.145)), Port::INPUT, module, Unity::IN1_INPUT + 4)); - addInput(Port::create(mm2px(Vec(19.907, 39.145)), Port::INPUT, module, Unity::IN1_INPUT + 5)); - addInput(Port::create(mm2px(Vec(2.361, 71.145)), Port::INPUT, module, Unity::IN2_INPUT + 0)); - addInput(Port::create(mm2px(Vec(19.907, 71.145)), Port::INPUT, module, Unity::IN2_INPUT + 1)); - addInput(Port::create(mm2px(Vec(2.361, 82.145)), Port::INPUT, module, Unity::IN2_INPUT + 2)); - addInput(Port::create(mm2px(Vec(19.907, 82.145)), Port::INPUT, module, Unity::IN2_INPUT + 3)); - addInput(Port::create(mm2px(Vec(2.361, 93.144)), Port::INPUT, module, Unity::IN2_INPUT + 4)); - addInput(Port::create(mm2px(Vec(19.907, 93.144)), Port::INPUT, module, Unity::IN2_INPUT + 5)); - - addOutput(Port::create(mm2px(Vec(2.361, 54.15)), Port::OUTPUT, module, Unity::MIX1_OUTPUT)); - addOutput(Port::create(mm2px(Vec(19.907, 54.15)), Port::OUTPUT, module, Unity::INV1_OUTPUT)); - addOutput(Port::create(mm2px(Vec(2.361, 108.144)), Port::OUTPUT, module, Unity::MIX2_OUTPUT)); - addOutput(Port::create(mm2px(Vec(19.907, 108.144)), Port::OUTPUT, module, Unity::INV2_OUTPUT)); - - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 19.663)), module, Unity::VU1_LIGHT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 25.163)), module, Unity::VU1_LIGHT + 1)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 30.663)), module, Unity::VU1_LIGHT + 2)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 36.162)), module, Unity::VU1_LIGHT + 3)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 41.662)), module, Unity::VU1_LIGHT + 4)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 73.663)), module, Unity::VU2_LIGHT + 0)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 79.163)), module, Unity::VU2_LIGHT + 1)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 84.663)), module, Unity::VU2_LIGHT + 2)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 90.162)), module, Unity::VU2_LIGHT + 3)); - addChild(ModuleLightWidget::create>(mm2px(Vec(13.652, 95.662)), module, Unity::VU2_LIGHT + 4)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x - 30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x - 30, 365))); + + addParam(createParam(mm2px(Vec(12.867, 52.961)), module, Unity::AVG1_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(mm2px(Vec(12.867, 107.006)), module, Unity::AVG2_PARAM, 0.0f, 1.0f, 0.0f)); + + addInput(createPort(mm2px(Vec(2.361, 17.144)), PortWidget::INPUT, module, Unity::IN1_INPUT + 0)); + addInput(createPort(mm2px(Vec(19.907, 17.144)), PortWidget::INPUT, module, Unity::IN1_INPUT + 1)); + addInput(createPort(mm2px(Vec(2.361, 28.145)), PortWidget::INPUT, module, Unity::IN1_INPUT + 2)); + addInput(createPort(mm2px(Vec(19.907, 28.145)), PortWidget::INPUT, module, Unity::IN1_INPUT + 3)); + addInput(createPort(mm2px(Vec(2.361, 39.145)), PortWidget::INPUT, module, Unity::IN1_INPUT + 4)); + addInput(createPort(mm2px(Vec(19.907, 39.145)), PortWidget::INPUT, module, Unity::IN1_INPUT + 5)); + addInput(createPort(mm2px(Vec(2.361, 71.145)), PortWidget::INPUT, module, Unity::IN2_INPUT + 0)); + addInput(createPort(mm2px(Vec(19.907, 71.145)), PortWidget::INPUT, module, Unity::IN2_INPUT + 1)); + addInput(createPort(mm2px(Vec(2.361, 82.145)), PortWidget::INPUT, module, Unity::IN2_INPUT + 2)); + addInput(createPort(mm2px(Vec(19.907, 82.145)), PortWidget::INPUT, module, Unity::IN2_INPUT + 3)); + addInput(createPort(mm2px(Vec(2.361, 93.144)), PortWidget::INPUT, module, Unity::IN2_INPUT + 4)); + addInput(createPort(mm2px(Vec(19.907, 93.144)), PortWidget::INPUT, module, Unity::IN2_INPUT + 5)); + + addOutput(createPort(mm2px(Vec(2.361, 54.15)), PortWidget::OUTPUT, module, Unity::MIX1_OUTPUT)); + addOutput(createPort(mm2px(Vec(19.907, 54.15)), PortWidget::OUTPUT, module, Unity::INV1_OUTPUT)); + addOutput(createPort(mm2px(Vec(2.361, 108.144)), PortWidget::OUTPUT, module, Unity::MIX2_OUTPUT)); + addOutput(createPort(mm2px(Vec(19.907, 108.144)), PortWidget::OUTPUT, module, Unity::INV2_OUTPUT)); + + addChild(createLight>(mm2px(Vec(13.652, 19.663)), module, Unity::VU1_LIGHT + 0)); + addChild(createLight>(mm2px(Vec(13.652, 25.163)), module, Unity::VU1_LIGHT + 1)); + addChild(createLight>(mm2px(Vec(13.652, 30.663)), module, Unity::VU1_LIGHT + 2)); + addChild(createLight>(mm2px(Vec(13.652, 36.162)), module, Unity::VU1_LIGHT + 3)); + addChild(createLight>(mm2px(Vec(13.652, 41.662)), module, Unity::VU1_LIGHT + 4)); + addChild(createLight>(mm2px(Vec(13.652, 73.663)), module, Unity::VU2_LIGHT + 0)); + addChild(createLight>(mm2px(Vec(13.652, 79.163)), module, Unity::VU2_LIGHT + 1)); + addChild(createLight>(mm2px(Vec(13.652, 84.663)), module, Unity::VU2_LIGHT + 2)); + addChild(createLight>(mm2px(Vec(13.652, 90.162)), module, Unity::VU2_LIGHT + 3)); + addChild(createLight>(mm2px(Vec(13.652, 95.662)), module, Unity::VU2_LIGHT + 4)); } struct UnityMergeItem : MenuItem { Unity *unity; - void onAction(EventAction &e) override { + void onAction(const event::Action &e) override { unity->merge ^= true; } void step() override { @@ -148,15 +148,15 @@ struct UnityMergeItem : MenuItem { }; void UnityWidget::appendContextMenu(Menu *menu) { - menu->addChild(MenuEntry::create()); + menu->addChild(new MenuEntry); Unity *unity = dynamic_cast(module); assert(unity); - UnityMergeItem *mergeItem = MenuItem::create("Merge channels 1 & 2"); + UnityMergeItem *mergeItem = createMenuItem("Merge channels 1 & 2"); mergeItem->unity = unity; menu->addChild(mergeItem); } -Model *modelUnity = Model::create("Unity"); +Model *modelUnity = createModel("Unity"); diff --git a/src/VCA.cpp b/src/VCA.cpp index 07b0c30..e2d2073 100644 --- a/src/VCA.cpp +++ b/src/VCA.cpp @@ -50,23 +50,23 @@ struct VCAWidget : ModuleWidget { VCAWidget::VCAWidget(VCA *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCA.svg"))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - - addParam(ParamWidget::create(mm2px(Vec(6.35, 19.11753)), module, VCA::LEVEL1_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create(mm2px(Vec(6.35, 74.80544)), module, VCA::LEVEL2_PARAM, 0.0, 1.0, 0.0)); - - addInput(Port::create(mm2px(Vec(2.5907, 38.19371)), Port::INPUT, module, VCA::EXP1_INPUT)); - addInput(Port::create(mm2px(Vec(14.59752, 38.19371)), Port::INPUT, module, VCA::LIN1_INPUT)); - addInput(Port::create(mm2px(Vec(2.5907, 52.80642)), Port::INPUT, module, VCA::IN1_INPUT)); - addInput(Port::create(mm2px(Vec(2.5907, 93.53435)), Port::INPUT, module, VCA::EXP2_INPUT)); - addInput(Port::create(mm2px(Vec(14.59752, 93.53435)), Port::INPUT, module, VCA::LIN2_INPUT)); - addInput(Port::create(mm2px(Vec(2.5907, 108.14706)), Port::INPUT, module, VCA::IN2_INPUT)); - - addOutput(Port::create(mm2px(Vec(14.59752, 52.80642)), Port::OUTPUT, module, VCA::OUT1_OUTPUT)); - addOutput(Port::create(mm2px(Vec(14.59752, 108.14706)), Port::OUTPUT, module, VCA::OUT2_OUTPUT)); + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + + addParam(createParam(mm2px(Vec(6.35, 19.11753)), module, VCA::LEVEL1_PARAM, 0.0, 1.0, 0.0)); + addParam(createParam(mm2px(Vec(6.35, 74.80544)), module, VCA::LEVEL2_PARAM, 0.0, 1.0, 0.0)); + + addInput(createPort(mm2px(Vec(2.5907, 38.19371)), PortWidget::INPUT, module, VCA::EXP1_INPUT)); + addInput(createPort(mm2px(Vec(14.59752, 38.19371)), PortWidget::INPUT, module, VCA::LIN1_INPUT)); + addInput(createPort(mm2px(Vec(2.5907, 52.80642)), PortWidget::INPUT, module, VCA::IN1_INPUT)); + addInput(createPort(mm2px(Vec(2.5907, 93.53435)), PortWidget::INPUT, module, VCA::EXP2_INPUT)); + addInput(createPort(mm2px(Vec(14.59752, 93.53435)), PortWidget::INPUT, module, VCA::LIN2_INPUT)); + addInput(createPort(mm2px(Vec(2.5907, 108.14706)), PortWidget::INPUT, module, VCA::IN2_INPUT)); + + addOutput(createPort(mm2px(Vec(14.59752, 52.80642)), PortWidget::OUTPUT, module, VCA::OUT1_OUTPUT)); + addOutput(createPort(mm2px(Vec(14.59752, 108.14706)), PortWidget::OUTPUT, module, VCA::OUT2_OUTPUT)); } @@ -104,23 +104,27 @@ struct VCA_1 : Module { struct VCA_1VUKnob : Knob { + VCA_1 *module = NULL; + VCA_1VUKnob() { box.size = mm2px(Vec(10, 46)); } void draw(NVGcontext *vg) override { + if (!quantity || !module) + return; + nvgBeginPath(vg); nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, 2.0); nvgFillColor(vg, nvgRGB(0, 0, 0)); nvgFill(vg); - VCA_1 *module = dynamic_cast(this->module); - const int segs = 25; const Vec margin = Vec(4, 4); - Rect r = box.zeroPos().shrink(margin); + Rect r = box.zeroPos().grow(margin); for (int i = 0; i < segs; i++) { + float value = quantity->getValue(); float segValue = clamp(value * segs - (segs - i - 1), 0.f, 1.f); float amplitude = value * module->lastCv; float segAmplitude = clamp(amplitude * segs - (segs - i - 1), 0.f, 1.f); @@ -144,21 +148,23 @@ struct VCA_1Widget : ModuleWidget { VCA_1Widget(VCA_1 *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCA-1.svg"))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addParam(ParamWidget::create(mm2px(Vec(2.62103, 12.31692)), module, VCA_1::LEVEL_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create(mm2px(Vec(5.24619, 79.9593)), module, VCA_1::EXP_PARAM, 0.0, 1.0, 1.0)); + VCA_1VUKnob *levelParam = createParam(mm2px(Vec(2.62103, 12.31692)), module, VCA_1::LEVEL_PARAM, 0.0, 1.0, 1.0); + levelParam->module = module; + addParam(levelParam); + addParam(createParam(mm2px(Vec(5.24619, 79.9593)), module, VCA_1::EXP_PARAM, 0.0, 1.0, 1.0)); - addInput(Port::create(mm2px(Vec(3.51261, 60.4008)), Port::INPUT, module, VCA_1::CV_INPUT)); - addInput(Port::create(mm2px(Vec(3.51398, 97.74977)), Port::INPUT, module, VCA_1::IN_INPUT)); + addInput(createPort(mm2px(Vec(3.51261, 60.4008)), PortWidget::INPUT, module, VCA_1::CV_INPUT)); + addInput(createPort(mm2px(Vec(3.51398, 97.74977)), PortWidget::INPUT, module, VCA_1::IN_INPUT)); - addOutput(Port::create(mm2px(Vec(3.51398, 108.64454)), Port::OUTPUT, module, VCA_1::OUT_OUTPUT)); + addOutput(createPort(mm2px(Vec(3.51398, 108.64454)), PortWidget::OUTPUT, module, VCA_1::OUT_OUTPUT)); } }; -Model *modelVCA_1 = createModel("VCA-1", "VCA-1", AMPLIFIER_TAG); -Model *modelVCA = createModel("VCA", "VCA-2", AMPLIFIER_TAG, DUAL_TAG); +Model *modelVCA_1 = createModel("VCA-1"); +Model *modelVCA = createModel("VCA"); diff --git a/src/VCF.cpp b/src/VCF.cpp index b4c6fe2..1cb90f5 100644 --- a/src/VCF.cpp +++ b/src/VCF.cpp @@ -149,24 +149,24 @@ struct VCFWidget : ModuleWidget { VCFWidget(VCF *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCF.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x - 30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x - 30, 365))); - - addParam(ParamWidget::create(Vec(33, 61), module, VCF::FREQ_PARAM, 0.f, 1.f, 0.5f)); - addParam(ParamWidget::create(Vec(12, 143), module, VCF::FINE_PARAM, 0.f, 1.f, 0.5f)); - addParam(ParamWidget::create(Vec(71, 143), module, VCF::RES_PARAM, 0.f, 1.f, 0.f)); - addParam(ParamWidget::create(Vec(12, 208), module, VCF::FREQ_CV_PARAM, -1.f, 1.f, 0.f)); - addParam(ParamWidget::create(Vec(71, 208), module, VCF::DRIVE_PARAM, 0.f, 1.f, 0.f)); - - addInput(Port::create(Vec(10, 276), Port::INPUT, module, VCF::FREQ_INPUT)); - addInput(Port::create(Vec(48, 276), Port::INPUT, module, VCF::RES_INPUT)); - addInput(Port::create(Vec(85, 276), Port::INPUT, module, VCF::DRIVE_INPUT)); - addInput(Port::create(Vec(10, 320), Port::INPUT, module, VCF::IN_INPUT)); - - addOutput(Port::create(Vec(48, 320), Port::OUTPUT, module, VCF::LPF_OUTPUT)); - addOutput(Port::create(Vec(85, 320), Port::OUTPUT, module, VCF::HPF_OUTPUT)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x - 30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x - 30, 365))); + + addParam(createParam(Vec(33, 61), module, VCF::FREQ_PARAM, 0.f, 1.f, 0.5f)); + addParam(createParam(Vec(12, 143), module, VCF::FINE_PARAM, 0.f, 1.f, 0.5f)); + addParam(createParam(Vec(71, 143), module, VCF::RES_PARAM, 0.f, 1.f, 0.f)); + addParam(createParam(Vec(12, 208), module, VCF::FREQ_CV_PARAM, -1.f, 1.f, 0.f)); + addParam(createParam(Vec(71, 208), module, VCF::DRIVE_PARAM, 0.f, 1.f, 0.f)); + + addInput(createPort(Vec(10, 276), PortWidget::INPUT, module, VCF::FREQ_INPUT)); + addInput(createPort(Vec(48, 276), PortWidget::INPUT, module, VCF::RES_INPUT)); + addInput(createPort(Vec(85, 276), PortWidget::INPUT, module, VCF::DRIVE_INPUT)); + addInput(createPort(Vec(10, 320), PortWidget::INPUT, module, VCF::IN_INPUT)); + + addOutput(createPort(Vec(48, 320), PortWidget::OUTPUT, module, VCF::LPF_OUTPUT)); + addOutput(createPort(Vec(85, 320), PortWidget::OUTPUT, module, VCF::HPF_OUTPUT)); } }; diff --git a/src/VCMixer.cpp b/src/VCMixer.cpp index b39973d..e4bfad4 100644 --- a/src/VCMixer.cpp +++ b/src/VCMixer.cpp @@ -43,35 +43,35 @@ struct VCMixerWidget : ModuleWidget { VCMixerWidget(VCMixer *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCMixer.svg"))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); - addChild(Widget::create(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addChild(Widget::create(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - addParam(ParamWidget::create(mm2px(Vec(19.049999, 21.161154)), module, VCMixer::MIX_LVL_PARAM, 0.0, 2.0, 1.0)); - addParam(ParamWidget::create(mm2px(Vec(5.8993969, 44.33149).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 0, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create(mm2px(Vec(17.899343, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 1, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create(mm2px(Vec(29.899292, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 2, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create(mm2px(Vec(41.90065, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 3, 0.0, 1.0, 1.0)); + addParam(createParam(mm2px(Vec(19.049999, 21.161154)), module, VCMixer::MIX_LVL_PARAM, 0.0, 2.0, 1.0)); + addParam(createParam(mm2px(Vec(5.8993969, 44.33149).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 0, 0.0, 1.0, 1.0)); + addParam(createParam(mm2px(Vec(17.899343, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 1, 0.0, 1.0, 1.0)); + addParam(createParam(mm2px(Vec(29.899292, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 2, 0.0, 1.0, 1.0)); + addParam(createParam(mm2px(Vec(41.90065, 44.331486).plus(Vec(-2, 0))), module, VCMixer::LVL_PARAM + 3, 0.0, 1.0, 1.0)); // Use old interleaved order for backward compatibility with <0.6 - addInput(Port::create(mm2px(Vec(3.2935331, 23.404598)), Port::INPUT, module, VCMixer::MIX_CV_INPUT)); - addInput(Port::create(mm2px(Vec(3.2935331, 78.531639)), Port::INPUT, module, VCMixer::CH_INPUT + 0)); - addInput(Port::create(mm2px(Vec(3.2935331, 93.531586)), Port::INPUT, module, VCMixer::CV_INPUT + 0)); - addInput(Port::create(mm2px(Vec(15.29348, 78.531639)), Port::INPUT, module, VCMixer::CH_INPUT + 1)); - addInput(Port::create(mm2px(Vec(15.29348, 93.531586)), Port::INPUT, module, VCMixer::CV_INPUT + 1)); - addInput(Port::create(mm2px(Vec(27.293465, 78.531639)), Port::INPUT, module, VCMixer::CH_INPUT + 2)); - addInput(Port::create(mm2px(Vec(27.293465, 93.531586)), Port::INPUT, module, VCMixer::CV_INPUT + 2)); - addInput(Port::create(mm2px(Vec(39.293411, 78.531639)), Port::INPUT, module, VCMixer::CH_INPUT + 3)); - addInput(Port::create(mm2px(Vec(39.293411, 93.531586)), Port::INPUT, module, VCMixer::CV_INPUT + 3)); + addInput(createPort(mm2px(Vec(3.2935331, 23.404598)), PortWidget::INPUT, module, VCMixer::MIX_CV_INPUT)); + addInput(createPort(mm2px(Vec(3.2935331, 78.531639)), PortWidget::INPUT, module, VCMixer::CH_INPUT + 0)); + addInput(createPort(mm2px(Vec(3.2935331, 93.531586)), PortWidget::INPUT, module, VCMixer::CV_INPUT + 0)); + addInput(createPort(mm2px(Vec(15.29348, 78.531639)), PortWidget::INPUT, module, VCMixer::CH_INPUT + 1)); + addInput(createPort(mm2px(Vec(15.29348, 93.531586)), PortWidget::INPUT, module, VCMixer::CV_INPUT + 1)); + addInput(createPort(mm2px(Vec(27.293465, 78.531639)), PortWidget::INPUT, module, VCMixer::CH_INPUT + 2)); + addInput(createPort(mm2px(Vec(27.293465, 93.531586)), PortWidget::INPUT, module, VCMixer::CV_INPUT + 2)); + addInput(createPort(mm2px(Vec(39.293411, 78.531639)), PortWidget::INPUT, module, VCMixer::CH_INPUT + 3)); + addInput(createPort(mm2px(Vec(39.293411, 93.531586)), PortWidget::INPUT, module, VCMixer::CV_INPUT + 3)); - addOutput(Port::create(mm2px(Vec(39.293411, 23.4046)), Port::OUTPUT, module, VCMixer::MIX_OUTPUT)); - addOutput(Port::create(mm2px(Vec(3.2935331, 108.53153)), Port::OUTPUT, module, VCMixer::CH_OUTPUT + 0)); - addOutput(Port::create(mm2px(Vec(15.29348, 108.53153)), Port::OUTPUT, module, VCMixer::CH_OUTPUT + 1)); - addOutput(Port::create(mm2px(Vec(27.293465, 108.53153)), Port::OUTPUT, module, VCMixer::CH_OUTPUT + 2)); - addOutput(Port::create(mm2px(Vec(39.293411, 108.53153)), Port::OUTPUT, module, VCMixer::CH_OUTPUT + 3)); + addOutput(createPort(mm2px(Vec(39.293411, 23.4046)), PortWidget::OUTPUT, module, VCMixer::MIX_OUTPUT)); + addOutput(createPort(mm2px(Vec(3.2935331, 108.53153)), PortWidget::OUTPUT, module, VCMixer::CH_OUTPUT + 0)); + addOutput(createPort(mm2px(Vec(15.29348, 108.53153)), PortWidget::OUTPUT, module, VCMixer::CH_OUTPUT + 1)); + addOutput(createPort(mm2px(Vec(27.293465, 108.53153)), PortWidget::OUTPUT, module, VCMixer::CH_OUTPUT + 2)); + addOutput(createPort(mm2px(Vec(39.293411, 108.53153)), PortWidget::OUTPUT, module, VCMixer::CH_OUTPUT + 3)); } }; -Model *modelVCMixer = Model::create("VCMixer"); +Model *modelVCMixer = createModel("VCMixer"); diff --git a/src/VCO.cpp b/src/VCO.cpp index 72002e2..1f46fe2 100644 --- a/src/VCO.cpp +++ b/src/VCO.cpp @@ -237,31 +237,31 @@ struct VCOWidget : ModuleWidget { VCOWidget::VCOWidget(VCO *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCO-1.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); - - addParam(ParamWidget::create(Vec(15, 77), module, VCO::MODE_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(119, 77), module, VCO::SYNC_PARAM, 0.0f, 1.0f, 1.0f)); - - addParam(ParamWidget::create(Vec(47, 61), module, VCO::FREQ_PARAM, -54.0f, 54.0f, 0.0f)); - addParam(ParamWidget::create(Vec(23, 143), module, VCO::FINE_PARAM, -1.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(91, 143), module, VCO::PW_PARAM, 0.0f, 1.0f, 0.5f)); - addParam(ParamWidget::create(Vec(23, 208), module, VCO::FM_PARAM, 0.0f, 1.0f, 0.0f)); - addParam(ParamWidget::create(Vec(91, 208), module, VCO::PWM_PARAM, 0.0f, 1.0f, 0.0f)); - - addInput(Port::create(Vec(11, 276), Port::INPUT, module, VCO::PITCH_INPUT)); - addInput(Port::create(Vec(45, 276), Port::INPUT, module, VCO::FM_INPUT)); - addInput(Port::create(Vec(80, 276), Port::INPUT, module, VCO::SYNC_INPUT)); - addInput(Port::create(Vec(114, 276), Port::INPUT, module, VCO::PW_INPUT)); - - addOutput(Port::create(Vec(11, 320), Port::OUTPUT, module, VCO::SIN_OUTPUT)); - addOutput(Port::create(Vec(45, 320), Port::OUTPUT, module, VCO::TRI_OUTPUT)); - addOutput(Port::create(Vec(80, 320), Port::OUTPUT, module, VCO::SAW_OUTPUT)); - addOutput(Port::create(Vec(114, 320), Port::OUTPUT, module, VCO::SQR_OUTPUT)); - - addChild(ModuleLightWidget::create>(Vec(99, 42.5f), module, VCO::PHASE_POS_LIGHT)); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); + + addParam(createParam(Vec(15, 77), module, VCO::MODE_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(119, 77), module, VCO::SYNC_PARAM, 0.0f, 1.0f, 1.0f)); + + addParam(createParam(Vec(47, 61), module, VCO::FREQ_PARAM, -54.0f, 54.0f, 0.0f)); + addParam(createParam(Vec(23, 143), module, VCO::FINE_PARAM, -1.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(91, 143), module, VCO::PW_PARAM, 0.0f, 1.0f, 0.5f)); + addParam(createParam(Vec(23, 208), module, VCO::FM_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(91, 208), module, VCO::PWM_PARAM, 0.0f, 1.0f, 0.0f)); + + addInput(createPort(Vec(11, 276), PortWidget::INPUT, module, VCO::PITCH_INPUT)); + addInput(createPort(Vec(45, 276), PortWidget::INPUT, module, VCO::FM_INPUT)); + addInput(createPort(Vec(80, 276), PortWidget::INPUT, module, VCO::SYNC_INPUT)); + addInput(createPort(Vec(114, 276), PortWidget::INPUT, module, VCO::PW_INPUT)); + + addOutput(createPort(Vec(11, 320), PortWidget::OUTPUT, module, VCO::SIN_OUTPUT)); + addOutput(createPort(Vec(45, 320), PortWidget::OUTPUT, module, VCO::TRI_OUTPUT)); + addOutput(createPort(Vec(80, 320), PortWidget::OUTPUT, module, VCO::SAW_OUTPUT)); + addOutput(createPort(Vec(114, 320), PortWidget::OUTPUT, module, VCO::SQR_OUTPUT)); + + addChild(createLight>(Vec(99, 42.5f), module, VCO::PHASE_POS_LIGHT)); } @@ -333,25 +333,25 @@ struct VCO2Widget : ModuleWidget { VCO2Widget::VCO2Widget(VCO2 *module) : ModuleWidget(module) { setPanel(SVG::load(assetPlugin(plugin, "res/VCO-2.svg"))); - addChild(Widget::create(Vec(15, 0))); - addChild(Widget::create(Vec(box.size.x-30, 0))); - addChild(Widget::create(Vec(15, 365))); - addChild(Widget::create(Vec(box.size.x-30, 365))); + addChild(createWidget(Vec(15, 0))); + addChild(createWidget(Vec(box.size.x-30, 0))); + addChild(createWidget(Vec(15, 365))); + addChild(createWidget(Vec(box.size.x-30, 365))); - addParam(ParamWidget::create(Vec(62, 150), module, VCO2::MODE_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(62, 215), module, VCO2::SYNC_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(62, 150), module, VCO2::MODE_PARAM, 0.0f, 1.0f, 1.0f)); + addParam(createParam(Vec(62, 215), module, VCO2::SYNC_PARAM, 0.0f, 1.0f, 1.0f)); - addParam(ParamWidget::create(Vec(17, 60), module, VCO2::FREQ_PARAM, -54.0f, 54.0f, 0.0f)); - addParam(ParamWidget::create(Vec(12, 143), module, VCO2::WAVE_PARAM, 0.0f, 3.0f, 1.5f)); - addParam(ParamWidget::create(Vec(12, 208), module, VCO2::FM_PARAM, 0.0f, 1.0f, 0.0f)); + addParam(createParam(Vec(17, 60), module, VCO2::FREQ_PARAM, -54.0f, 54.0f, 0.0f)); + addParam(createParam(Vec(12, 143), module, VCO2::WAVE_PARAM, 0.0f, 3.0f, 1.5f)); + addParam(createParam(Vec(12, 208), module, VCO2::FM_PARAM, 0.0f, 1.0f, 0.0f)); - addInput(Port::create(Vec(11, 276), Port::INPUT, module, VCO2::FM_INPUT)); - addInput(Port::create(Vec(54, 276), Port::INPUT, module, VCO2::SYNC_INPUT)); - addInput(Port::create(Vec(11, 320), Port::INPUT, module, VCO2::WAVE_INPUT)); + addInput(createPort(Vec(11, 276), PortWidget::INPUT, module, VCO2::FM_INPUT)); + addInput(createPort(Vec(54, 276), PortWidget::INPUT, module, VCO2::SYNC_INPUT)); + addInput(createPort(Vec(11, 320), PortWidget::INPUT, module, VCO2::WAVE_INPUT)); - addOutput(Port::create(Vec(54, 320), Port::OUTPUT, module, VCO2::OUT_OUTPUT)); + addOutput(createPort(Vec(54, 320), PortWidget::OUTPUT, module, VCO2::OUT_OUTPUT)); - addChild(ModuleLightWidget::create>(Vec(68, 42.5f), module, VCO2::PHASE_POS_LIGHT)); + addChild(createLight>(Vec(68, 42.5f), module, VCO2::PHASE_POS_LIGHT)); }