-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a PleaseQuit module * update workflow
- Loading branch information
Showing
7 changed files
with
161 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sst-basic-blocks
updated
13 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,6 @@ extern Model *modelPatchNameDisplay; | |
|
||
extern Model *modelBaconTest; | ||
|
||
extern Model *modelPleaseQuit; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
#include "PleaseQuit.hpp" | ||
#include "BaconPlugs.hpp" | ||
|
||
#include "BaconModule.hpp" | ||
#include "BaconModuleWidget.h" | ||
|
||
namespace bp = baconpaul::rackplugs; | ||
|
||
struct PleaseQuitWidget : bp::BaconModuleWidget | ||
{ | ||
typedef PleaseQuit<bp::BaconModule> SD; | ||
PleaseQuitWidget(SD *module); | ||
|
||
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); | ||
|
||
nvgBeginPath(vg); | ||
nvgFontFaceId(vg, memFont); | ||
nvgFontSize(vg, 12); | ||
nvgFillColor(vg, labelColor); | ||
nvgTextAlign(vg, NVG_ALIGN_MIDDLE | NVG_ALIGN_LEFT); | ||
|
||
auto plabel = std::string("PleaseQuit is a utility module to shut down rack"); | ||
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 = std::string("Rack Quits on Trigger"); | ||
nvgText(vg, 5, -box.size.x * 0.30, flabel.c_str(), nullptr); | ||
nvgRestore(vg); | ||
}; | ||
}; | ||
|
||
PleaseQuitWidget::PleaseQuitWidget(SD *module) | ||
{ | ||
setModule(module); | ||
box.size = Vec(SCREW_WIDTH * 3, RACK_HEIGHT); | ||
|
||
BaconBackground *bg = new BaconBackground(box.size, "Quit"); | ||
addChild(bg->wrappedInFramebuffer()); | ||
|
||
int outy = 30; | ||
//int gap = 10; | ||
//int margin = 3; | ||
|
||
// plug label is 29 x 49 | ||
Vec ppos = Vec(bg->cx(SizeTable<PJ301MPort>::X), outy + 20); | ||
bg->addPlugLabel(ppos, BaconBackground::SIG_IN, "bye!"); | ||
addInput(createInput<PJ301MPort>(ppos, module, SD::PLEASE_QUIT)); | ||
|
||
bdw = new BufferedDrawFunctionWidget(rack::Vec(0, outy + 70), rack::Vec(box.size.x, box.size.y - 70 - 25), | ||
[this](auto *vg) { drawLabel(vg); }); | ||
addChild(bdw); | ||
} | ||
|
||
Model *modelPleaseQuit = createModel<PleaseQuitWidget::SD, PleaseQuitWidget>("PleaseQuit"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
#include <algorithm> | ||
#include <vector> | ||
#include "rack.hpp" | ||
|
||
template <typename TBase> struct PleaseQuit : virtual TBase | ||
{ | ||
enum ParamIds | ||
{ | ||
NUM_PARAMS | ||
}; | ||
|
||
enum InputIds | ||
{ | ||
PLEASE_QUIT, | ||
NUM_INPUTS | ||
}; | ||
|
||
enum OutputIds | ||
{ | ||
NUM_OUTPUTS | ||
}; | ||
|
||
enum LightIds | ||
{ | ||
NUM_LIGHTS | ||
}; | ||
|
||
using TBase::inputs; | ||
using TBase::lights; | ||
using TBase::outputs; | ||
using TBase::params; | ||
|
||
std::vector<float> ring[16]; | ||
size_t ringSize; | ||
size_t pos[16]; | ||
|
||
PleaseQuit() : TBase() | ||
{ | ||
TBase::config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); | ||
TBase::configInput(PLEASE_QUIT, "Trigger Me to Quit"); | ||
} | ||
|
||
rack::dsp::SchmittTrigger inTrig; | ||
uint64_t samplesGoneBy{0}; | ||
void process(const typename TBase::ProcessArgs &args) override | ||
{ | ||
if (samplesGoneBy < 12000) | ||
{ | ||
samplesGoneBy ++; | ||
} | ||
else | ||
{ | ||
if (inTrig.process(inputs[PLEASE_QUIT].getVoltageSum())) | ||
{ | ||
APP->window->close(); | ||
} | ||
} | ||
} | ||
}; |