Skip to content

Commit

Permalink
Add Patch Name Display; Update to rack dark panel setting
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Feb 4, 2024
1 parent cc7fcfc commit 3f0b0df
Show file tree
Hide file tree
Showing 27 changed files with 351 additions and 258 deletions.
1 change: 0 additions & 1 deletion src/ALingADing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "BaconModule.hpp"
#include "BaconModuleWidget.h"


namespace bp = baconpaul::rackplugs;

/*
Expand Down
3 changes: 1 addition & 2 deletions src/BaconModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace baconpaul::rackplugs
{
struct BaconModule : rack::engine::Module
{

};
}
} // namespace baconpaul::rackplugs

#endif // BACONPLUGS_RACK_HACK_BACONMODULE_H
22 changes: 4 additions & 18 deletions src/BaconModuleWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/BaconPlugs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/BaconPlugs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern Model *modelPolyGenerator;
extern Model *modelLintBuddy;
extern Model *modelLuckyHold;
extern Model *modelContrastBNDEditor;
extern Model *modelPatchNameDisplay;

extern Model *modelBaconTest;

Expand Down
53 changes: 21 additions & 32 deletions src/BaconTestModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand All @@ -97,16 +82,17 @@ 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;

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<std::pair<float, float>> poly_t;
Expand All @@ -125,32 +111,35 @@ 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;
for (auto &poly : polys)
{
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;
}
nvgClosePath(vg);
// 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++;
Expand Down
10 changes: 4 additions & 6 deletions src/BufferedDrawFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,32 @@ 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;
auto kidBox = Rect(Vec(0, 0), box.size);
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
}

#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};
Expand Down
10 changes: 3 additions & 7 deletions src/ChipNoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -117,12 +116,9 @@ struct ChipNoise : virtual bp::BaconModule, sst::rackhelpers::module_connector::
outputs[NOISE_OUTPUT].setVoltage(noise->step());
}


std::optional<std::vector<labeledStereoPort_t>> getPrimaryOutputs() override
{
return {{
std::make_pair("Noise", std::make_pair(NOISE_OUTPUT, -1))
}};
return {{std::make_pair("Noise", std::make_pair(NOISE_OUTPUT, -1))}};
}
};

Expand Down
10 changes: 4 additions & 6 deletions src/ChipWaves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,13 +108,10 @@ struct ChipWaves : virtual bp::BaconModule, sst::rackhelpers::module_connector::
}
}


std::optional<std::vector<labeledStereoPort_t>> 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))}};
}
};

Expand Down
Loading

0 comments on commit 3f0b0df

Please sign in to comment.