diff --git a/src/Spiralone.hpp b/src/Spiralone.hpp index 4f648ac..f6db645 100644 --- a/src/Spiralone.hpp +++ b/src/Spiralone.hpp @@ -21,7 +21,7 @@ struct SpiraloneWidget : SequencerWidget { public: SpiraloneWidget(Spiralone *module); - Menu *addContextMenu(Menu *menu) override; + void appendContextMenu(ui::Menu *menu) override; void onMenu(int action); private: diff --git a/src/SpiraloneModule.cpp b/src/SpiraloneModule.cpp index 906f6c8..e6c0e7e 100644 --- a/src/SpiraloneModule.cpp +++ b/src/SpiraloneModule.cpp @@ -121,7 +121,7 @@ SpiraloneWidget::SpiraloneWidget(Spiralone *module) : SequencerWidget(module) #endif } -void SpiralonecreateWidgetSequencer(int seq) +void SpiraloneWidget::createSequencer(int seq) { #ifdef OSCTEST_MODULE char name[60]; @@ -191,7 +191,7 @@ void SpiralonecreateWidgetSequencer(int seq) addOutput(createOutput(Vec(mm2px(238.996), yncscape(104.395 + dist_v*seq, 8.255)), module, Spiralone::GATE_1 + seq)); } -ModuleLightWidget *SpiralonecreateWidgetLed(int seq, Vec pos, Module *module, int firstLightId, bool big) +ModuleLightWidget *SpiraloneWidget::createLed(int seq, Vec pos, Module *module, int firstLightId, bool big) { ModuleLightWidget * rv = new ModuleLightWidget(); if(big) @@ -206,7 +206,7 @@ ModuleLightWidget *SpiralonecreateWidgetLed(int seq, Vec pos, Module *module, in return rv; } -Menu *SpiraloneWidget::addContextMenu(Menu *menu) +void SpiraloneWidget::appendContextMenu(ui::Menu *menu) { menu->addChild(new SeqMenuItem("Randomize Pitch", this, RANDOMIZE_PITCH)); menu->addChild(new SeqMenuItem("Randomize Length", this, RANDOMIZE_LEN)); diff --git a/src/SpiraloneModule.hpp b/src/SpiraloneModule.hpp index b9f1082..ab0c0a4 100644 --- a/src/SpiraloneModule.hpp +++ b/src/SpiraloneModule.hpp @@ -62,7 +62,8 @@ struct Spiralone : Module #endif void process(const ProcessArgs &args) override; - void reset() override { load(); } + // FIXME - this has been moved to the widget + // void reset() override { load(); } void dataFromJson(json_t *root) override { Module::dataFromJson(root); on_loaded(); } json_t *dataToJson() override diff --git a/src/Z8K.hpp b/src/Z8K.hpp index 232c7f6..896f91a 100644 --- a/src/Z8K.hpp +++ b/src/Z8K.hpp @@ -97,7 +97,7 @@ struct Z8K : Module #endif void process(const ProcessArgs &args) override; - void reset() override { load(); } + // void reset() override { load(); } void dataFromJson(json_t *root) override { Module::dataFromJson(root); on_loaded(); } json_t *dataToJson() override diff --git a/src/burst.hpp b/src/burst.hpp index 050239a..fa504bd 100644 --- a/src/burst.hpp +++ b/src/burst.hpp @@ -54,7 +54,7 @@ struct Burst : Module } void process(const ProcessArgs &args) override; - void reset() override { load(); } + void reset() /* override */ { load(); } // FIXME - this shoudl be in the widget void dataFromJson(json_t *root) override { Module::dataFromJson(root); on_loaded(); } json_t *dataToJson() override { @@ -70,7 +70,7 @@ private: void prepare_step(); void next_step(); void end_step(); - void port(int n, bool on) { lights[LEDOUT_1 + n].value = outputs[OUT_1 + n].setVoltage(on ? LVL_ON : LVL_OFF); } + void port(int n, bool on) { lights[LEDOUT_1 + n].value = 0; outputs[OUT_1 + n].setVoltage(on ? LVL_ON : LVL_OFF); } void invert_port(int n) { port(n, outputs[OUT_1 + n].value < LVL_ON); } private: diff --git a/src/common.hpp b/src/common.hpp index 763d5c2..d5af851 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -42,10 +42,10 @@ struct _davies1900base : Davies1900hKnob setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, res))); } - void randomize() override + virtual void randomize() override { if(snap) - setValue(roundf(rescale(random::uniform(), 0.0, 1.0, minAngle, maxAngle))); + paramQuantity->setValue(roundf(rescale(random::uniform(), 0.0, 1.0, minAngle, maxAngle))); else Davies1900hKnob::randomize(); } @@ -79,13 +79,11 @@ struct WhiteLight : GrayModuleLightWidget } }; -struct _ioPort : SVGPort +struct _ioPort : app::SvgPort { _ioPort(const char *res) { - background->svg = APP->window->loadSvg(asset::plugin(pluginInstance, res)); - background->wrap(); - box.size = background->box.size; + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, res))); } }; @@ -148,37 +146,38 @@ struct CL1362WPort : _ioPort CL1362WPort() : _ioPort("res/CL1362W.svg") {} }; -struct BefacoPushBig : SVGSwitch, MomentarySwitch { +struct BefacoPushBig : app::SvgSwitch { BefacoPushBig() { + momentary = true; addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoPush_0big.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoPush_1big.svg"))); } }; -struct CKSSFix : SVGSwitch, ToggleSwitch { +struct CKSSFix : app::SvgSwitch { CKSSFix() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CKSS_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CKSS_1.svg"))); } - void randomize() override + virtual void randomize() override { - setValue(roundf(rescale(random::uniform(), 0.0, 1.0, minValue, maxValue))); + paramQuantity->setValue(roundf(rescale(random::uniform(), 0.0, 1.0, paramQuantity->minValue, paramQuantity->maxValue))); } }; -struct CKSSThreeFix : SVGSwitch, ToggleSwitch { +struct CKSSThreeFix : app::SvgSwitch { CKSSThreeFix() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CKSSThree_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CKSSThree_1.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CKSSThree_2.svg"))); } - void randomize() override + virtual void randomize() override { - setValue(roundf(rescale(random::uniform(), 0.0, 1.0, minValue, maxValue))); + paramQuantity->setValue(roundf(rescale(random::uniform(), 0.0, 1.0, paramQuantity->minValue, paramQuantity->maxValue))); } }; -struct TL1105Sw : SVGSwitch, ToggleSwitch { +struct TL1105Sw : app::SvgSwitch { TL1105Sw() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/TL1105_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/TL1105_1.svg"))); @@ -234,7 +233,7 @@ struct SchmittTrigger2 } }; -struct NKK2 : SVGSwitch, ToggleSwitch +struct NKK2 : app::SvgSwitch { NKK2() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/NKK_0.svg"))); @@ -242,20 +241,20 @@ struct NKK2 : SVGSwitch, ToggleSwitch addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/NKK_2.svg"))); } - void randomize() override + virtual void randomize() override { - setValue(roundf(rescale(random::uniform(), 0.0, 1.0, minValue, maxValue))); + paramQuantity->setValue(roundf(rescale(random::uniform(), 0.0, 1.0, paramQuantity->minValue, paramQuantity->maxValue))); } }; -struct BefacoSnappedSwitch : SVGSwitch, ToggleSwitch +struct BefacoSnappedSwitch : app::SvgSwitch { - void randomize() override + virtual void randomize() override { if(random::uniform() >= 0.5) - setValue(1.0); + paramQuantity->setValue(1.0); else - setValue(0.0); + paramQuantity->setValue(0.0); } BefacoSnappedSwitch() @@ -267,7 +266,7 @@ struct BefacoSnappedSwitch : SVGSwitch, ToggleSwitch -struct VerticalSwitch : SVGFader +struct VerticalSwitch : app::SvgSlider { VerticalSwitch() { @@ -282,7 +281,7 @@ struct VerticalSwitch : SVGFader handle->wrap(); } - void randomize() override { setValue(roundf(random::uniform() * maxValue)); } + virtual void randomize() override { paramQuantity->setValue(roundf(random::uniform() * paramQuantity->maxValue)); } }; @@ -296,7 +295,7 @@ public: action = act; }; - void onAction(EventAction &e) override { widget->onMenu(action); }; + void onAction(const event::Action &e) override { widget->onMenu(action); }; private: T *widget; @@ -316,7 +315,7 @@ protected: } int getParamIndex(int index) { - auto it = std::find_if(params.begin(), params.end(), [&index](const ParamWidget *m) -> bool { return m->paramId == index; }); + auto it = std::find_if(params.begin(), params.end(), [&index](const ParamWidget *m) -> bool { return m->paramQuantity->paramId == index; }); if(it != params.end()) return std::distance(params.begin(), it); @@ -335,15 +334,11 @@ protected: } } - Menu *createContextMenu() override + virtual void appendContextMenu(ui::Menu *menu) override { - Menu *menu = ModulecreateWidgetContextMenu(); MenuLabel *spacerLabel = new MenuLabel(); menu->addChild(spacerLabel); - return addContextMenu(menu); } - - virtual Menu *addContextMenu(Menu *menu) { return menu; } }; #if defined(LAUNCHPAD) || defined(OSC_ENABLE) diff --git a/src/mplex.hpp b/src/mplex.hpp index fea533f..ebab29c 100644 --- a/src/mplex.hpp +++ b/src/mplex.hpp @@ -59,11 +59,11 @@ struct Mplex : Module return rootJ; } void process(const ProcessArgs &args) override; - void reset() override { load(); } - void randomize() override + // void reset() override { load(); } + /*virtual void randomize() override { set_output((int)roundf(rescale(random::uniform(), 0.0, 1.0, 0, NUM_MPLEX_INPUTS))); - } + }*/ private: void load(); diff --git a/src/pwmClock.cpp b/src/pwmClock.cpp index ad5796b..ec2f504 100644 --- a/src/pwmClock.cpp +++ b/src/pwmClock.cpp @@ -135,7 +135,7 @@ PwmClockWidget::PwmClockWidget(PwmClock *module) : SequencerWidget(module) module->setWidget(this); box.size = Vec(15 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT); { - SVGPanel *panel = new SVGPanel(); + auto panel = new app::SvgPanel(); panel->box.size = box.size; panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/modules/PwmClock.svg"))); @@ -209,9 +209,10 @@ void PwmClockWidget::SetBpm(float bpm_integer) if(index >= 0) { // VCV interface update is ahem.... migliorabile.... - bool smooth = params[index]->smooth; - params[index]->smooth = false; - params[index]->setValue((double)bpm_integer); - params[index]->smooth = smooth; + // FIXME - what was this smooth doing? + //bool smooth = params[index]->paramQuantity->smooth; + //params[index]->paramQuantity->smooth = false; + params[index]->paramQuantity->setValue((double)bpm_integer); + //params[index]->paramQuantity->smooth = smooth; } } diff --git a/src/pwmClock.hpp b/src/pwmClock.hpp index f0b8652..b4396ce 100644 --- a/src/pwmClock.hpp +++ b/src/pwmClock.hpp @@ -1,19 +1,21 @@ #pragma once #include "common.hpp" -struct UPSWITCH : SVGSwitch, MomentarySwitch +struct UPSWITCH : app::SvgSwitch { UPSWITCH() { + momentary = true; addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/upswitch_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/upswitch_1.svg"))); } }; -struct DNSWITCH : SVGSwitch, MomentarySwitch +struct DNSWITCH : app::SvgSwitch { DNSWITCH() { + momentary = true; addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/dnswitch_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/dnswitch_1.svg"))); } @@ -23,7 +25,7 @@ struct Rogan1PSRedSmall : Rogan { Rogan1PSRedSmall() { - setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Rogan2PSRedSmall.svg"))); + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Rogan2PSRedSmall.svg"))); } }; @@ -40,7 +42,7 @@ struct SA_TIMER //sample accurate version { float Reset() { - prevTime = curTime = args.sampleTime; + prevTime = curTime = rack::APP->engine->getSampleTime(); return Begin(); } @@ -55,7 +57,7 @@ struct SA_TIMER //sample accurate version float Step() { - curTime += args.sampleTime; + curTime += rack::APP->engine->getSampleTime(); float deltaTime = curTime - prevTime; prevTime = curTime; totalPulseTime += deltaTime; @@ -125,13 +127,16 @@ struct PwmClock : Module on_loaded(); } + // FIXME - this has been moved to widget + /* void reset() override { bpm_integer = 120; load(); } - void randomize() override {} + */ + // void randomize() override {} void setWidget(PwmClockWidget *pwdg) { pWidget = pwdg; } float bpm; float swing; diff --git a/src/quantizer.cpp b/src/quantizer.cpp index 80fbcbf..d2f0462 100644 --- a/src/quantizer.cpp +++ b/src/quantizer.cpp @@ -52,8 +52,9 @@ QuantizerWidget::QuantizerWidget(Quantizer *module) for(int k = 0; k < NUM_QUANTIZERS; k++) { addInput(createInput(Vec(in_x, y), module, Quantizer::IN_1 + k)); + // FIXME - move this to module creation if(module) - module->configParam(0.0, 5.0, 0.0); + module->configParam(Quantizer::IN_1 + k, 0.0, 5.0, 0.0); addParam(createParam(Vec(pot_x, ypot+1), module, Quantizer::TRANSP_1+k)); addInput(createInput(Vec(mod_x, mod_y), module, Quantizer::TRNSPIN_1 + k)); addOutput(createOutput(Vec(out_x, y), module, Quantizer::OUT_1+k)); diff --git a/src/switch.cpp b/src/switch.cpp index c892a5c..aac5fc4 100644 --- a/src/switch.cpp +++ b/src/switch.cpp @@ -1,36 +1,38 @@ #include "common.hpp" #include "switch.hpp" -void Switch::process(const ProcessArgs &args) +void XORSwitch::process(const ProcessArgs &args) { for(int k = 0; k < NUM_SWITCHES; k++) { if(outputs[OUT_1 + k].isConnected() && inputs[IN_1 + k].isConnected()) { - if(getSwitch(k)) + if(getXORSwitch(k)) { lights[LED_1 + k].value = 5;; outputs[OUT_1 + k].setVoltage(inputs[IN_1 + k].getVoltage()); } else { - lights[LED_1 + k].value = outputs[OUT_1 + k].setVoltage(0); + lights[LED_1 + k].value = 0; + outputs[OUT_1 + k].setVoltage(0); } } else { - lights[LED_1 + k].value = outputs[OUT_1 + k].setVoltage(0); + lights[LED_1 + k].value = 0; + outputs[OUT_1 + k].setVoltage(0); } } } -SwitchWidget::SwitchWidget(Switch *module) +XORSwitchWidget::XORSwitchWidget(XORSwitch *module) { setModule(module); box.size = Vec(10 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT); { - SVGPanel *panel = new SVGPanel(); + auto panel = new SvgPanel(); panel->box.size = box.size; - panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/modules/Switch.svg"))); + panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/modules/XORSwitch.svg"))); addChild(panel); } @@ -51,13 +53,13 @@ SwitchWidget::SwitchWidget(Switch *module) for(int k = 0; k < NUM_SWITCHES; k++) { - addInput(createInput(Vec(in_x, yncscape(y, 8.255)), module, Switch::IN_1 + k)); - addInput(createInput(Vec(mod_x, yncscape(y1, 8.255)), module, Switch::MOD_1 + k)); + addInput(createInput(Vec(in_x, yncscape(y, 8.255)), module, XORSwitch::IN_1 + k)); + addInput(createInput(Vec(mod_x, yncscape(y1, 8.255)), module, XORSwitch::MOD_1 + k)); if(module) - module->configParam(Switch::SW_1+k, 0.0, 1.0, 0.0); - addParam(createParam(Vec(sw_x, yncscape(ysw, 7.336)), module, Switch::SW_1+k)); - addChild(createLight>(Vec(led_x, yncscape(yled, 2.176)), module, Switch::LED_1 + k )); - addOutput(createOutput(Vec(out_x, yncscape(y, 8.255)), module, Switch::OUT_1+k)); + module->configParam(XORSwitch::SW_1+k, 0.0, 1.0, 0.0); + addParam(createParam(Vec(sw_x, yncscape(ysw, 7.336)), module, XORSwitch::SW_1+k)); + addChild(createLight>(Vec(led_x, yncscape(yled, 2.176)), module, XORSwitch::LED_1 + k )); + addOutput(createOutput(Vec(out_x, yncscape(y, 8.255)), module, XORSwitch::OUT_1+k)); y += delta_y; y1 += delta_y; ysw += delta_y; diff --git a/src/switch.hpp b/src/switch.hpp index f58dce2..6ca112a 100644 --- a/src/switch.hpp +++ b/src/switch.hpp @@ -8,10 +8,10 @@ extern Plugin *pluginInstance; #define NUM_SWITCHES (5) -struct Switch; -struct SwitchWidget : ModuleWidget +struct XORSwitch; +struct XORSwitchWidget : ModuleWidget { - SwitchWidget(Switch * module); + XORSwitchWidget(XORSwitch * module); private: float yncscape(float y, float height) { @@ -19,7 +19,7 @@ private: } }; -struct Switch : Module +struct XORSwitch : Module { enum ParamIds { @@ -42,14 +42,14 @@ struct Switch : Module LED_1, NUM_LIGHTS = LED_1 + NUM_SWITCHES }; - Switch() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) + XORSwitch() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { } void process(const ProcessArgs &args) override; private: - bool getSwitch(int n) + bool getXORSwitch(int n) { return (inputs[MOD_1 + n].normalize(0.0) + params[SW_1 + n].getValue()) > 0.5; } diff --git a/src/uncert.cpp b/src/uncert.cpp index 7087525..d8e64eb 100644 --- a/src/uncert.cpp +++ b/src/uncert.cpp @@ -112,7 +112,7 @@ UncertainWidget::UncertainWidget(Uncertain *module) : SequencerWidget(module) { box.size = Vec(12 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT); { - SVGPanel *panel = new SVGPanel(); + auto panel = new app::SvgPanel(); panel->box.size = box.size; panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/modules/uncert.svg"))); addChild(panel); diff --git a/src/uncert.hpp b/src/uncert.hpp index 004f8af..59e54d5 100644 --- a/src/uncert.hpp +++ b/src/uncert.hpp @@ -53,12 +53,15 @@ struct Uncertain : Module NUM_LIGHTS }; - Uncertain() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) - { + Uncertain() : Module() + { + config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); } void process(const ProcessArgs &args) override; - void reset() override { load(); } + // FIXME - reset has been moved to the widget. What's the intent here? + // virtual void reset() override { load(); } + void dataFromJson(json_t *root) override { Module::dataFromJson(root); on_loaded(); } json_t *dataToJson() override {