From 3f0b0dfb1a6c5341488d238c717dc6e0a9de61fd Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 4 Feb 2024 09:07:09 -0500 Subject: [PATCH] Add Patch Name Display; Update to rack dark panel setting --- src/ALingADing.cpp | 1 - src/BaconModule.hpp | 3 +- src/BaconModuleWidget.h | 22 ++---- src/BaconPlugs.cpp | 1 + src/BaconPlugs.hpp | 1 + src/BaconTestModule.cpp | 53 ++++++-------- src/BufferedDrawFunction.hpp | 10 ++- src/ChipNoise.cpp | 10 +-- src/ChipWaves.cpp | 10 ++- src/Components.hpp | 115 ++++++++++++++--------------- src/ContrastBNDEditor.cpp | 3 +- src/Glissinator.hpp | 4 +- src/GraduatedFader.hpp | 12 ++-- src/HarMoNee.cpp | 3 +- src/KarplusStrongPoly.cpp | 3 +- src/LintBuddy.cpp | 5 +- src/LuckyHold.cpp | 109 ++++++++++++++-------------- src/Open303.cpp | 2 +- src/PatchNameDisplay.cpp | 136 +++++++++++++++++++++++++++++++++++ src/PolyGenerator.cpp | 5 +- src/PolyGenerator.hpp | 1 - src/PolyGnome.cpp | 34 +++------ src/PolyGnome.hpp | 28 ++++---- src/QuantEyes.cpp | 10 ++- src/SampleDelay.cpp | 1 - src/Style.cpp | 11 +-- src/Style.hpp | 16 ++++- 27 files changed, 351 insertions(+), 258 deletions(-) create mode 100644 src/PatchNameDisplay.cpp diff --git a/src/ALingADing.cpp b/src/ALingADing.cpp index cdc7122..03c412f 100644 --- a/src/ALingADing.cpp +++ b/src/ALingADing.cpp @@ -3,7 +3,6 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - namespace bp = baconpaul::rackplugs; /* diff --git a/src/BaconModule.hpp b/src/BaconModule.hpp index 5ab39d8..acaca73 100644 --- a/src/BaconModule.hpp +++ b/src/BaconModule.hpp @@ -13,8 +13,7 @@ namespace baconpaul::rackplugs { struct BaconModule : rack::engine::Module { - }; -} +} // namespace baconpaul::rackplugs #endif // BACONPLUGS_RACK_HACK_BACONMODULE_H diff --git a/src/BaconModuleWidget.h b/src/BaconModuleWidget.h index 7de7135..e817516 100644 --- a/src/BaconModuleWidget.h +++ b/src/BaconModuleWidget.h @@ -23,30 +23,16 @@ struct BaconModuleWidget : rack::app::ModuleWidget, StyleParticipant dirtyFB(c); } - void appendContextMenu(ui::Menu *menu) override { - appendModuleSpecificContextMenu(menu); - } - - virtual void appendModuleSpecificContextMenu(Menu *) - { - - } + void appendContextMenu(ui::Menu *menu) override { appendModuleSpecificContextMenu(menu); } + virtual void appendModuleSpecificContextMenu(Menu *) {} void step() override { -#ifndef USING_CARDINAL_NOT_RACK - auto lpd = rack::settings::preferDarkPanels; - if (lpd) - BaconStyle::get()->setStyle(BaconStyle::DARK); - else - BaconStyle::get()->setStyle(BaconStyle::LIGHT); -#endif - + BaconStyle::get()->setStyle(); ModuleWidget::step(); } - }; -} +} // namespace baconpaul::rackplugs #endif // BACONPLUGS_RACK_HACK_BACONMODULEWIDGET_H diff --git a/src/BaconPlugs.cpp b/src/BaconPlugs.cpp index 187af88..b180f75 100644 --- a/src/BaconPlugs.cpp +++ b/src/BaconPlugs.cpp @@ -30,6 +30,7 @@ __attribute__((__visibility__("default"))) void init(rack::Plugin *p) p->addModel(modelLintBuddy); p->addModel(modelLuckyHold); p->addModel(modelContrastBNDEditor); + p->addModel(modelPatchNameDisplay); p->addModel(modelBaconTest); diff --git a/src/BaconPlugs.hpp b/src/BaconPlugs.hpp index 9caa896..74559a5 100644 --- a/src/BaconPlugs.hpp +++ b/src/BaconPlugs.hpp @@ -45,6 +45,7 @@ extern Model *modelPolyGenerator; extern Model *modelLintBuddy; extern Model *modelLuckyHold; extern Model *modelContrastBNDEditor; +extern Model *modelPatchNameDisplay; extern Model *modelBaconTest; diff --git a/src/BaconTestModule.cpp b/src/BaconTestModule.cpp index c44b159..aee972c 100644 --- a/src/BaconTestModule.cpp +++ b/src/BaconTestModule.cpp @@ -60,32 +60,17 @@ struct BaconTest : bp::BaconModule } float lrt = -1.f; float prior[2]{0.f, 0.f}; - void process(const ProcessArgs &args) override { - auto iL = inputs[INPUT_0].getVoltage() / 5.0f; - auto iR = inputs[INPUT_0 + 1].getVoltage() / 5.0f; - - qo.step(); - - if (params[PARAM_0].getValue() != lrt) + void process(const ProcessArgs &args) override + { + auto v = inputs[INPUT_0].getVoltage(); + if (v > 2) { - lrt = params[PARAM_0].getValue(); - auto rf = lrt * 800 - 200; - qo.setRate(2.0 * M_PI * rf * args.sampleTime); + getModel()->hidden = false; + } + else + { + getModel()->hidden = true; } - auto fb = params[PARAM_0 + 1].getValue(); - iL = 0.8 * ( iL + fb * fb * fb * prior[0] ); - iR = 0.8 * ( iR + fb * fb * fb * prior[1] ); - - auto [L, R] = hilbert.stepToPair(iL, iR); - - auto [re, im] = L; - - auto [reR, imR] = R; - - prior[0] = (re * qo.v - im * qo.u); - prior[1] = (reR * qo.v - imR * qo.u); - outputs[OUTPUT_0+0].setVoltage(prior[0] * 5.f); - outputs[OUTPUT_0+1].setVoltage(prior[1] * 5.f); } }; @@ -97,7 +82,8 @@ struct BaconTestWidget : bp::BaconModuleWidget struct PolyWidget : public rack::Widget { int64_t dc{0}; - void draw(const DrawArgs &args) override { + void draw(const DrawArgs &args) override + { auto s = box.size; auto vg = args.vg; @@ -105,8 +91,8 @@ struct PolyWidget : public rack::Widget auto dcm = dc % (int)(s.x - 40); nvgBeginPath(vg); - nvgFillColor(vg, nvgRGB(255,0,0)); - nvgRect(vg, dcm, dcm, 40 , 40); + nvgFillColor(vg, nvgRGB(255, 0, 0)); + nvgRect(vg, dcm, dcm, 40, 40); nvgFill(vg); typedef std::vector> poly_t; @@ -125,6 +111,8 @@ struct PolyWidget : public rack::Widget polys.push_back(p); auto idx = nsides - 3; colm[p] = nvgRGB((255 - dcm * 20) * (idx < 5), idx * 15, dcm * 20); + if (idx == 3 && dcm > 20) + colm[p] = nvgRGB(255, 255, 0); } int idx = 0; @@ -132,15 +120,16 @@ struct PolyWidget : public rack::Widget { auto first{true}; nvgBeginPath(vg); - for (const auto &[x,y] : poly) + float xdcm = (dcm + std::sin(dc * (0.4 + idx * 0.03)) * (idx * 4)); + for (const auto &[x, y] : poly) { if (first) { - nvgMoveTo(vg, 15 * x + dcm, 15 * y + dcm + 40 + idx * 18); + nvgMoveTo(vg, 15 * x + xdcm, 15 * y + dcm + 40 + idx * 18); } else { - nvgLineTo(vg, 15 * x + dcm, 15 * y + dcm + 40 + idx * 18); + nvgLineTo(vg, 15 * x + xdcm, 15 * y + dcm + 40 + idx * 18); } first = false; } @@ -148,9 +137,9 @@ struct PolyWidget : public rack::Widget // nvgFillColor(vg, nvgRGB((255 - dcm * 20) * (idx < 5), idx * 15, dcm * 20)); nvgFillColor(vg, colm[poly]); nvgFill(vg); - nvgStrokeColor(vg, nvgRGB(0,0,50)); + nvgStrokeColor(vg, nvgRGB(0, 0, 50)); nvgStroke(vg); - idx ++; + idx++; } dc++; diff --git a/src/BufferedDrawFunction.hpp b/src/BufferedDrawFunction.hpp index fb67666..39f9355 100644 --- a/src/BufferedDrawFunction.hpp +++ b/src/BufferedDrawFunction.hpp @@ -22,12 +22,11 @@ struct BufferedDrawFunctionWidget : virtual FramebufferWidget /* widget::Widget* struct InternalBDW : Widget { drawfn_t drawf; - InternalBDW(Rect box_, drawfn_t draw_) : drawf(draw_) { box = box_; } + InternalBDW(Rect box_, drawfn_t draw_) : drawf(draw_) { box = box_; } void draw(const DrawArgs &args) override { drawf(args.vg); } }; - BufferedDrawFunctionWidget(Vec pos, Vec sz,drawfn_t draw_) - : drawf(draw_) + BufferedDrawFunctionWidget(Vec pos, Vec sz, drawfn_t draw_) : drawf(draw_) { box.pos = pos; box.size = sz; @@ -35,7 +34,7 @@ struct BufferedDrawFunctionWidget : virtual FramebufferWidget /* widget::Widget* InternalBDW *kid = new InternalBDW(kidBox, drawf); addChild(kid); #if DEBUG_MEM - memDebugger["bdw"] ++; + memDebugger["bdw"]++; std::cout << "CTOR >> Outstanding BDWs = " << memDebugger["bdw"] << std::endl; #endif } @@ -43,13 +42,12 @@ struct BufferedDrawFunctionWidget : virtual FramebufferWidget /* widget::Widget* #if DEBUG_MEM ~BufferedDrawFunctionWidget() override { - memDebugger["bdw"] --; + memDebugger["bdw"]--; std::cout << "DTOR << Outstanding BDWs = " << memDebugger["bdw"] << std::endl; } #endif }; - struct BufferedDrawFunctionWidgetOnLayer : BufferedDrawFunctionWidget { int layer{1}; diff --git a/src/ChipNoise.cpp b/src/ChipNoise.cpp index 75afe8b..fb32689 100644 --- a/src/ChipNoise.cpp +++ b/src/ChipNoise.cpp @@ -3,14 +3,13 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - - #include "sst/rackhelpers/module_connector.h" #include "sst/rackhelpers/neighbor_connectable.h" namespace bp = baconpaul::rackplugs; -struct ChipNoise : virtual bp::BaconModule, sst::rackhelpers::module_connector::NeighborConnectable_V1 +struct ChipNoise : virtual bp::BaconModule, + sst::rackhelpers::module_connector::NeighborConnectable_V1 { enum ParamIds { @@ -117,12 +116,9 @@ struct ChipNoise : virtual bp::BaconModule, sst::rackhelpers::module_connector:: outputs[NOISE_OUTPUT].setVoltage(noise->step()); } - std::optional> getPrimaryOutputs() override { - return {{ - std::make_pair("Noise", std::make_pair(NOISE_OUTPUT, -1)) - }}; + return {{std::make_pair("Noise", std::make_pair(NOISE_OUTPUT, -1))}}; } }; diff --git a/src/ChipWaves.cpp b/src/ChipWaves.cpp index 3b6331d..747aad2 100644 --- a/src/ChipWaves.cpp +++ b/src/ChipWaves.cpp @@ -10,7 +10,8 @@ namespace bp = baconpaul::rackplugs; -struct ChipWaves : virtual bp::BaconModule, sst::rackhelpers::module_connector::NeighborConnectable_V1 +struct ChipWaves : virtual bp::BaconModule, + sst::rackhelpers::module_connector::NeighborConnectable_V1 { enum ParamIds @@ -107,13 +108,10 @@ struct ChipWaves : virtual bp::BaconModule, sst::rackhelpers::module_connector:: } } - std::optional> getPrimaryOutputs() override { - return {{ - std::make_pair("Triangle", std::make_pair(TRI_OUTPUT, -1)), - std::make_pair("PULSE", std::make_pair(PULSE_OUTPUT, -1)) - }}; + return {{std::make_pair("Triangle", std::make_pair(TRI_OUTPUT, -1)), + std::make_pair("PULSE", std::make_pair(PULSE_OUTPUT, -1))}}; } }; diff --git a/src/Components.hpp b/src/Components.hpp index 11ad5e1..515fb14 100644 --- a/src/Components.hpp +++ b/src/Components.hpp @@ -17,7 +17,6 @@ #include "GraduatedFader.hpp" #include "Style.hpp" - using namespace rack; template struct SevenSegmentLight : T @@ -66,16 +65,17 @@ template struct SevenSegmentLight : T unscaledLoc.push_back(Rect(Vec(1, 2), Vec(1, 3))); unscaledLoc.push_back(Rect(Vec(2, 5), Vec(3, 1))); - buffer = new BufferedDrawFunctionWidget( - Vec(0, 0), this->box.size, [this](auto vg) { drawBackgroundBox(vg);}); + buffer = new BufferedDrawFunctionWidget(Vec(0, 0), this->box.size, + [this](auto vg) { drawBackgroundBox(vg); }); this->addChild(buffer); - bufferLight = new BufferedDrawFunctionWidgetOnLayer( - Vec(0, 0), this->box.size, [this](auto vg) { drawSegments(vg);}); + bufferLight = new BufferedDrawFunctionWidgetOnLayer(Vec(0, 0), this->box.size, + [this](auto vg) { drawSegments(vg); }); this->addChild(bufferLight); } - void step() override { + void step() override + { float fvalue = 0; if (this->module) fvalue = this->module->lights[this->firstLightId].value; @@ -94,7 +94,7 @@ template struct SevenSegmentLight : T if (value != pvalue) { buffer->dirty = true; - bufferLight->dirty =true; + bufferLight->dirty = true; } pvalue = value; @@ -103,10 +103,11 @@ template struct SevenSegmentLight : T void setDirty() { buffer->dirty = true; - bufferLight->dirty =true; + bufferLight->dirty = true; } - void draw(const typename T::DrawArgs &args) override { + void draw(const typename T::DrawArgs &args) override + { if (buffer) { buffer->draw(args); @@ -200,8 +201,6 @@ template struct SevenSegmentLight : T o->hexMode = true; return o; } - - }; template @@ -215,7 +214,7 @@ struct MultiDigitSevenSegmentLight : ModuleLightWidget this->box.size = Vec(digits * LtClass::sx, LtClass::sy); } - std::array childLightWeakRefs; + std::array childLightWeakRefs; static MultiDigitSevenSegmentLight *create(Vec pos, Module *module, int firstLightId) { @@ -303,9 +302,11 @@ struct BaconBackground : virtual TransparentWidget, baconpaul::rackplugs::StyleP { return addLabel(pos, lab, px, align, baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); } - BaconBackground *addLabel(Vec pos, const char *lab, int px, int align, baconpaul::rackplugs::BaconStyle::Colors col); + BaconBackground *addLabel(Vec pos, const char *lab, int px, int align, + baconpaul::rackplugs::BaconStyle::Colors col); - BaconBackground *addLambdaLabel(Vec pos, std::function val, int px, int align, baconpaul::rackplugs::BaconStyle::Colors col); + BaconBackground *addLambdaLabel(Vec pos, std::function val, int px, + int align, baconpaul::rackplugs::BaconStyle::Colors col); BaconBackground *addPlugLabel(Vec plugPos, LabelStyle s, const char *ilabel) { @@ -313,7 +314,8 @@ struct BaconBackground : virtual TransparentWidget, baconpaul::rackplugs::StyleP } BaconBackground *addPlugLabel(Vec plugPos, LabelAt l, LabelStyle s, const char *ilabel); BaconBackground *addRoundedBorder(Vec pos, Vec sz); - BaconBackground *addRoundedBorder(Vec pos, Vec sz, baconpaul::rackplugs::BaconStyle::Colors fill); + BaconBackground *addRoundedBorder(Vec pos, Vec sz, + baconpaul::rackplugs::BaconStyle::Colors fill); BaconBackground *addRoundedBorder(Vec pos, Vec sz, NVGcolor fill) { std::cout << "ERROR" << std::endl; @@ -404,8 +406,8 @@ template struct NStepDraggableLEDWidget : publ dragging = false; lastDragPos = Vec(-1, -1); - buffer = new BufferedDrawFunctionWidget( - Vec(0, 0), this->box.size, [this](auto vg) { drawSegments(vg); }); + buffer = new BufferedDrawFunctionWidget(Vec(0, 0), this->box.size, + [this](auto vg) { drawSegments(vg); }); addChild(buffer); } @@ -578,11 +580,11 @@ struct DotMatrixLightTextWidget : public widget::Widget // Thanks http://scruss. padSize = 1; box.size = Vec(charCount * (5 * ledSize + padSize) + 2 * padSize, 7 * ledSize + 4.5 * padSize); // 5 x 7 data structure - buffer = new BufferedDrawFunctionWidget( - Vec(0, 0), this->box.size, [this](auto vg) {drawBackground(vg);}); + buffer = new BufferedDrawFunctionWidget(Vec(0, 0), this->box.size, + [this](auto vg) { drawBackground(vg); }); addChild(buffer); - bufferLight = new BufferedDrawFunctionWidgetOnLayer( - Vec(0, 0), this->box.size, [this](auto vg) {drawText(vg);}); + bufferLight = new BufferedDrawFunctionWidgetOnLayer(Vec(0, 0), this->box.size, + [this](auto vg) { drawText(vg); }); addChild(bufferLight); INFO("BaconMusic loading DMP json: %s", @@ -634,7 +636,8 @@ struct DotMatrixLightTextWidget : public widget::Widget // Thanks http://scruss. stringGetter getfn; Module *module; - void step() override { + void step() override + { if (dirtyfn) { if (this->module && dirtyfn(this->module)) @@ -751,7 +754,6 @@ struct InternalFontMgr } }; - // FIXME - double buffer this struct DynamicLabel : virtual TransparentWidget, baconpaul::rackplugs::StyleParticipant { @@ -769,7 +771,8 @@ struct DynamicLabel : virtual TransparentWidget, baconpaul::rackplugs::StylePart void draw(const DrawArgs &args) override { - auto memFont = InternalFontMgr::get(args.vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); + auto memFont = + InternalFontMgr::get(args.vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); auto col = baconpaul::rackplugs::BaconStyle::get()->getColor(color); nvgBeginPath(args.vg); @@ -781,22 +784,21 @@ struct DynamicLabel : virtual TransparentWidget, baconpaul::rackplugs::StylePart nvgText(args.vg, 0, 0, label.c_str(), nullptr); } - void onStyleChanged() override - {} + void onStyleChanged() override {} }; - -struct CBButton : rack::Widget, baconpaul::rackplugs::StyleParticipant +struct CBButton : rack::Widget, baconpaul::rackplugs::StyleParticipant { - std::function getLabel = [](){return "Label";}; - std::function onPressed = [](){ std::cout << "Pressed; No Callback" << std::endl;}; + std::function getLabel = []() { return "Label"; }; + std::function onPressed = []() { std::cout << "Pressed; No Callback" << std::endl; }; BufferedDrawFunctionWidget *bdw{nullptr}; std::string label{""}; CBButton(const rack::Vec &pos, const rack::Vec &sz) { box.pos = pos; box.size = sz; - bdw = new BufferedDrawFunctionWidget(rack::Vec(0,0), sz, [this](auto v) { this->drawB(v);}); + bdw = + new BufferedDrawFunctionWidget(rack::Vec(0, 0), sz, [this](auto v) { this->drawB(v); }); addChild(bdw); } void onButton(const ButtonEvent &e) override @@ -826,7 +828,8 @@ struct CBButton : rack::Widget, baconpaul::rackplugs::StyleParticipant auto labelColor = style->getColor(baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); nvgBeginPath(vg); - nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, baconpaul::rackplugs::StyleConstants::rectRadius); + nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, + baconpaul::rackplugs::StyleConstants::rectRadius); NVGpaint vgr = nvgLinearGradient(vg, 0, 0, 0, box.size.y, labelBg, labelBgEnd); nvgFillPaint(vg, vgr); nvgFill(vg); @@ -834,7 +837,8 @@ struct CBButton : rack::Widget, baconpaul::rackplugs::StyleParticipant nvgStrokeWidth(vg, 1); nvgStroke(vg); - auto memFont = InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); + auto memFont = + InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); nvgBeginPath(vg); nvgFontFaceId(vg, memFont); @@ -843,9 +847,7 @@ struct CBButton : rack::Widget, baconpaul::rackplugs::StyleParticipant nvgTextAlign(vg, NVG_ALIGN_MIDDLE | NVG_ALIGN_CENTER); nvgText(vg, box.size.x * 0.5, box.size.y * 0.5, label.c_str(), nullptr); } - void onStyleChanged() override { - bdw->dirty = true; - } + void onStyleChanged() override { bdw->dirty = true; } }; struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleParticipant @@ -864,13 +866,15 @@ struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleP void draw(const DrawArgs &args) override { auto vg = args.vg; - auto memFont = InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->monoFontName()); + auto memFont = + InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->monoFontName()); int y = 3; - for (auto i=0U; idata.size(); ++i) + for (auto i = 0U; i < that->data.size(); ++i) { auto d = that->data[i]; - if (y > args.clipBox.pos.y - rowHeight && y < args.clipBox.pos.y + box.size.y + 2 * rowHeight) + if (y > args.clipBox.pos.y - rowHeight && + y < args.clipBox.pos.y + box.size.y + 2 * rowHeight) { nvgBeginPath(vg); nvgFontFaceId(vg, memFont); @@ -886,21 +890,21 @@ struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleP ScrollableStringList(const rack::Vec &pos, const rack::Vec &size, std::function()> getF, - std::function dirtyF) : - getList(std::move(getF)), isListDirty(std::move(dirtyF)) { + std::function dirtyF) + : getList(std::move(getF)), isListDirty(std::move(dirtyF)) + { box.pos = pos; box.size = size; - bg = new BufferedDrawFunctionWidget(rack::Vec(0,0), size, - [this](auto v) { drawBG(v);}); + bg = new BufferedDrawFunctionWidget(rack::Vec(0, 0), size, [this](auto v) { drawBG(v); }); addChild(bg); sw = new rack::ui::ScrollWidget; - sw->box.pos = rack::Vec(0,0); + sw->box.pos = rack::Vec(0, 0); sw->box.size = size; addChild(sw); list = new ListRender; - list->box.pos = rack::Vec(0,0); - list->box.size = rack::Vec(1000,1000); + list->box.pos = rack::Vec(0, 0); + list->box.size = rack::Vec(1000, 1000); list->that = this; sw->container->addChild(list); @@ -910,8 +914,8 @@ struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleP { nvgBeginPath(vg); nvgRect(vg, 0, 0, box.size.x, box.size.y); - nvgFillColor(vg, nvgRGB(0,0,0)); - nvgStrokeColor(vg, nvgRGB(200,200,220)); + nvgFillColor(vg, nvgRGB(0, 0, 0)); + nvgStrokeColor(vg, nvgRGB(200, 200, 220)); nvgFill(vg); nvgStrokeWidth(vg, 0.7); nvgStroke(vg); @@ -924,14 +928,16 @@ struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleP { if (isListDirty()) { - if (h0 < 0) h0 = box.size.y; - if (w0 < 0) w0 = box.size.x; + if (h0 < 0) + h0 = box.size.y; + if (w0 < 0) + w0 = box.size.x; data = getList(); auto h = std::max(h0, (int)(data.size() + 1) * rowHeight); auto w = w0; - for (const auto & d : data) + for (const auto &d : data) { w = std::max((int)d.size() * 8, w); } @@ -942,14 +948,9 @@ struct ScrollableStringList : virtual OpaqueWidget, baconpaul::rackplugs::StyleP OpaqueWidget::step(); } - void onStyleChanged() override - { - bg->dirty = true; - } + void onStyleChanged() override { bg->dirty = true; } }; - #include "SizeTable.hpp" - #endif diff --git a/src/ContrastBNDEditor.cpp b/src/ContrastBNDEditor.cpp index 275853a..1065983 100644 --- a/src/ContrastBNDEditor.cpp +++ b/src/ContrastBNDEditor.cpp @@ -7,7 +7,6 @@ #include "blendish.h" #include "blendish.h" - #define SCALE_LENGTH 12 namespace bp = baconpaul::rackplugs; @@ -164,7 +163,7 @@ struct ContrastBNDEditorWidget : bp::BaconModuleWidget } } } - Widget::step(); + bp::BaconModuleWidget::step(); } BufferedDrawFunctionWidget *bdw{nullptr}; void drawLabel(NVGcontext *vg) diff --git a/src/Glissinator.hpp b/src/Glissinator.hpp index 4e0bc2c..e1c3342 100644 --- a/src/Glissinator.hpp +++ b/src/Glissinator.hpp @@ -58,7 +58,6 @@ template struct Glissinator : public TBase { float glist_sec = params[GLISS_TIME].getValue(); - int nChan = inputs[SOURCE_INPUT].getChannels(); outputs[SLID_OUTPUT].setChannels(nChan); outputs[GLISSING_GATE].setChannels(nChan); @@ -66,7 +65,8 @@ template struct Glissinator : public TBase for (int i = 0; i < nChan; ++i) { - auto cglist = std::clamp(glist_sec + inputs[GLISS_CV_INPUT].getVoltage(i) * 0.2f, 0.f, 1.f); + auto cglist = + std::clamp(glist_sec + inputs[GLISS_CV_INPUT].getVoltage(i) * 0.2f, 0.f, 1.f); int shift_time = args.sampleRate * cglist; if (shift_time < 10) shift_time = 10; diff --git a/src/GraduatedFader.hpp b/src/GraduatedFader.hpp index 8952652..49ab4dc 100644 --- a/src/GraduatedFader.hpp +++ b/src/GraduatedFader.hpp @@ -23,15 +23,16 @@ template struct GraduatedFader : app::SliderKnob, baconpaul::rackplugs:: fb = new widget::FramebufferWidget(); addChild(fb); - notches = new BufferedDrawFunctionWidget( - Vec(0, 0), box.size, [this](auto vg) { drawBackground(vg);}); + notches = new BufferedDrawFunctionWidget(Vec(0, 0), box.size, + [this](auto vg) { drawBackground(vg); }); fb->addChild(notches); - shadow = new BufferedDrawFunctionWidget( - Vec(0, 0), Vec(20, 41), [this](auto vg) {drawHandleShadow(vg);}); + shadow = new BufferedDrawFunctionWidget(Vec(0, 0), Vec(20, 41), + [this](auto vg) { drawHandleShadow(vg); }); fb->addChild(shadow); - handle = new BufferedDrawFunctionWidget(Vec(0, 0), Vec(20, 41), [this](auto vg) {drawHandle(vg);}); + handle = new BufferedDrawFunctionWidget(Vec(0, 0), Vec(20, 41), + [this](auto vg) { drawHandle(vg); }); fb->addChild(handle); } @@ -98,7 +99,6 @@ template struct GraduatedFader : app::SliderKnob, baconpaul::rackplugs:: int slideBump = 5; int slotWidth = 1; - float dx = (1.0 * slideHeight) / nStrokes; // and now the black notches diff --git a/src/HarMoNee.cpp b/src/HarMoNee.cpp index f6703a8..9d5c943 100644 --- a/src/HarMoNee.cpp +++ b/src/HarMoNee.cpp @@ -2,7 +2,6 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - namespace bp = baconpaul::rackplugs; struct HarMoNee : bp::BaconModule @@ -76,7 +75,7 @@ struct HarMoNee : bp::BaconModule { v = 0; } - configParam(i, 0, 1, v, "Offset by " + std::string(labels[i-HALF_STEP])); + configParam(i, 0, 1, v, "Offset by " + std::string(labels[i - HALF_STEP])); } for (int i = 0; i < OCTAVE; ++i) diff --git a/src/KarplusStrongPoly.cpp b/src/KarplusStrongPoly.cpp index 5598195..81ca61f 100644 --- a/src/KarplusStrongPoly.cpp +++ b/src/KarplusStrongPoly.cpp @@ -324,7 +324,8 @@ KarplusStrongPolyWidget::KarplusStrongPolyWidget(KarplusStrongPoly *module) : Mo auto cl = [&](std::string lab, float ys) { bg->addLabel(Vec(obuf + margin, outy + ys / 2), lab.c_str(), 13, - NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT, baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); + NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT, + baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); }; yh = SizeTable::Y; diff --git a/src/LintBuddy.cpp b/src/LintBuddy.cpp index 4367e45..b4b21f2 100644 --- a/src/LintBuddy.cpp +++ b/src/LintBuddy.cpp @@ -195,11 +195,10 @@ struct MyPatch : LintBuddyTest { info.push_back("Patch Path"); info.push_back("[" + pt->path + "]"); - } else { - info.push_back("PT is NULL" ); + info.push_back("PT is NULL"); } } }; @@ -519,7 +518,7 @@ LintBuddyWidget::LintBuddyWidget(LintBuddy *m) : bp::BaconModuleWidget() if (lbm) { std::cout << "Running 100x" << std::endl; - for (int i=0; i<100; ++i) + for (int i = 0; i < 100; ++i) lbm->rerun(); } }; diff --git a/src/LuckyHold.cpp b/src/LuckyHold.cpp index b9a8126..3063df3 100644 --- a/src/LuckyHold.cpp +++ b/src/LuckyHold.cpp @@ -8,8 +8,6 @@ namespace bp = baconpaul::rackplugs; - - struct LuckyHold : virtual bp::BaconModule { enum ParamIds @@ -50,7 +48,7 @@ struct LuckyHold : virtual bp::BaconModule std::default_random_engine gen; std::uniform_real_distribution ud; - LuckyHold() : bp::BaconModule(), ud(0,1) + LuckyHold() : bp::BaconModule(), ud(0, 1) { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); @@ -60,7 +58,7 @@ struct LuckyHold : virtual bp::BaconModule configParam(CHANCE, -1, 1, 0, "A (-1) or B (1) chance?", "%", 0, 100); configParam(RNG_SCALE, 0, 10, 10, "Random CV Scale", "V"); configParam(RNG_OFFSET, -5, 5, 0, "Random CV Center", "V"); - configSwitch(LATCH, 0, 1, 1, "Latch vs Passthrough", { "Passthrough", "Latch" } ); + configSwitch(LATCH, 0, 1, 1, "Latch vs Passthrough", {"Passthrough", "Latch"}); configInput(CLOCK_IN, "Clock"); configInput(CHANCE_CV, "Chance"); @@ -72,7 +70,7 @@ struct LuckyHold : virtual bp::BaconModule configBypass(CLOCK_IN, A_CLOCK); configBypass(CLOCK_IN, B_CLOCK); - for (int i=0; ilights[LuckyHold::GATE_0 + i].value) { @@ -201,28 +195,31 @@ struct ABLights : rack::TransparentWidget, baconpaul::rackplugs::StyleParticipan rack::TransparentWidget::step(); } - void drawBG(NVGcontext *vg) { + void drawBG(NVGcontext *vg) + { auto style = baconpaul::rackplugs::BaconStyle::get(); int nChan = MAX_POLY; if (module) nChan = module->nChan; - for (int i=0; igetColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); + nvgStrokeColor(vg, + style->getColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); nvgMoveTo(vg, xc0 + i * dx, yc0 + cSize); nvgLineTo(vg, xc0 + i * dx, yc0 + 2 * dy - cSize); nvgStrokeWidth(vg, 0.5); nvgStroke(vg); - for (int j=0; j<3; ++j) + for (int j = 0; j < 3; ++j) { - if (j==1) + if (j == 1) continue; nvgBeginPath(vg); nvgEllipse(vg, xc0 + dx * i, yc0 + dy * j, cSize, cSize); nvgFillColor(vg, style->getColor(baconpaul::rackplugs::BaconStyle::LIGHT_BG)); - nvgStrokeColor(vg, style->getColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); + nvgStrokeColor( + vg, style->getColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); if (i < nChan) nvgFill(vg); nvgStrokeWidth(vg, 0.5); @@ -230,20 +227,24 @@ struct ABLights : rack::TransparentWidget, baconpaul::rackplugs::StyleParticipan } } } - void drawLight(NVGcontext *vg) { + void drawLight(NVGcontext *vg) + { auto style = baconpaul::rackplugs::BaconStyle::get(); - for (int i=0; i 0) j = 0; - if (vals[i] < 0) j = 2; + int j = 1; + if (vals[i] > 0) + j = 0; + if (vals[i] < 0) + j = 2; nvgBeginPath(vg); nvgEllipse(vg, xc0 + dx * i, yc0 + dy * j, cSize, cSize); nvgFillColor(vg, SCHEME_BLUE); - nvgStrokeColor(vg, style->getColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); + nvgStrokeColor(vg, + style->getColor(baconpaul::rackplugs::BaconStyle::SECTION_RULE_LINE)); nvgFill(vg); nvgStrokeWidth(vg, 0.5); nvgStroke(vg); @@ -276,11 +277,10 @@ LuckyHoldWidget::LuckyHoldWidget(LuckyHold *m) : bp::BaconModuleWidget() bg->addRoundedBorder(rack::Vec(5, yp), rack::Vec(box.size.x - 10, h)); bg->addLabel(rack::Vec(8, yp + h * 0.5), "Poly", 12, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); addParam(createParamCentered(Vec(60, yp + h * 0.5), module, M::POLY_COUNT)); - auto msg = MultiDigitSevenSegmentLight::create(rack::Vec(90, yp + h * 0.5), module, - M::POLY_LIGHT); + auto msg = MultiDigitSevenSegmentLight::create(rack::Vec(90, yp + h * 0.5), + module, M::POLY_LIGHT); msg->box.pos.y -= msg->box.size.y * 0.5; addChild(msg); - } // Chance Knob CV In and Switch @@ -290,13 +290,12 @@ LuckyHoldWidget::LuckyHoldWidget(LuckyHold *m) : bp::BaconModuleWidget() bg->addLabel(rack::Vec(8, yp + h * 0.5), "Chance", 12, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); addParam(createParamCentered(Vec(60, yp + h * 0.5), module, M::CHANCE)); - addInput(createInputCentered(rack::Vec(90, yp + h * 0.5), - module, - M::CHANCE_CV)); + addInput( + createInputCentered(rack::Vec(90, yp + h * 0.5), module, M::CHANCE_CV)); addParam(createParamCentered(rack::Vec(115, yp + h * 0.5 + 3), module, M::LATCH)); - bg->addLabel(rack::Vec(115, yp + h * 0.5 - 9), "latch", 8, NVG_ALIGN_BOTTOM | NVG_ALIGN_CENTER); - + bg->addLabel(rack::Vec(115, yp + h * 0.5 - 9), "latch", 8, + NVG_ALIGN_BOTTOM | NVG_ALIGN_CENTER); } // Scale and Offset Knobs @@ -305,10 +304,14 @@ LuckyHoldWidget::LuckyHoldWidget(LuckyHold *m) : bp::BaconModuleWidget() bg->addRoundedBorder(rack::Vec(5, yp), rack::Vec(box.size.x - 10, h)); bg->addLabel(rack::Vec(8, yp + h * 0.5), "Rand CV", 12, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); - addParam(createParamCentered(Vec(65, yp + h * 0.5 - 3), module, M::RNG_SCALE)); - bg->addLabel(rack::Vec(65, yp + h * 0.5 + 10), "scale", 8, NVG_ALIGN_TOP | NVG_ALIGN_CENTER); - addParam(createParamCentered(Vec(105, yp + h * 0.5 - 3), module, M::RNG_OFFSET)); - bg->addLabel(rack::Vec(105, yp + h * 0.5 + 10), "center", 8, NVG_ALIGN_TOP | NVG_ALIGN_CENTER); + addParam(createParamCentered(Vec(65, yp + h * 0.5 - 3), module, + M::RNG_SCALE)); + bg->addLabel(rack::Vec(65, yp + h * 0.5 + 10), "scale", 8, + NVG_ALIGN_TOP | NVG_ALIGN_CENTER); + addParam(createParamCentered(Vec(105, yp + h * 0.5 - 3), module, + M::RNG_OFFSET)); + bg->addLabel(rack::Vec(105, yp + h * 0.5 + 10), "center", 8, + NVG_ALIGN_TOP | NVG_ALIGN_CENTER); } auto lt = new ABLights; @@ -319,38 +322,38 @@ LuckyHoldWidget::LuckyHoldWidget(LuckyHold *m) : bp::BaconModuleWidget() addChild(lt); std::vector labels{"A", "B", "Every"}; - for (int i=0; i<3; ++i) + for (int i = 0; i < 3; ++i) { auto h = 144 - i * 38; bg->addRoundedBorder(Vec(5, RACK_HEIGHT - (h + 30)), Vec(box.size.x - 10, 35), baconpaul::rackplugs::BaconStyle::HIGHLIGHT_BG); - bg->addLabel(Vec(20, RACK_HEIGHT - (h+12)), labels[i].c_str(), 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, + bg->addLabel(Vec(20, RACK_HEIGHT - (h + 12)), labels[i].c_str(), 11, + NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_HIGHLIGHT_LABEL); bg->addLabel(Vec(20, RACK_HEIGHT - h), "gate", 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_HIGHLIGHT_LABEL); addOutput( - createOutput(Vec(35, RACK_HEIGHT - (h+24)), module, M::A_CLOCK + i * 2)); + createOutput(Vec(35, RACK_HEIGHT - (h + 24)), module, M::A_CLOCK + i * 2)); - bg->addLabel(Vec(80, RACK_HEIGHT - (h+12)), labels[i].c_str(), 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, + bg->addLabel(Vec(80, RACK_HEIGHT - (h + 12)), labels[i].c_str(), 11, + NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_HIGHLIGHT_LABEL); bg->addLabel(Vec(80, RACK_HEIGHT - h), "CV", 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_HIGHLIGHT_LABEL); addOutput( - createOutput(Vec(95, RACK_HEIGHT - (h+24)), module, M::A_RNG + i * 2)); - + createOutput(Vec(95, RACK_HEIGHT - (h + 24)), module, M::A_RNG + i * 2)); } { auto h = 30; bg->addRoundedBorder(Vec(5, RACK_HEIGHT - (h + 30)), Vec(70, 35), baconpaul::rackplugs::BaconStyle::INPUT_BG); - bg->addLabel(Vec(20, RACK_HEIGHT - (h+12)), "Clock", 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, + bg->addLabel(Vec(20, RACK_HEIGHT - (h + 12)), "Clock", 11, + NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); bg->addLabel(Vec(20, RACK_HEIGHT - h), "in", 11, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM, baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL); - addInput( - createInput(Vec(43, RACK_HEIGHT - (h+24)), module, M::CLOCK_IN)); - + addInput(createInput(Vec(43, RACK_HEIGHT - (h + 24)), module, M::CLOCK_IN)); } } diff --git a/src/Open303.cpp b/src/Open303.cpp index 07e5391..89d6538 100644 --- a/src/Open303.cpp +++ b/src/Open303.cpp @@ -273,7 +273,7 @@ struct Open303SequenceDisplay : public rack::TransparentWidget this->box.pos = pos; this->box.size = rack::Vec(nStepX * stepPxW, nStepY * stepPxH); addChild(new BufferedDrawFunctionWidget(rack::Vec(0, 0), this->box.size, - [this](NVGcontext *c) { this->drawSequence(c); })); + [this](NVGcontext *c) { this->drawSequence(c); })); } void drawSequence(NVGcontext *vg) diff --git a/src/PatchNameDisplay.cpp b/src/PatchNameDisplay.cpp new file mode 100644 index 0000000..930ef6b --- /dev/null +++ b/src/PatchNameDisplay.cpp @@ -0,0 +1,136 @@ +#include "BaconPlugs.hpp" + +#include "BaconModule.hpp" +#include "BaconModuleWidget.h" + +#include "patch.hpp" + +#include +namespace fs = ghc::filesystem; + +#define SCALE_LENGTH 12 + +namespace bp = baconpaul::rackplugs; + +struct PatchNameDisplay : virtual bp::BaconModule +{ + enum ParamIds + { + NUM_PARAMS + }; + + enum InputIds + { + NUM_INPUTS + }; + + enum OutputIds + { + NUM_OUTPUTS + }; + + enum LightIds + { + NUM_LIGHTS, + }; + + PatchNameDisplay() : bp::BaconModule() + { + config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); + } + + void process(const ProcessArgs &args) override {} + + enum ColorScheme + { + DEFAULT, + HICONTRAST_LIGHT, + HICONTRAST_DARK, + }; + + std::atomic colorScheme; + json_t *dataToJson() override + { + auto *rootJ = json_object(); + json_object_set(rootJ, "colorScheme", json_integer(colorScheme)); + return rootJ; + } + void dataFromJson(json_t *rootJ) override + { + auto cs = json_object_get(rootJ, "colorScheme"); + colorScheme = (ColorScheme)(cs ? json_integer_value(cs) : 0); + } +}; + +struct PatchNameDisplayWidget : bp::BaconModuleWidget +{ + PatchNameDisplayWidget(PatchNameDisplay *model); + ~PatchNameDisplayWidget() {} + + std::string lastPatchName{}; + void step() override + { + if (module) + { + auto c = dynamic_cast(module); + if (c) + { + std::string tpn = rack::contextGet()->patch->path; + if (tpn != lastPatchName) + { + tpn = lastPatchName; + bdw->dirty = true; + } + } + } + bp::BaconModuleWidget::step(); + } + BufferedDrawFunctionWidget *bdw{nullptr}; + void drawLabel(NVGcontext *vg) + { + nvgSave(vg); + nvgRotate(vg, M_PI_2); + + auto memFont = + InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); + auto labelColor = baconpaul::rackplugs::BaconStyle::get()->getColor( + baconpaul::rackplugs::BaconStyle::DEFAULT_MUTED_LABEL); + + auto fp = fs::path{rack::contextGet()->patch->path}; + + nvgBeginPath(vg); + nvgFontFaceId(vg, memFont); + nvgFontSize(vg, 12); + nvgFillColor(vg, labelColor); + nvgTextAlign(vg, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); + + auto plabel = fp.parent_path().u8string(); + nvgText(vg, 5, -box.size.x * 0.77, plabel.c_str(), nullptr); + + nvgBeginPath(vg); + nvgFontFaceId(vg, memFont); + nvgFontSize(vg, 24); + nvgFillColor(vg, labelColor); + nvgTextAlign(vg, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); + + auto flabel = fp.filename().u8string(); + nvgText(vg, 5, -box.size.x * 0.30, flabel.c_str(), nullptr); + nvgRestore(vg); + }; +}; + +PatchNameDisplayWidget::PatchNameDisplayWidget(PatchNameDisplay *model) : bp::BaconModuleWidget() +{ + setModule(model); + box.size = Vec(SCREW_WIDTH * 3, RACK_HEIGHT); + + BaconBackground *bg = new BaconBackground(box.size, "Name"); + addChild(bg->wrappedInFramebuffer()); + + bdw = new BufferedDrawFunctionWidget(rack::Vec(0, 25), rack::Vec(box.size.x, box.size.y - 50), + [this](auto *vg) { drawLabel(vg); }); + addChild(bdw); +} + +Model *modelPatchNameDisplay = + createModel("PatchNameDisplay"); diff --git a/src/PolyGenerator.cpp b/src/PolyGenerator.cpp index 2eb1ec9..717a284 100644 --- a/src/PolyGenerator.cpp +++ b/src/PolyGenerator.cpp @@ -11,14 +11,15 @@ struct PolyGeneratorWidget : baconpaul::rackplugs::BaconModuleWidget int memFont = -1; void drawBG(NVGcontext *vg) { - memFont = InternalFontMgr::get(vg,baconpaul::rackplugs::BaconStyle::get()->fontName()); + memFont = InternalFontMgr::get(vg, baconpaul::rackplugs::BaconStyle::get()->fontName()); for (int i = 0; i < 4; ++i) { nvgBeginPath(vg); nvgFontFaceId(vg, memFont); nvgFontSize(vg, 14); - nvgFillColor(vg, baconpaul::rackplugs::BaconStyle::get()->getColor(baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL)); + nvgFillColor(vg, baconpaul::rackplugs::BaconStyle::get()->getColor( + baconpaul::rackplugs::BaconStyle::DEFAULT_LABEL)); nvgTextAlign(vg, NVG_ALIGN_TOP | NVG_ALIGN_LEFT); nvgText(vg, 7, y0 + i * dy, labels[i].c_str(), NULL); } diff --git a/src/PolyGenerator.hpp b/src/PolyGenerator.hpp index c2079cc..3056213 100644 --- a/src/PolyGenerator.hpp +++ b/src/PolyGenerator.hpp @@ -6,7 +6,6 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - struct PPlayer { struct pnote diff --git a/src/PolyGnome.cpp b/src/PolyGnome.cpp index e222cfb..fc2c80b 100644 --- a/src/PolyGnome.cpp +++ b/src/PolyGnome.cpp @@ -8,7 +8,6 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - namespace bp = baconpaul::rackplugs; struct PolyGnomeWidget : bp::BaconModuleWidget @@ -51,18 +50,16 @@ PolyGnomeWidget::PolyGnomeWidget(PolyGnomeWidget::M *module) addChild(MultiDigitSevenSegmentLight::create(Vec(7 + 30, kPos + 2), module, M::BPM_LIGHT)); - outP.x = 12; outP.y = 108; addParam(createParamCentered(outP, module, M::RUN_PARAM)); outP.y -= 4; auto lp = outP; lp.y -= 8; - bg->addLabel(lp, "run", 11, NVG_ALIGN_BOTTOM | NVG_ALIGN_CENTER);; + bg->addLabel(lp, "run", 11, NVG_ALIGN_BOTTOM | NVG_ALIGN_CENTER); + ; lp.y -= 15; - addChild(createLightCentered>( - lp, module, M::RUNNING_LIGHT)); - + addChild(createLightCentered>(lp, module, M::RUNNING_LIGHT)); outP.x += 23; @@ -83,12 +80,11 @@ PolyGnomeWidget::PolyGnomeWidget(PolyGnomeWidget::M *module) srp.y -= 10; srp.x += 18; - auto srlt = MultiDigitSevenSegmentLight::create(srp, module, - M::SELF_RESET_LIGHT); + auto srlt = + MultiDigitSevenSegmentLight::create(srp, module, M::SELF_RESET_LIGHT); srlt->blankZero = true; addChild(srlt); - outP.x = 93 + 37; bg->addPlugLabel(outP, BaconBackground::SIG_IN, "bpm"); addInput(createInput(outP, module, M::BPM_INPUT)); @@ -100,9 +96,8 @@ PolyGnomeWidget::PolyGnomeWidget(PolyGnomeWidget::M *module) addInput(createInput(outP, module, M::RESET_INPUT)); outP.x += 37; - int bh = 41; - std::vector startX{15,43,82,110, 146, 176, 206}; + std::vector startX{15, 43, 82, 110, 146, 176, 206}; auto lb = 154; bg->addLabel(rack::Vec(startX[0], lb), "N beats...", 11, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM); @@ -118,27 +113,20 @@ PolyGnomeWidget::PolyGnomeWidget(PolyGnomeWidget::M *module) Vec outP = Vec(box.size.x - 51, ypos); bg->addRoundedBorder(Vec(4, outP.y - 4), Vec(box.size.x - 8, bh - 5)); - auto pv = [&](int i) - { - return rack::Vec(startX[i], ypos + 2); - }; + auto pv = [&](int i) { return rack::Vec(startX[i], ypos + 2); }; // knob light knob light port port port - addParam(createParam(pv(0), module, - M::CLOCK_NUMERATOR_0 + (i - 1))); + addParam(createParam(pv(0), module, M::CLOCK_NUMERATOR_0 + (i - 1))); addChild(MultiDigitSevenSegmentLight::create( pv(1), module, M::LIGHT_DENOMINATOR_1 + (i - 1))); - addParam(createParam(pv(2), module, - M::CLOCK_DENOMINATOR_0 + (i - 1))); + addParam(createParam(pv(2), module, M::CLOCK_DENOMINATOR_0 + (i - 1))); addChild(MultiDigitSevenSegmentLight::create( - pv(3), module, M::LIGHT_NUMERATOR_1 + (i - 1))); + pv(3), module, M::LIGHT_NUMERATOR_1 + (i - 1))); - addParam(createParam(pv(4), module, - M::CLOCK_PULSE_WIDTH_0 + (i - 1))); + addParam(createParam(pv(4), module, M::CLOCK_PULSE_WIDTH_0 + (i - 1))); addOutput(createOutput(pv(5), module, M::CLOCK_GATE_0 + i)); addOutput(createOutput(pv(6), module, M::CLOCK_CV_LEVEL_0 + i)); - } } diff --git a/src/PolyGnome.hpp b/src/PolyGnome.hpp index caaf82d..cbc87fc 100644 --- a/src/PolyGnome.hpp +++ b/src/PolyGnome.hpp @@ -64,17 +64,20 @@ template struct PolyGnome : virtual TBase TBase::configParam(CLOCK_PARAM, -2.0, 2.0, 0.0, "Clock tempo", " bpm", 2.f, 120.f); for (int i = 0; i < NUM_CLOCKS; ++i) { - auto d = TBase::configParam(CLOCK_DENOMINATOR_0 + i, 1, 32, 1, "Denominator " + std::to_string(i+1)); + auto d = TBase::configParam(CLOCK_DENOMINATOR_0 + i, 1, 32, 1, + "Denominator " + std::to_string(i + 1)); d->snapEnabled = true; - auto n = TBase::configParam(CLOCK_NUMERATOR_0 + i, 1, 32, 1, "Numerator " + std::to_string(i+1) ); + auto n = TBase::configParam(CLOCK_NUMERATOR_0 + i, 1, 32, 1, + "Numerator " + std::to_string(i + 1)); n->snapEnabled = true; - TBase::configParam(CLOCK_PULSE_WIDTH_0 + i, 0, 1, 0.5, "Pulse Width " + std::to_string(i+1)); + TBase::configParam(CLOCK_PULSE_WIDTH_0 + i, 0, 1, 0.5, + "Pulse Width " + std::to_string(i + 1)); } - for (int i=0; i struct PolyGnome : virtual TBase TBase::configBypass(RUN_INPUT, RUN_OUTPUT); TBase::configBypass(RESET_INPUT, RESET_OUTPUT); TBase::configBypass(BPM_INPUT, CLOCK_CV_LEVEL_0); - for (int i=0; isnapEnabled = true; } @@ -148,7 +151,7 @@ template struct PolyGnome : virtual TBase } } - if (useGates && ! wasRunning) + if (useGates && !wasRunning) { wasRunning = true; doReset = true; @@ -179,7 +182,6 @@ template struct PolyGnome : virtual TBase wasResetting = false; } - for (int i = 0; i < NUM_CLOCKS; ++i) { float cbpm = beatsPerMinute * numi(i) / deni(i); @@ -257,7 +259,7 @@ template struct PolyGnome : virtual TBase if (gateIn && !priorGates[i] && i == 0) { - since_reset ++; + since_reset++; } priorGates[i] = gateIn; diff --git a/src/QuantEyes.cpp b/src/QuantEyes.cpp index e24e4ff..81ef412 100644 --- a/src/QuantEyes.cpp +++ b/src/QuantEyes.cpp @@ -6,7 +6,6 @@ #define SCALE_LENGTH 12 - namespace bp = baconpaul::rackplugs; struct QuantEyes : virtual bp::BaconModule @@ -49,14 +48,14 @@ struct QuantEyes : virtual bp::BaconModule config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(ROOT_STEP, 0, 12, 0, "The root in 1/12 of a volt"); for (int i = 0; i < SCALE_LENGTH; ++i) - configParam(SCALE_PARAM + i, 0, 1, 0, "Allow Scale Tone " + std::to_string(i+1)); + configParam(SCALE_PARAM + i, 0, 1, 0, "Allow Scale Tone " + std::to_string(i + 1)); for (int i = 0; i < SCALE_LENGTH; ++i) scaleState[i] = 1; configInput(CV_INPUT, "V/Oct Input"); configOutput(QUANTIZED_OUT, "Quantized Output"); configOutput(CHANGE_TRIG_OUT, "Trigger on Change"); - for (int i=0; i<16; ++i) + for (int i = 0; i < 16; ++i) { priorOut[i] = 0; trigOut[i] = 0; @@ -139,7 +138,7 @@ struct QuantEyes : virtual bp::BaconModule if (trigOut[i]) { outputs[CHANGE_TRIG_OUT].setVoltage(10.0, i); - trigOut[i] --; + trigOut[i]--; } else { @@ -276,8 +275,7 @@ void QuantEyesWidget::appendModuleSpecificContextMenu(Menu *menu) QuantEyes *qe = dynamic_cast(module); auto addScale = [menu, qe](const char *name, QuantEyesScaleItem::scale_t scale) { - QuantEyesScaleItem *scaleItem = - createMenuItem(name); + QuantEyesScaleItem *scaleItem = createMenuItem(name); scaleItem->quanteyes = qe; scaleItem->setScale(scale); menu->addChild(scaleItem); diff --git a/src/SampleDelay.cpp b/src/SampleDelay.cpp index 071a553..40d0284 100644 --- a/src/SampleDelay.cpp +++ b/src/SampleDelay.cpp @@ -5,7 +5,6 @@ #include "BaconModule.hpp" #include "BaconModuleWidget.h" - namespace bp = baconpaul::rackplugs; struct SampleDelayWidget : bp::BaconModuleWidget diff --git a/src/Style.cpp b/src/Style.cpp index a575dfb..e37cd8f 100644 --- a/src/Style.cpp +++ b/src/Style.cpp @@ -9,16 +9,7 @@ namespace baconpaul::rackplugs { std::shared_ptr BaconStyle::stylePtr{nullptr}; -BaconStyle::BaconStyle() -{ -#ifndef USING_CARDINAL_NOT_RACK - auto lpd = rack::settings::preferDarkPanels; - if (lpd) - setStyle(BaconStyle::DARK); - else - setStyle(BaconStyle::LIGHT); -#endif -} +BaconStyle::BaconStyle() { setStyle(); } NVGcolor getColorLight(baconpaul::rackplugs::BaconStyle::Colors c) { diff --git a/src/Style.hpp b/src/Style.hpp index d90d3b4..688fb28 100644 --- a/src/Style.hpp +++ b/src/Style.hpp @@ -33,10 +33,20 @@ struct BaconStyle LIGHT }; Style activeStyle{LIGHT}; - void setStyle(Style s) + void setStyle() { - activeStyle = s; - notifyStyleListeners(); + auto rs = rack::settings::preferDarkPanels; + + if (rs && activeStyle == LIGHT) + { + activeStyle = DARK; + notifyStyleListeners(); + } + else if (!rs && activeStyle == DARK) + { + activeStyle = LIGHT; + notifyStyleListeners(); + } } friend struct StyleParticipant;