BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit 339a141774bb9e53bf2e7381d031eed4b846d43f
parent aedd96b96cc0ccfb7a0705cfd47f982b063c5a1b
Author: Matt Demanett <matt@demanett.net>
Date:   Sun, 18 Feb 2018 02:58:07 -0500

Give each module a header -> no module delcarations in a central header -> less unnecessary recompiling.  Also, merged template panel into a single hpp/cpp.

Diffstat:
Msrc/Analyzer.cpp | 197++++++++++++++++++++++++++-----------------------------------------------------
Asrc/Analyzer.hpp | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/DADSRH.cpp | 323++++++++++++++++++++++++-------------------------------------------------------
Asrc/DADSRH.hpp | 134+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/DADSRHPlus.cpp | 378+++++++++++++++++++++++++------------------------------------------------------
Asrc/DADSRHPlus.hpp | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/DGate.cpp | 139++++++++++++++++++++++++-------------------------------------------------------
Asrc/DGate.hpp | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Detune.cpp | 98+++++++++++++++++++++++++------------------------------------------------------
Asrc/Detune.hpp | 41+++++++++++++++++++++++++++++++++++++++++
Dsrc/EightHP.cpp | 55-------------------------------------------------------
Dsrc/EighteenHP.cpp | 57---------------------------------------------------------
Dsrc/FifteenHP.cpp | 57---------------------------------------------------------
Msrc/Manual.cpp | 117++++++++++++++++++++++++++-----------------------------------------------------
Asrc/Manual.hpp | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Noise.cpp | 96+++++++++++++++++++++++--------------------------------------------------------
Asrc/Noise.hpp | 45+++++++++++++++++++++++++++++++++++++++++++++
Msrc/Offset.cpp | 86++++++++++++++++++++++++++-----------------------------------------------------
Asrc/Offset.hpp | 35+++++++++++++++++++++++++++++++++++
Msrc/Reftone.cpp | 130+++++++++++++++++++++++++------------------------------------------------------
Asrc/Reftone.hpp | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/SampleHold.cpp | 112+++++++++++++++++++++++--------------------------------------------------------
Asrc/SampleHold.hpp | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Shaper.cpp | 249+++++++++++++++++++++++--------------------------------------------------------
Asrc/Shaper.hpp | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ShaperPlus.cpp | 300+++++++++++++++++++++++++------------------------------------------------------
Asrc/ShaperPlus.hpp | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/SixHP.cpp | 55-------------------------------------------------------
Msrc/Stack.cpp | 148++++++++++++++++++++++++++++---------------------------------------------------
Asrc/Stack.hpp | 47+++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Switch.cpp | 123++++++++++++++++++++++++++-----------------------------------------------------
Asrc/Switch.hpp | 44++++++++++++++++++++++++++++++++++++++++++++
Dsrc/TenHP.cpp | 57---------------------------------------------------------
Msrc/Test.cpp | 212++++++++++++-------------------------------------------------------------------
Asrc/Test.hpp | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/ThirteenHP.cpp | 57---------------------------------------------------------
Dsrc/ThirtyHP.cpp | 57---------------------------------------------------------
Dsrc/ThreeHP.cpp | 55-------------------------------------------------------
Dsrc/TwelveHP.cpp | 57---------------------------------------------------------
Dsrc/TwentyFiveHP.cpp | 57---------------------------------------------------------
Dsrc/TwentyHP.cpp | 57---------------------------------------------------------
Dsrc/TwentyTwoHP.cpp | 57---------------------------------------------------------
Msrc/VCA.cpp | 99++++++++++++++++++++++++++-----------------------------------------------------
Asrc/VCA.hpp | 40++++++++++++++++++++++++++++++++++++++++
Msrc/bogaudio.cpp | 22++++++++++++++++++++++
Msrc/bogaudio.hpp | 34+---------------------------------
Msrc/dadsrh_core.hpp | 1+
Msrc/shaper_core.hpp | 1+
Asrc/template_panels.cpp | 246+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/template_panels.hpp | 16++++++++++++++++
50 files changed, 2333 insertions(+), 2675 deletions(-)

diff --git a/src/Analyzer.cpp b/src/Analyzer.cpp @@ -1,10 +1,7 @@ -#include "bogaudio.hpp" -#include "dsp/analyzer.hpp" +#include "Analyzer.hpp" -using namespace bogaudio::dsp; - -struct ChannelAnalyzer : SpectrumAnalyzer { +struct bogaudio::ChannelAnalyzer : SpectrumAnalyzer { int _binsN; float* _bins; AveragingBuffer<float>* _averagedBins; @@ -78,69 +75,6 @@ float ChannelAnalyzer::getPeak() { } -struct Analyzer : Module { - enum ParamsIds { - RANGE_PARAM, - SMOOTH_PARAM, - QUALITY_PARAM, - POWER_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - SIGNALA_INPUT, - SIGNALB_INPUT, - SIGNALC_INPUT, - SIGNALD_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - SIGNALA_OUTPUT, - SIGNALB_OUTPUT, - SIGNALC_OUTPUT, - SIGNALD_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - QUALITY_HIGH_LIGHT, - QUALITY_GOOD_LIGHT, - POWER_ON_LIGHT, - NUM_LIGHTS - }; - - enum Quality { - QUALITY_HIGH, - QUALITY_GOOD - }; - - int _averageN; - ChannelAnalyzer* _channelA = NULL; - ChannelAnalyzer* _channelB = NULL; - ChannelAnalyzer* _channelC = NULL; - ChannelAnalyzer* _channelD = NULL; - float _range = 0.0; - float _smooth = 0.0; - Quality _quality = QUALITY_GOOD; - const SpectrumAnalyzer::Overlap _overlap = SpectrumAnalyzer::OVERLAP_2; - const int _binAverageN = 2; - - Analyzer() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - virtual ~Analyzer() { - onReset(); - } - - virtual void onReset() override; - virtual void onSampleRateChange() override; - void resetChannels(); - SpectrumAnalyzer::Size size(); - virtual void step() override; - void stepChannel(ChannelAnalyzer*& channelPointer, bool running, Input& input, Output& output); -}; - void Analyzer::onReset() { resetChannels(); } @@ -514,73 +448,70 @@ struct OneTenKnob : Knob38 { struct AnalyzerWidget : ModuleWidget { - AnalyzerWidget(Analyzer* module); -}; - -AnalyzerWidget::AnalyzerWidget(Analyzer* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT); + AnalyzerWidget(Analyzer* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT); + + { + auto panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Analyzer.svg"))); + addChild(panel); + } - { - auto panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Analyzer.svg"))); - addChild(panel); - } + { + auto inset = Vec(10, 25); + auto size = Vec(box.size.x - 2*inset.x, 230); + auto display = new AnalyzerDisplay(module, size); + display->box.pos = inset; + display->box.size = size; + addChild(display); + } - { - auto inset = Vec(10, 25); - auto size = Vec(box.size.x - 2*inset.x, 230); - auto display = new AnalyzerDisplay(module, size); - display->box.pos = inset; - display->box.size = size; - addChild(display); + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + + // generated by svg_widgets.rb + auto rangeParamPosition = Vec(35.08, 271.08); + auto smoothParamPosition = Vec(109.08, 271.08); + auto qualityParamPosition = Vec(186.02, 298.02); + auto powerParamPosition = Vec(259.02, 298.02); + + auto signalaInputPosition = Vec(13.5, 323.0); + auto signalbInputPosition = Vec(86.5, 323.0); + auto signalcInputPosition = Vec(160.5, 323.0); + auto signaldInputPosition = Vec(233.5, 323.0); + + auto signalaOutputPosition = Vec(42.5, 323.0); + auto signalbOutputPosition = Vec(115.5, 323.0); + auto signalcOutputPosition = Vec(189.5, 323.0); + auto signaldOutputPosition = Vec(262.5, 323.0); + + auto qualityHighLightPosition = Vec(179.0, 274.0); + auto qualityGoodLightPosition = Vec(179.0, 289.0); + auto powerOnLightPosition = Vec(252.0, 289.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<OneTenKnob>(rangeParamPosition, module, Analyzer::RANGE_PARAM, 0.1, 1.0, 0.5)); + addParam(ParamWidget::create<Knob38>(smoothParamPosition, module, Analyzer::SMOOTH_PARAM, 0.0, 1.0, 0.5)); + addParam(ParamWidget::create<StatefulButton9>(qualityParamPosition, module, Analyzer::QUALITY_PARAM, 1.0, 2.0, 1.0)); + addParam(ParamWidget::create<StatefulButton9>(powerParamPosition, module, Analyzer::POWER_PARAM, 0.0, 1.0, 1.0)); + + addInput(Port::create<Port24>(signalaInputPosition, Port::INPUT, module, Analyzer::SIGNALA_INPUT)); + addInput(Port::create<Port24>(signalbInputPosition, Port::INPUT, module, Analyzer::SIGNALB_INPUT)); + addInput(Port::create<Port24>(signalcInputPosition, Port::INPUT, module, Analyzer::SIGNALC_INPUT)); + addInput(Port::create<Port24>(signaldInputPosition, Port::INPUT, module, Analyzer::SIGNALD_INPUT)); + + addOutput(Port::create<Port24>(signalaOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALA_OUTPUT)); + addOutput(Port::create<Port24>(signalbOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALB_OUTPUT)); + addOutput(Port::create<Port24>(signalcOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALC_OUTPUT)); + addOutput(Port::create<Port24>(signaldOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALD_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(qualityHighLightPosition, module, Analyzer::QUALITY_HIGH_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(qualityGoodLightPosition, module, Analyzer::QUALITY_GOOD_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(powerOnLightPosition, module, Analyzer::POWER_ON_LIGHT)); } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); - - // generated by svg_widgets.rb - auto rangeParamPosition = Vec(35.08, 271.08); - auto smoothParamPosition = Vec(109.08, 271.08); - auto qualityParamPosition = Vec(186.02, 298.02); - auto powerParamPosition = Vec(259.02, 298.02); - - auto signalaInputPosition = Vec(13.5, 323.0); - auto signalbInputPosition = Vec(86.5, 323.0); - auto signalcInputPosition = Vec(160.5, 323.0); - auto signaldInputPosition = Vec(233.5, 323.0); - - auto signalaOutputPosition = Vec(42.5, 323.0); - auto signalbOutputPosition = Vec(115.5, 323.0); - auto signalcOutputPosition = Vec(189.5, 323.0); - auto signaldOutputPosition = Vec(262.5, 323.0); - - auto qualityHighLightPosition = Vec(179.0, 274.0); - auto qualityGoodLightPosition = Vec(179.0, 289.0); - auto powerOnLightPosition = Vec(252.0, 289.0); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<OneTenKnob>(rangeParamPosition, module, Analyzer::RANGE_PARAM, 0.1, 1.0, 0.5)); - addParam(ParamWidget::create<Knob38>(smoothParamPosition, module, Analyzer::SMOOTH_PARAM, 0.0, 1.0, 0.5)); - addParam(ParamWidget::create<StatefulButton9>(qualityParamPosition, module, Analyzer::QUALITY_PARAM, 1.0, 2.0, 1.0)); - addParam(ParamWidget::create<StatefulButton9>(powerParamPosition, module, Analyzer::POWER_PARAM, 0.0, 1.0, 1.0)); - - addInput(Port::create<Port24>(signalaInputPosition, Port::INPUT, module, Analyzer::SIGNALA_INPUT)); - addInput(Port::create<Port24>(signalbInputPosition, Port::INPUT, module, Analyzer::SIGNALB_INPUT)); - addInput(Port::create<Port24>(signalcInputPosition, Port::INPUT, module, Analyzer::SIGNALC_INPUT)); - addInput(Port::create<Port24>(signaldInputPosition, Port::INPUT, module, Analyzer::SIGNALD_INPUT)); - - addOutput(Port::create<Port24>(signalaOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALA_OUTPUT)); - addOutput(Port::create<Port24>(signalbOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALB_OUTPUT)); - addOutput(Port::create<Port24>(signalcOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALC_OUTPUT)); - addOutput(Port::create<Port24>(signaldOutputPosition, Port::OUTPUT, module, Analyzer::SIGNALD_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(qualityHighLightPosition, module, Analyzer::QUALITY_HIGH_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(qualityGoodLightPosition, module, Analyzer::QUALITY_GOOD_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(powerOnLightPosition, module, Analyzer::POWER_ON_LIGHT)); -} - +}; Model* modelAnalyzer = Model::create<Analyzer, AnalyzerWidget>("Bogaudio", "Bogaudio-Analyzer", "Analyzer", VISUAL_TAG); diff --git a/src/Analyzer.hpp b/src/Analyzer.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/analyzer.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelAnalyzer; + +namespace bogaudio { + +struct ChannelAnalyzer; + +struct Analyzer : Module { + enum ParamsIds { + RANGE_PARAM, + SMOOTH_PARAM, + QUALITY_PARAM, + POWER_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + SIGNALA_INPUT, + SIGNALB_INPUT, + SIGNALC_INPUT, + SIGNALD_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + SIGNALA_OUTPUT, + SIGNALB_OUTPUT, + SIGNALC_OUTPUT, + SIGNALD_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + QUALITY_HIGH_LIGHT, + QUALITY_GOOD_LIGHT, + POWER_ON_LIGHT, + NUM_LIGHTS + }; + + enum Quality { + QUALITY_HIGH, + QUALITY_GOOD + }; + + int _averageN; + ChannelAnalyzer* _channelA = NULL; + ChannelAnalyzer* _channelB = NULL; + ChannelAnalyzer* _channelC = NULL; + ChannelAnalyzer* _channelD = NULL; + float _range = 0.0; + float _smooth = 0.0; + Quality _quality = QUALITY_GOOD; + const SpectrumAnalyzer::Overlap _overlap = SpectrumAnalyzer::OVERLAP_2; + const int _binAverageN = 2; + + Analyzer() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + onReset(); + } + virtual ~Analyzer() { + onReset(); + } + + virtual void onReset() override; + virtual void onSampleRateChange() override; + void resetChannels(); + SpectrumAnalyzer::Size size(); + virtual void step() override; + void stepChannel(ChannelAnalyzer*& channelPointer, bool running, Input& input, Output& output); +}; + +} // namespace bogaudio diff --git a/src/DADSRH.cpp b/src/DADSRH.cpp @@ -1,234 +1,105 @@ -#include "dadsrh_core.hpp" +#include "DADSRH.hpp" -struct DADSRH : TriggerOnLoadModule { - enum ParamsIds { - DELAY_PARAM, - ATTACK_PARAM, - DECAY_PARAM, - SUSTAIN_PARAM, - RELEASE_PARAM, - HOLD_PARAM, - ATTACK_SHAPE_PARAM, - DECAY_SHAPE_PARAM, - RELEASE_SHAPE_PARAM, - TRIGGER_PARAM, - MODE_PARAM, - LOOP_PARAM, - SPEED_PARAM, - RETRIGGER_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - TRIGGER_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - ENV_OUTPUT, - INV_OUTPUT, - TRIGGER_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - DELAY_LIGHT, - ATTACK_LIGHT, - DECAY_LIGHT, - SUSTAIN_LIGHT, - RELEASE_LIGHT, - ATTACK_SHAPE1_LIGHT, - ATTACK_SHAPE2_LIGHT, - ATTACK_SHAPE3_LIGHT, - DECAY_SHAPE1_LIGHT, - DECAY_SHAPE2_LIGHT, - DECAY_SHAPE3_LIGHT, - RELEASE_SHAPE1_LIGHT, - RELEASE_SHAPE2_LIGHT, - RELEASE_SHAPE3_LIGHT, - NUM_LIGHTS - }; - - DADSRHCore _core; - - DADSRH() : TriggerOnLoadModule( - NUM_PARAMS, - NUM_INPUTS, - NUM_OUTPUTS, - NUM_LIGHTS - ) - , _core( - params[DELAY_PARAM], - params[ATTACK_PARAM], - params[DECAY_PARAM], - params[SUSTAIN_PARAM], - params[RELEASE_PARAM], - params[HOLD_PARAM], - params[ATTACK_SHAPE_PARAM], - params[DECAY_SHAPE_PARAM], - params[RELEASE_SHAPE_PARAM], - params[TRIGGER_PARAM], - params[MODE_PARAM], - params[LOOP_PARAM], - params[SPEED_PARAM], - params[RETRIGGER_PARAM], - - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - inputs[TRIGGER_INPUT], - - NULL, - NULL, - NULL, - NULL, - NULL, - outputs[ENV_OUTPUT], - outputs[INV_OUTPUT], - outputs[TRIGGER_OUTPUT], - - lights[DELAY_LIGHT], - lights[ATTACK_LIGHT], - lights[DECAY_LIGHT], - lights[SUSTAIN_LIGHT], - lights[RELEASE_LIGHT], - lights[ATTACK_SHAPE1_LIGHT], - lights[ATTACK_SHAPE2_LIGHT], - lights[ATTACK_SHAPE3_LIGHT], - lights[DECAY_SHAPE1_LIGHT], - lights[DECAY_SHAPE2_LIGHT], - lights[DECAY_SHAPE3_LIGHT], - lights[RELEASE_SHAPE1_LIGHT], - lights[RELEASE_SHAPE2_LIGHT], - lights[RELEASE_SHAPE3_LIGHT], - - _triggerOnLoad, - _shouldTriggerOnLoad - ) { - onReset(); - } - - virtual void onReset() override { - _core.reset(); - } - - virtual void step() override { - _core.step(); +struct DADSRHWidget : ModuleWidget { + DADSRHWidget(DADSRH* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/DADSRH.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto delayParamPosition = Vec(27.08, 33.08); + auto attackParamPosition = Vec(27.08, 89.08); + auto decayParamPosition = Vec(27.08, 145.08); + auto sustainParamPosition = Vec(27.08, 201.08); + auto releaseParamPosition = Vec(27.08, 257.08); + auto holdParamPosition = Vec(82.38, 313.08); + auto attackShapeParamPosition = Vec(77.02, 124.02); + auto decayShapeParamPosition = Vec(77.02, 180.52); + auto releaseShapeParamPosition = Vec(77.02, 292.52); + auto triggerParamPosition = Vec(90.04, 43.04); + auto modeParamPosition = Vec(120.0, 95.0); + auto loopParamPosition = Vec(120.0, 145.0); + auto speedParamPosition = Vec(20.0, 321.0); + auto retriggerParamPosition = Vec(55.0, 321.0); + + auto triggerInputPosition = Vec(115.0, 40.0); + + auto envOutputPosition = Vec(115.0, 191.0); + auto invOutputPosition = Vec(115.0, 228.0); + auto triggerOutputPosition = Vec(115.0, 265.0); + + auto delayLightPosition = Vec(12.0, 76.0); + auto attackLightPosition = Vec(12.0, 123.0); + auto decayLightPosition = Vec(12.0, 179.0); + auto sustainLightPosition = Vec(12.0, 235.0); + auto releaseLightPosition = Vec(12.0, 291.0); + auto attackShape1LightPosition = Vec(77.0, 96.0); + auto attackShape2LightPosition = Vec(77.0, 106.0); + auto attackShape3LightPosition = Vec(77.0, 116.0); + auto decayShape1LightPosition = Vec(77.0, 152.5); + auto decayShape2LightPosition = Vec(77.0, 162.5); + auto decayShape3LightPosition = Vec(77.0, 172.5); + auto releaseShape1LightPosition = Vec(77.0, 264.5); + auto releaseShape2LightPosition = Vec(77.0, 274.5); + auto releaseShape3LightPosition = Vec(77.0, 284.5); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Knob38>(delayParamPosition, module, DADSRH::DELAY_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<Knob38>(attackParamPosition, module, DADSRH::ATTACK_PARAM, 0.0, 1.0, 0.12)); + addParam(ParamWidget::create<Knob38>(decayParamPosition, module, DADSRH::DECAY_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(sustainParamPosition, module, DADSRH::SUSTAIN_PARAM, 0.0, 1.0, 0.5)); + addParam(ParamWidget::create<Knob38>(releaseParamPosition, module, DADSRH::RELEASE_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(holdParamPosition, module, DADSRH::HOLD_PARAM, 0.0, 1.0, 0.45)); + addParam(ParamWidget::create<StatefulButton9>(attackShapeParamPosition, module, DADSRH::ATTACK_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<StatefulButton9>(decayShapeParamPosition, module, DADSRH::DECAY_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<StatefulButton9>(releaseShapeParamPosition, module, DADSRH::RELEASE_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DADSRH::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(modeParamPosition, module, DADSRH::MODE_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DADSRH::LOOP_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, DADSRH::SPEED_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(retriggerParamPosition, module, DADSRH::RETRIGGER_PARAM, 0.0, 1.0, 1.0)); + + addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DADSRH::TRIGGER_INPUT)); + + addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, DADSRH::ENV_OUTPUT)); + addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, DADSRH::INV_OUTPUT)); + addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, DADSRH::TRIGGER_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DADSRH::DELAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, DADSRH::ATTACK_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, DADSRH::DECAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(sustainLightPosition, module, DADSRH::SUSTAIN_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseLightPosition, module, DADSRH::RELEASE_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape1LightPosition, module, DADSRH::ATTACK_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape2LightPosition, module, DADSRH::ATTACK_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape3LightPosition, module, DADSRH::ATTACK_SHAPE3_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape1LightPosition, module, DADSRH::DECAY_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape2LightPosition, module, DADSRH::DECAY_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape3LightPosition, module, DADSRH::DECAY_SHAPE3_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape1LightPosition, module, DADSRH::RELEASE_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape2LightPosition, module, DADSRH::RELEASE_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape3LightPosition, module, DADSRH::RELEASE_SHAPE3_LIGHT)); } - virtual bool shouldTriggerOnNextLoad() override { - return _core._stage != _core.STOPPED_STAGE; + virtual Menu* createContextMenu() override { + DADSRH* dadsrh = dynamic_cast<DADSRH*>(module); + assert(dadsrh); + Menu* menu = ModuleWidget::createContextMenu(); + menu->addChild(new MenuLabel()); + menu->addChild(new TriggerOnLoadMenuItem(dadsrh, "Resume Loop on Load")); + return menu; } }; - -struct DADSRHWidget : ModuleWidget { - DADSRHWidget(DADSRH* module); - virtual Menu* createContextMenu() override; -}; - -DADSRHWidget::DADSRHWidget(DADSRH* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/DADSRH.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(0, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - - // generated by svg_widgets.rb - auto delayParamPosition = Vec(27.08, 33.08); - auto attackParamPosition = Vec(27.08, 89.08); - auto decayParamPosition = Vec(27.08, 145.08); - auto sustainParamPosition = Vec(27.08, 201.08); - auto releaseParamPosition = Vec(27.08, 257.08); - auto holdParamPosition = Vec(82.38, 313.08); - auto attackShapeParamPosition = Vec(77.02, 124.02); - auto decayShapeParamPosition = Vec(77.02, 180.52); - auto releaseShapeParamPosition = Vec(77.02, 292.52); - auto triggerParamPosition = Vec(90.04, 43.04); - auto modeParamPosition = Vec(120.0, 95.0); - auto loopParamPosition = Vec(120.0, 145.0); - auto speedParamPosition = Vec(20.0, 321.0); - auto retriggerParamPosition = Vec(55.0, 321.0); - - auto triggerInputPosition = Vec(115.0, 40.0); - - auto envOutputPosition = Vec(115.0, 191.0); - auto invOutputPosition = Vec(115.0, 228.0); - auto triggerOutputPosition = Vec(115.0, 265.0); - - auto delayLightPosition = Vec(12.0, 76.0); - auto attackLightPosition = Vec(12.0, 123.0); - auto decayLightPosition = Vec(12.0, 179.0); - auto sustainLightPosition = Vec(12.0, 235.0); - auto releaseLightPosition = Vec(12.0, 291.0); - auto attackShape1LightPosition = Vec(77.0, 96.0); - auto attackShape2LightPosition = Vec(77.0, 106.0); - auto attackShape3LightPosition = Vec(77.0, 116.0); - auto decayShape1LightPosition = Vec(77.0, 152.5); - auto decayShape2LightPosition = Vec(77.0, 162.5); - auto decayShape3LightPosition = Vec(77.0, 172.5); - auto releaseShape1LightPosition = Vec(77.0, 264.5); - auto releaseShape2LightPosition = Vec(77.0, 274.5); - auto releaseShape3LightPosition = Vec(77.0, 284.5); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Knob38>(delayParamPosition, module, DADSRH::DELAY_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<Knob38>(attackParamPosition, module, DADSRH::ATTACK_PARAM, 0.0, 1.0, 0.12)); - addParam(ParamWidget::create<Knob38>(decayParamPosition, module, DADSRH::DECAY_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(sustainParamPosition, module, DADSRH::SUSTAIN_PARAM, 0.0, 1.0, 0.5)); - addParam(ParamWidget::create<Knob38>(releaseParamPosition, module, DADSRH::RELEASE_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(holdParamPosition, module, DADSRH::HOLD_PARAM, 0.0, 1.0, 0.45)); - addParam(ParamWidget::create<StatefulButton9>(attackShapeParamPosition, module, DADSRH::ATTACK_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<StatefulButton9>(decayShapeParamPosition, module, DADSRH::DECAY_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<StatefulButton9>(releaseShapeParamPosition, module, DADSRH::RELEASE_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DADSRH::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(modeParamPosition, module, DADSRH::MODE_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DADSRH::LOOP_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, DADSRH::SPEED_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(retriggerParamPosition, module, DADSRH::RETRIGGER_PARAM, 0.0, 1.0, 1.0)); - - addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DADSRH::TRIGGER_INPUT)); - - addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, DADSRH::ENV_OUTPUT)); - addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, DADSRH::INV_OUTPUT)); - addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, DADSRH::TRIGGER_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DADSRH::DELAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, DADSRH::ATTACK_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, DADSRH::DECAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(sustainLightPosition, module, DADSRH::SUSTAIN_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseLightPosition, module, DADSRH::RELEASE_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape1LightPosition, module, DADSRH::ATTACK_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape2LightPosition, module, DADSRH::ATTACK_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape3LightPosition, module, DADSRH::ATTACK_SHAPE3_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape1LightPosition, module, DADSRH::DECAY_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape2LightPosition, module, DADSRH::DECAY_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape3LightPosition, module, DADSRH::DECAY_SHAPE3_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape1LightPosition, module, DADSRH::RELEASE_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape2LightPosition, module, DADSRH::RELEASE_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape3LightPosition, module, DADSRH::RELEASE_SHAPE3_LIGHT)); -} - -Menu* DADSRHWidget::createContextMenu() { - DADSRH* dadsrh = dynamic_cast<DADSRH*>(module); - assert(dadsrh); - Menu* menu = ModuleWidget::createContextMenu(); - menu->addChild(new MenuLabel()); - menu->addChild(new TriggerOnLoadMenuItem(dadsrh, "Resume Loop on Load")); - return menu; -} - - Model* modelDADSRH = Model::create<DADSRH, DADSRHWidget>("Bogaudio", "Bogaudio-DADSRH", "DADSR(H)", ENVELOPE_GENERATOR_TAG); diff --git a/src/DADSRH.hpp b/src/DADSRH.hpp @@ -0,0 +1,134 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dadsrh_core.hpp" + +extern Model* modelDADSRH; + +namespace bogaudio { + +struct DADSRH : TriggerOnLoadModule { + enum ParamsIds { + DELAY_PARAM, + ATTACK_PARAM, + DECAY_PARAM, + SUSTAIN_PARAM, + RELEASE_PARAM, + HOLD_PARAM, + ATTACK_SHAPE_PARAM, + DECAY_SHAPE_PARAM, + RELEASE_SHAPE_PARAM, + TRIGGER_PARAM, + MODE_PARAM, + LOOP_PARAM, + SPEED_PARAM, + RETRIGGER_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + TRIGGER_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + ENV_OUTPUT, + INV_OUTPUT, + TRIGGER_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + DELAY_LIGHT, + ATTACK_LIGHT, + DECAY_LIGHT, + SUSTAIN_LIGHT, + RELEASE_LIGHT, + ATTACK_SHAPE1_LIGHT, + ATTACK_SHAPE2_LIGHT, + ATTACK_SHAPE3_LIGHT, + DECAY_SHAPE1_LIGHT, + DECAY_SHAPE2_LIGHT, + DECAY_SHAPE3_LIGHT, + RELEASE_SHAPE1_LIGHT, + RELEASE_SHAPE2_LIGHT, + RELEASE_SHAPE3_LIGHT, + NUM_LIGHTS + }; + + DADSRHCore _core; + + DADSRH() : TriggerOnLoadModule( + NUM_PARAMS, + NUM_INPUTS, + NUM_OUTPUTS, + NUM_LIGHTS + ) + , _core( + params[DELAY_PARAM], + params[ATTACK_PARAM], + params[DECAY_PARAM], + params[SUSTAIN_PARAM], + params[RELEASE_PARAM], + params[HOLD_PARAM], + params[ATTACK_SHAPE_PARAM], + params[DECAY_SHAPE_PARAM], + params[RELEASE_SHAPE_PARAM], + params[TRIGGER_PARAM], + params[MODE_PARAM], + params[LOOP_PARAM], + params[SPEED_PARAM], + params[RETRIGGER_PARAM], + + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + inputs[TRIGGER_INPUT], + + NULL, + NULL, + NULL, + NULL, + NULL, + outputs[ENV_OUTPUT], + outputs[INV_OUTPUT], + outputs[TRIGGER_OUTPUT], + + lights[DELAY_LIGHT], + lights[ATTACK_LIGHT], + lights[DECAY_LIGHT], + lights[SUSTAIN_LIGHT], + lights[RELEASE_LIGHT], + lights[ATTACK_SHAPE1_LIGHT], + lights[ATTACK_SHAPE2_LIGHT], + lights[ATTACK_SHAPE3_LIGHT], + lights[DECAY_SHAPE1_LIGHT], + lights[DECAY_SHAPE2_LIGHT], + lights[DECAY_SHAPE3_LIGHT], + lights[RELEASE_SHAPE1_LIGHT], + lights[RELEASE_SHAPE2_LIGHT], + lights[RELEASE_SHAPE3_LIGHT], + + _triggerOnLoad, + _shouldTriggerOnLoad + ) { + onReset(); + } + + virtual void onReset() override { + _core.reset(); + } + + virtual void step() override { + _core.step(); + } + + virtual bool shouldTriggerOnNextLoad() override { + return _core._stage != _core.STOPPED_STAGE; + } +}; + +} // namespace bogaudio diff --git a/src/DADSRHPlus.cpp b/src/DADSRHPlus.cpp @@ -1,267 +1,127 @@ -#include "dadsrh_core.hpp" +#include "DADSRHPlus.hpp" -struct DADSRHPlus : TriggerOnLoadModule { - enum ParamsIds { - DELAY_PARAM, - ATTACK_PARAM, - DECAY_PARAM, - SUSTAIN_PARAM, - RELEASE_PARAM, - HOLD_PARAM, - ATTACK_SHAPE_PARAM, - DECAY_SHAPE_PARAM, - RELEASE_SHAPE_PARAM, - TRIGGER_PARAM, - MODE_PARAM, - LOOP_PARAM, - SPEED_PARAM, - RETRIGGER_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - DELAY_INPUT, - ATTACK_INPUT, - DECAY_INPUT, - SUSTAIN_INPUT, - RELEASE_INPUT, - HOLD_INPUT, - TRIGGER_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - DELAY_OUTPUT, - ATTACK_OUTPUT, - DECAY_OUTPUT, - SUSTAIN_OUTPUT, - RELEASE_OUTPUT, - ENV_OUTPUT, - INV_OUTPUT, - TRIGGER_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - DELAY_LIGHT, - ATTACK_LIGHT, - DECAY_LIGHT, - SUSTAIN_LIGHT, - RELEASE_LIGHT, - ATTACK_SHAPE1_LIGHT, - ATTACK_SHAPE2_LIGHT, - ATTACK_SHAPE3_LIGHT, - DECAY_SHAPE1_LIGHT, - DECAY_SHAPE2_LIGHT, - DECAY_SHAPE3_LIGHT, - RELEASE_SHAPE1_LIGHT, - RELEASE_SHAPE2_LIGHT, - RELEASE_SHAPE3_LIGHT, - NUM_LIGHTS - }; - - DADSRHCore _core; - - DADSRHPlus() : TriggerOnLoadModule( - NUM_PARAMS, - NUM_INPUTS, - NUM_OUTPUTS, - NUM_LIGHTS - ) - , _core( - params[DELAY_PARAM], - params[ATTACK_PARAM], - params[DECAY_PARAM], - params[SUSTAIN_PARAM], - params[RELEASE_PARAM], - params[HOLD_PARAM], - params[ATTACK_SHAPE_PARAM], - params[DECAY_SHAPE_PARAM], - params[RELEASE_SHAPE_PARAM], - params[TRIGGER_PARAM], - params[MODE_PARAM], - params[LOOP_PARAM], - params[SPEED_PARAM], - params[RETRIGGER_PARAM], - - &inputs[DELAY_INPUT], - &inputs[ATTACK_INPUT], - &inputs[DECAY_INPUT], - &inputs[SUSTAIN_INPUT], - &inputs[RELEASE_INPUT], - &inputs[HOLD_INPUT], - inputs[TRIGGER_INPUT], - - &outputs[DELAY_OUTPUT], - &outputs[ATTACK_OUTPUT], - &outputs[DECAY_OUTPUT], - &outputs[SUSTAIN_OUTPUT], - &outputs[RELEASE_OUTPUT], - outputs[ENV_OUTPUT], - outputs[INV_OUTPUT], - outputs[TRIGGER_OUTPUT], - - lights[DELAY_LIGHT], - lights[ATTACK_LIGHT], - lights[DECAY_LIGHT], - lights[SUSTAIN_LIGHT], - lights[RELEASE_LIGHT], - lights[ATTACK_SHAPE1_LIGHT], - lights[ATTACK_SHAPE2_LIGHT], - lights[ATTACK_SHAPE3_LIGHT], - lights[DECAY_SHAPE1_LIGHT], - lights[DECAY_SHAPE2_LIGHT], - lights[DECAY_SHAPE3_LIGHT], - lights[RELEASE_SHAPE1_LIGHT], - lights[RELEASE_SHAPE2_LIGHT], - lights[RELEASE_SHAPE3_LIGHT], - - _triggerOnLoad, - _shouldTriggerOnLoad - ) { - onReset(); - } - - virtual void onReset() override { - _core.reset(); - } - - virtual void step() override { - _core.step(); +struct DADSRHPlusWidget : ModuleWidget { + DADSRHPlusWidget(DADSRHPlus* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/DADSRHPlus.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + + // generated by svg_widgets.rb + auto delayParamPosition = Vec(27.08, 33.08); + auto attackParamPosition = Vec(27.08, 89.08); + auto decayParamPosition = Vec(27.08, 145.08); + auto sustainParamPosition = Vec(27.08, 201.08); + auto releaseParamPosition = Vec(27.08, 257.08); + auto holdParamPosition = Vec(82.38, 313.08); + auto attackShapeParamPosition = Vec(77.02, 124.02); + auto decayShapeParamPosition = Vec(77.02, 180.52); + auto releaseShapeParamPosition = Vec(77.02, 292.52); + auto triggerParamPosition = Vec(90.04, 43.04); + auto modeParamPosition = Vec(120.0, 95.0); + auto loopParamPosition = Vec(120.0, 145.0); + auto speedParamPosition = Vec(20.0, 321.0); + auto retriggerParamPosition = Vec(55.0, 321.0); + + auto delayInputPosition = Vec(152.0, 40.0); + auto attackInputPosition = Vec(152.0, 96.0); + auto decayInputPosition = Vec(152.0, 152.0); + auto sustainInputPosition = Vec(152.0, 208.0); + auto releaseInputPosition = Vec(152.0, 264.0); + auto holdInputPosition = Vec(152.0, 320.0); + auto triggerInputPosition = Vec(115.0, 40.0); + + auto delayOutputPosition = Vec(189.0, 40.0); + auto attackOutputPosition = Vec(189.0, 96.0); + auto decayOutputPosition = Vec(189.0, 152.0); + auto sustainOutputPosition = Vec(189.0, 208.0); + auto releaseOutputPosition = Vec(189.0, 264.0); + auto envOutputPosition = Vec(115.0, 191.0); + auto invOutputPosition = Vec(115.0, 228.0); + auto triggerOutputPosition = Vec(115.0, 265.0); + + auto delayLightPosition = Vec(12.0, 76.0); + auto attackLightPosition = Vec(12.0, 123.0); + auto decayLightPosition = Vec(12.0, 179.0); + auto sustainLightPosition = Vec(12.0, 235.0); + auto releaseLightPosition = Vec(12.0, 291.0); + auto attackShape1LightPosition = Vec(77.0, 96.0); + auto attackShape2LightPosition = Vec(77.0, 106.0); + auto attackShape3LightPosition = Vec(77.0, 116.0); + auto decayShape1LightPosition = Vec(77.0, 152.5); + auto decayShape2LightPosition = Vec(77.0, 162.5); + auto decayShape3LightPosition = Vec(77.0, 172.5); + auto releaseShape1LightPosition = Vec(77.0, 264.5); + auto releaseShape2LightPosition = Vec(77.0, 274.5); + auto releaseShape3LightPosition = Vec(77.0, 284.5); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Knob38>(delayParamPosition, module, DADSRHPlus::DELAY_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<Knob38>(attackParamPosition, module, DADSRHPlus::ATTACK_PARAM, 0.0, 1.0, 0.12)); + addParam(ParamWidget::create<Knob38>(decayParamPosition, module, DADSRHPlus::DECAY_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(sustainParamPosition, module, DADSRHPlus::SUSTAIN_PARAM, 0.0, 1.0, 0.5)); + addParam(ParamWidget::create<Knob38>(releaseParamPosition, module, DADSRHPlus::RELEASE_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(holdParamPosition, module, DADSRHPlus::HOLD_PARAM, 0.0, 1.0, 0.45)); + addParam(ParamWidget::create<StatefulButton9>(attackShapeParamPosition, module, DADSRHPlus::ATTACK_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<StatefulButton9>(decayShapeParamPosition, module, DADSRHPlus::DECAY_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<StatefulButton9>(releaseShapeParamPosition, module, DADSRHPlus::RELEASE_SHAPE_PARAM, 1.0, 3.0, 1.0)); + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DADSRHPlus::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(modeParamPosition, module, DADSRHPlus::MODE_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DADSRHPlus::LOOP_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, DADSRHPlus::SPEED_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(retriggerParamPosition, module, DADSRHPlus::RETRIGGER_PARAM, 0.0, 1.0, 1.0)); + + addInput(Port::create<Port24>(delayInputPosition, Port::INPUT, module, DADSRHPlus::DELAY_INPUT)); + addInput(Port::create<Port24>(attackInputPosition, Port::INPUT, module, DADSRHPlus::ATTACK_INPUT)); + addInput(Port::create<Port24>(decayInputPosition, Port::INPUT, module, DADSRHPlus::DECAY_INPUT)); + addInput(Port::create<Port24>(sustainInputPosition, Port::INPUT, module, DADSRHPlus::SUSTAIN_INPUT)); + addInput(Port::create<Port24>(releaseInputPosition, Port::INPUT, module, DADSRHPlus::RELEASE_INPUT)); + addInput(Port::create<Port24>(holdInputPosition, Port::INPUT, module, DADSRHPlus::HOLD_INPUT)); + addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DADSRHPlus::TRIGGER_INPUT)); + + addOutput(Port::create<Port24>(delayOutputPosition, Port::OUTPUT, module, DADSRHPlus::DELAY_OUTPUT)); + addOutput(Port::create<Port24>(attackOutputPosition, Port::OUTPUT, module, DADSRHPlus::ATTACK_OUTPUT)); + addOutput(Port::create<Port24>(decayOutputPosition, Port::OUTPUT, module, DADSRHPlus::DECAY_OUTPUT)); + addOutput(Port::create<Port24>(sustainOutputPosition, Port::OUTPUT, module, DADSRHPlus::SUSTAIN_OUTPUT)); + addOutput(Port::create<Port24>(releaseOutputPosition, Port::OUTPUT, module, DADSRHPlus::RELEASE_OUTPUT)); + addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, DADSRHPlus::ENV_OUTPUT)); + addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, DADSRHPlus::INV_OUTPUT)); + addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, DADSRHPlus::TRIGGER_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DADSRHPlus::DELAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, DADSRHPlus::ATTACK_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, DADSRHPlus::DECAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(sustainLightPosition, module, DADSRHPlus::SUSTAIN_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseLightPosition, module, DADSRHPlus::RELEASE_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape1LightPosition, module, DADSRHPlus::ATTACK_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape2LightPosition, module, DADSRHPlus::ATTACK_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape3LightPosition, module, DADSRHPlus::ATTACK_SHAPE3_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape1LightPosition, module, DADSRHPlus::DECAY_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape2LightPosition, module, DADSRHPlus::DECAY_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape3LightPosition, module, DADSRHPlus::DECAY_SHAPE3_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape1LightPosition, module, DADSRHPlus::RELEASE_SHAPE1_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape2LightPosition, module, DADSRHPlus::RELEASE_SHAPE2_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape3LightPosition, module, DADSRHPlus::RELEASE_SHAPE3_LIGHT)); } - virtual bool shouldTriggerOnNextLoad() override { - return _core._stage != _core.STOPPED_STAGE; + virtual Menu* createContextMenu() override { + DADSRHPlus* dadsrhPlus = dynamic_cast<DADSRHPlus*>(module); + assert(dadsrhPlus); + Menu* menu = ModuleWidget::createContextMenu(); + menu->addChild(new MenuLabel()); + menu->addChild(new TriggerOnLoadMenuItem(dadsrhPlus, "Resume Loop on Load")); + return menu; } }; - -struct DADSRHPlusWidget : ModuleWidget { - DADSRHPlusWidget(DADSRHPlus* module); - virtual Menu* createContextMenu() override; -}; - -DADSRHPlusWidget::DADSRHPlusWidget(DADSRHPlus* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/DADSRHPlus.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); - - // generated by svg_widgets.rb - auto delayParamPosition = Vec(27.08, 33.08); - auto attackParamPosition = Vec(27.08, 89.08); - auto decayParamPosition = Vec(27.08, 145.08); - auto sustainParamPosition = Vec(27.08, 201.08); - auto releaseParamPosition = Vec(27.08, 257.08); - auto holdParamPosition = Vec(82.38, 313.08); - auto attackShapeParamPosition = Vec(77.02, 124.02); - auto decayShapeParamPosition = Vec(77.02, 180.52); - auto releaseShapeParamPosition = Vec(77.02, 292.52); - auto triggerParamPosition = Vec(90.04, 43.04); - auto modeParamPosition = Vec(120.0, 95.0); - auto loopParamPosition = Vec(120.0, 145.0); - auto speedParamPosition = Vec(20.0, 321.0); - auto retriggerParamPosition = Vec(55.0, 321.0); - - auto delayInputPosition = Vec(152.0, 40.0); - auto attackInputPosition = Vec(152.0, 96.0); - auto decayInputPosition = Vec(152.0, 152.0); - auto sustainInputPosition = Vec(152.0, 208.0); - auto releaseInputPosition = Vec(152.0, 264.0); - auto holdInputPosition = Vec(152.0, 320.0); - auto triggerInputPosition = Vec(115.0, 40.0); - - auto delayOutputPosition = Vec(189.0, 40.0); - auto attackOutputPosition = Vec(189.0, 96.0); - auto decayOutputPosition = Vec(189.0, 152.0); - auto sustainOutputPosition = Vec(189.0, 208.0); - auto releaseOutputPosition = Vec(189.0, 264.0); - auto envOutputPosition = Vec(115.0, 191.0); - auto invOutputPosition = Vec(115.0, 228.0); - auto triggerOutputPosition = Vec(115.0, 265.0); - - auto delayLightPosition = Vec(12.0, 76.0); - auto attackLightPosition = Vec(12.0, 123.0); - auto decayLightPosition = Vec(12.0, 179.0); - auto sustainLightPosition = Vec(12.0, 235.0); - auto releaseLightPosition = Vec(12.0, 291.0); - auto attackShape1LightPosition = Vec(77.0, 96.0); - auto attackShape2LightPosition = Vec(77.0, 106.0); - auto attackShape3LightPosition = Vec(77.0, 116.0); - auto decayShape1LightPosition = Vec(77.0, 152.5); - auto decayShape2LightPosition = Vec(77.0, 162.5); - auto decayShape3LightPosition = Vec(77.0, 172.5); - auto releaseShape1LightPosition = Vec(77.0, 264.5); - auto releaseShape2LightPosition = Vec(77.0, 274.5); - auto releaseShape3LightPosition = Vec(77.0, 284.5); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Knob38>(delayParamPosition, module, DADSRHPlus::DELAY_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<Knob38>(attackParamPosition, module, DADSRHPlus::ATTACK_PARAM, 0.0, 1.0, 0.12)); - addParam(ParamWidget::create<Knob38>(decayParamPosition, module, DADSRHPlus::DECAY_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(sustainParamPosition, module, DADSRHPlus::SUSTAIN_PARAM, 0.0, 1.0, 0.5)); - addParam(ParamWidget::create<Knob38>(releaseParamPosition, module, DADSRHPlus::RELEASE_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(holdParamPosition, module, DADSRHPlus::HOLD_PARAM, 0.0, 1.0, 0.45)); - addParam(ParamWidget::create<StatefulButton9>(attackShapeParamPosition, module, DADSRHPlus::ATTACK_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<StatefulButton9>(decayShapeParamPosition, module, DADSRHPlus::DECAY_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<StatefulButton9>(releaseShapeParamPosition, module, DADSRHPlus::RELEASE_SHAPE_PARAM, 1.0, 3.0, 1.0)); - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DADSRHPlus::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(modeParamPosition, module, DADSRHPlus::MODE_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DADSRHPlus::LOOP_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, DADSRHPlus::SPEED_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(retriggerParamPosition, module, DADSRHPlus::RETRIGGER_PARAM, 0.0, 1.0, 1.0)); - - addInput(Port::create<Port24>(delayInputPosition, Port::INPUT, module, DADSRHPlus::DELAY_INPUT)); - addInput(Port::create<Port24>(attackInputPosition, Port::INPUT, module, DADSRHPlus::ATTACK_INPUT)); - addInput(Port::create<Port24>(decayInputPosition, Port::INPUT, module, DADSRHPlus::DECAY_INPUT)); - addInput(Port::create<Port24>(sustainInputPosition, Port::INPUT, module, DADSRHPlus::SUSTAIN_INPUT)); - addInput(Port::create<Port24>(releaseInputPosition, Port::INPUT, module, DADSRHPlus::RELEASE_INPUT)); - addInput(Port::create<Port24>(holdInputPosition, Port::INPUT, module, DADSRHPlus::HOLD_INPUT)); - addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DADSRHPlus::TRIGGER_INPUT)); - - addOutput(Port::create<Port24>(delayOutputPosition, Port::OUTPUT, module, DADSRHPlus::DELAY_OUTPUT)); - addOutput(Port::create<Port24>(attackOutputPosition, Port::OUTPUT, module, DADSRHPlus::ATTACK_OUTPUT)); - addOutput(Port::create<Port24>(decayOutputPosition, Port::OUTPUT, module, DADSRHPlus::DECAY_OUTPUT)); - addOutput(Port::create<Port24>(sustainOutputPosition, Port::OUTPUT, module, DADSRHPlus::SUSTAIN_OUTPUT)); - addOutput(Port::create<Port24>(releaseOutputPosition, Port::OUTPUT, module, DADSRHPlus::RELEASE_OUTPUT)); - addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, DADSRHPlus::ENV_OUTPUT)); - addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, DADSRHPlus::INV_OUTPUT)); - addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, DADSRHPlus::TRIGGER_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DADSRHPlus::DELAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, DADSRHPlus::ATTACK_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, DADSRHPlus::DECAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(sustainLightPosition, module, DADSRHPlus::SUSTAIN_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseLightPosition, module, DADSRHPlus::RELEASE_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape1LightPosition, module, DADSRHPlus::ATTACK_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape2LightPosition, module, DADSRHPlus::ATTACK_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackShape3LightPosition, module, DADSRHPlus::ATTACK_SHAPE3_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape1LightPosition, module, DADSRHPlus::DECAY_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape2LightPosition, module, DADSRHPlus::DECAY_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayShape3LightPosition, module, DADSRHPlus::DECAY_SHAPE3_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape1LightPosition, module, DADSRHPlus::RELEASE_SHAPE1_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape2LightPosition, module, DADSRHPlus::RELEASE_SHAPE2_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(releaseShape3LightPosition, module, DADSRHPlus::RELEASE_SHAPE3_LIGHT)); -} - -Menu* DADSRHPlusWidget::createContextMenu() { - DADSRHPlus* dadsrhPlus = dynamic_cast<DADSRHPlus*>(module); - assert(dadsrhPlus); - Menu* menu = ModuleWidget::createContextMenu(); - menu->addChild(new MenuLabel()); - menu->addChild(new TriggerOnLoadMenuItem(dadsrhPlus, "Resume Loop on Load")); - return menu; -} - - Model* modelDADSRHPlus = Model::create<DADSRHPlus, DADSRHPlusWidget>("Bogaudio", "Bogaudio-DADSRHPlus", "DADSR(H)+", ENVELOPE_GENERATOR_TAG); diff --git a/src/DADSRHPlus.hpp b/src/DADSRHPlus.hpp @@ -0,0 +1,145 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dadsrh_core.hpp" + +extern Model* modelDADSRHPlus; + +namespace bogaudio { + +struct DADSRHPlus : TriggerOnLoadModule { + enum ParamsIds { + DELAY_PARAM, + ATTACK_PARAM, + DECAY_PARAM, + SUSTAIN_PARAM, + RELEASE_PARAM, + HOLD_PARAM, + ATTACK_SHAPE_PARAM, + DECAY_SHAPE_PARAM, + RELEASE_SHAPE_PARAM, + TRIGGER_PARAM, + MODE_PARAM, + LOOP_PARAM, + SPEED_PARAM, + RETRIGGER_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + DELAY_INPUT, + ATTACK_INPUT, + DECAY_INPUT, + SUSTAIN_INPUT, + RELEASE_INPUT, + HOLD_INPUT, + TRIGGER_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + DELAY_OUTPUT, + ATTACK_OUTPUT, + DECAY_OUTPUT, + SUSTAIN_OUTPUT, + RELEASE_OUTPUT, + ENV_OUTPUT, + INV_OUTPUT, + TRIGGER_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + DELAY_LIGHT, + ATTACK_LIGHT, + DECAY_LIGHT, + SUSTAIN_LIGHT, + RELEASE_LIGHT, + ATTACK_SHAPE1_LIGHT, + ATTACK_SHAPE2_LIGHT, + ATTACK_SHAPE3_LIGHT, + DECAY_SHAPE1_LIGHT, + DECAY_SHAPE2_LIGHT, + DECAY_SHAPE3_LIGHT, + RELEASE_SHAPE1_LIGHT, + RELEASE_SHAPE2_LIGHT, + RELEASE_SHAPE3_LIGHT, + NUM_LIGHTS + }; + + DADSRHCore _core; + + DADSRHPlus() : TriggerOnLoadModule( + NUM_PARAMS, + NUM_INPUTS, + NUM_OUTPUTS, + NUM_LIGHTS + ) + , _core( + params[DELAY_PARAM], + params[ATTACK_PARAM], + params[DECAY_PARAM], + params[SUSTAIN_PARAM], + params[RELEASE_PARAM], + params[HOLD_PARAM], + params[ATTACK_SHAPE_PARAM], + params[DECAY_SHAPE_PARAM], + params[RELEASE_SHAPE_PARAM], + params[TRIGGER_PARAM], + params[MODE_PARAM], + params[LOOP_PARAM], + params[SPEED_PARAM], + params[RETRIGGER_PARAM], + + &inputs[DELAY_INPUT], + &inputs[ATTACK_INPUT], + &inputs[DECAY_INPUT], + &inputs[SUSTAIN_INPUT], + &inputs[RELEASE_INPUT], + &inputs[HOLD_INPUT], + inputs[TRIGGER_INPUT], + + &outputs[DELAY_OUTPUT], + &outputs[ATTACK_OUTPUT], + &outputs[DECAY_OUTPUT], + &outputs[SUSTAIN_OUTPUT], + &outputs[RELEASE_OUTPUT], + outputs[ENV_OUTPUT], + outputs[INV_OUTPUT], + outputs[TRIGGER_OUTPUT], + + lights[DELAY_LIGHT], + lights[ATTACK_LIGHT], + lights[DECAY_LIGHT], + lights[SUSTAIN_LIGHT], + lights[RELEASE_LIGHT], + lights[ATTACK_SHAPE1_LIGHT], + lights[ATTACK_SHAPE2_LIGHT], + lights[ATTACK_SHAPE3_LIGHT], + lights[DECAY_SHAPE1_LIGHT], + lights[DECAY_SHAPE2_LIGHT], + lights[DECAY_SHAPE3_LIGHT], + lights[RELEASE_SHAPE1_LIGHT], + lights[RELEASE_SHAPE2_LIGHT], + lights[RELEASE_SHAPE3_LIGHT], + + _triggerOnLoad, + _shouldTriggerOnLoad + ) { + onReset(); + } + + virtual void onReset() override { + _core.reset(); + } + + virtual void step() override { + _core.step(); + } + + virtual bool shouldTriggerOnNextLoad() override { + return _core._stage != _core.STOPPED_STAGE; + } +}; + +} // namespace bogaudio diff --git a/src/DGate.cpp b/src/DGate.cpp @@ -1,55 +1,5 @@ -#include "bogaudio.hpp" - -struct DGate : TriggerOnLoadModule { - enum ParamsIds { - DELAY_PARAM, - GATE_PARAM, - LOOP_PARAM, - TRIGGER_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - TRIGGER_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - GATE_OUTPUT, - END_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - DELAY_LIGHT, - GATE_LIGHT, - NUM_LIGHTS - }; - - enum Stage { - STOPPED_STAGE, - DELAY_STAGE, - GATE_STAGE - }; - - bool _firstStep = true; - SchmittTrigger _trigger; - PulseGenerator _triggerOuptutPulseGen; - Stage _stage; - float _stageProgress; - - DGate() : TriggerOnLoadModule(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; - bool stepStage(Param& knob); - virtual bool shouldTriggerOnNextLoad() override { - return _stage != STOPPED_STAGE; - }; -}; +#include "DGate.hpp" void DGate::onReset() { _trigger.reset(); @@ -120,62 +70,57 @@ bool DGate::stepStage(Param& knob) { return _stageProgress > 1.0; } - struct DGateWidget : ModuleWidget { - DGateWidget(DGate* module); - virtual Menu* createContextMenu() override; -}; - -DGateWidget::DGateWidget(DGate* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/DGate.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + DGateWidget(DGate* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/DGate.svg"))); + addChild(panel); + } - // generated by svg_widgets.rb - auto delayParamPosition = Vec(7.5, 32.5); - auto gateParamPosition = Vec(7.5, 91.5); - auto loopParamPosition = Vec(15.0, 144.5); - auto triggerParamPosition = Vec(13.5, 190.0); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - auto triggerInputPosition = Vec(10.5, 213.0); + // generated by svg_widgets.rb + auto delayParamPosition = Vec(7.5, 32.5); + auto gateParamPosition = Vec(7.5, 91.5); + auto loopParamPosition = Vec(15.0, 144.5); + auto triggerParamPosition = Vec(13.5, 190.0); - auto gateOutputPosition = Vec(10.5, 252.0); - auto endOutputPosition = Vec(10.5, 287.0); + auto triggerInputPosition = Vec(10.5, 213.0); - auto delayLightPosition = Vec(20.8, 65.0); - auto gateLightPosition = Vec(20.8, 124.0); - // end generated by svg_widgets.rb + auto gateOutputPosition = Vec(10.5, 252.0); + auto endOutputPosition = Vec(10.5, 287.0); - addParam(ParamWidget::create<Knob29>(delayParamPosition, module, DGate::DELAY_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<Knob29>(gateParamPosition, module, DGate::GATE_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DGate::LOOP_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DGate::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + auto delayLightPosition = Vec(20.8, 65.0); + auto gateLightPosition = Vec(20.8, 124.0); + // end generated by svg_widgets.rb - addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DGate::TRIGGER_INPUT)); + addParam(ParamWidget::create<Knob29>(delayParamPosition, module, DGate::DELAY_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<Knob29>(gateParamPosition, module, DGate::GATE_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, DGate::LOOP_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, DGate::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - addOutput(Port::create<Port24>(gateOutputPosition, Port::OUTPUT, module, DGate::GATE_OUTPUT)); - addOutput(Port::create<Port24>(endOutputPosition, Port::OUTPUT, module, DGate::END_OUTPUT)); + addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, DGate::TRIGGER_INPUT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DGate::DELAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(gateLightPosition, module, DGate::GATE_LIGHT)); -} + addOutput(Port::create<Port24>(gateOutputPosition, Port::OUTPUT, module, DGate::GATE_OUTPUT)); + addOutput(Port::create<Port24>(endOutputPosition, Port::OUTPUT, module, DGate::END_OUTPUT)); -Menu* DGateWidget::createContextMenu() { - DGate* dgate = dynamic_cast<DGate*>(module); - assert(dgate); - Menu* menu = ModuleWidget::createContextMenu(); - menu->addChild(new MenuLabel()); - menu->addChild(new TriggerOnLoadMenuItem(dgate, "Resume Loop on Load")); - return menu; -} + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(delayLightPosition, module, DGate::DELAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(gateLightPosition, module, DGate::GATE_LIGHT)); + } + virtual Menu* createContextMenu() override { + DGate* dgate = dynamic_cast<DGate*>(module); + assert(dgate); + Menu* menu = ModuleWidget::createContextMenu(); + menu->addChild(new MenuLabel()); + menu->addChild(new TriggerOnLoadMenuItem(dgate, "Resume Loop on Load")); + return menu; + } +}; Model* modelDGate = Model::create<DGate, DGateWidget>("Bogaudio", "Bogaudio-DGate", "DGate", UTILITY_TAG); diff --git a/src/DGate.hpp b/src/DGate.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelDGate; + +namespace bogaudio { + +struct DGate : TriggerOnLoadModule { + enum ParamsIds { + DELAY_PARAM, + GATE_PARAM, + LOOP_PARAM, + TRIGGER_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + TRIGGER_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + GATE_OUTPUT, + END_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + DELAY_LIGHT, + GATE_LIGHT, + NUM_LIGHTS + }; + + enum Stage { + STOPPED_STAGE, + DELAY_STAGE, + GATE_STAGE + }; + + bool _firstStep = true; + SchmittTrigger _trigger; + PulseGenerator _triggerOuptutPulseGen; + Stage _stage; + float _stageProgress; + + DGate() : TriggerOnLoadModule(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + onReset(); + } + + virtual void onReset() override; + virtual void step() override; + bool stepStage(Param& knob); + virtual bool shouldTriggerOnNextLoad() override { + return _stage != STOPPED_STAGE; + }; +}; + +} // namespace bogaudio diff --git a/src/Detune.cpp b/src/Detune.cpp @@ -1,37 +1,5 @@ -#include "bogaudio.hpp" -#include "dsp/pitch.hpp" - -using namespace bogaudio::dsp; - -struct Detune : Module { - enum ParamsIds { - CENTS_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - CV_INPUT, - IN_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - THRU_OUTPUT, - OUT_PLUS_OUTPUT, - OUT_MINUS_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - Detune() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - } - - virtual void step() override; -}; +#include "Detune.hpp" void Detune::step() { if (!(outputs[OUT_PLUS_OUTPUT].active || outputs[OUT_MINUS_OUTPUT].active || outputs[THRU_OUTPUT].active)) { @@ -71,48 +39,44 @@ void Detune::step() { } } - struct DetuneWidget : ModuleWidget { - DetuneWidget(Detune* module); -}; + DetuneWidget(Detune* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Detune.svg"))); + addChild(panel); + } -DetuneWidget::DetuneWidget(Detune* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Detune.svg"))); - addChild(panel); - } + // generated by svg_widgets.rb + auto centsParamPosition = Vec(9.5, 32.5); - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + auto cvInputPosition = Vec(10.5, 77.0); + auto inInputPosition = Vec(10.5, 126.0); - // generated by svg_widgets.rb - auto centsParamPosition = Vec(9.5, 32.5); + auto thruOutputPosition = Vec(10.5, 164.0); + auto outPlusOutputPosition = Vec(10.5, 200.0); + auto outMinusOutputPosition = Vec(10.5, 236.0); + // end generated by svg_widgets.rb - auto cvInputPosition = Vec(10.5, 77.0); - auto inInputPosition = Vec(10.5, 126.0); + { + auto w = ParamWidget::create<Knob26>(centsParamPosition, module, Detune::CENTS_PARAM, 0.0, 50.0, 0.0); + dynamic_cast<Knob*>(w)->snap = true; + addParam(w); + } - auto thruOutputPosition = Vec(10.5, 164.0); - auto outPlusOutputPosition = Vec(10.5, 200.0); - auto outMinusOutputPosition = Vec(10.5, 236.0); - // end generated by svg_widgets.rb + addInput(Port::create<Port24>(cvInputPosition, Port::INPUT, module, Detune::CV_INPUT)); + addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Detune::IN_INPUT)); - { - auto w = ParamWidget::create<Knob26>(centsParamPosition, module, Detune::CENTS_PARAM, 0.0, 50.0, 0.0); - dynamic_cast<Knob*>(w)->snap = true; - addParam(w); + addOutput(Port::create<Port24>(thruOutputPosition, Port::OUTPUT, module, Detune::THRU_OUTPUT)); + addOutput(Port::create<Port24>(outPlusOutputPosition, Port::OUTPUT, module, Detune::OUT_PLUS_OUTPUT)); + addOutput(Port::create<Port24>(outMinusOutputPosition, Port::OUTPUT, module, Detune::OUT_MINUS_OUTPUT)); } - - addInput(Port::create<Port24>(cvInputPosition, Port::INPUT, module, Detune::CV_INPUT)); - addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Detune::IN_INPUT)); - - addOutput(Port::create<Port24>(thruOutputPosition, Port::OUTPUT, module, Detune::THRU_OUTPUT)); - addOutput(Port::create<Port24>(outPlusOutputPosition, Port::OUTPUT, module, Detune::OUT_PLUS_OUTPUT)); - addOutput(Port::create<Port24>(outMinusOutputPosition, Port::OUTPUT, module, Detune::OUT_MINUS_OUTPUT)); -} - +}; Model* modelDetune = Model::create<Detune, DetuneWidget>("Bogaudio", "Bogaudio-Detune", "Detune"); diff --git a/src/Detune.hpp b/src/Detune.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/pitch.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelDetune; + +namespace bogaudio { + +struct Detune : Module { + enum ParamsIds { + CENTS_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + CV_INPUT, + IN_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + THRU_OUTPUT, + OUT_PLUS_OUTPUT, + OUT_MINUS_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + Detune() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + } + + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/EightHP.cpp b/src/EightHP.cpp @@ -1,55 +0,0 @@ - -#include "bogaudio.hpp" - -struct EightHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - EightHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void EightHP::onReset() { -} - -void EightHP::step() { -} - - -struct EightHPWidget : ModuleWidget { - EightHPWidget(EightHP* module); -}; - -EightHPWidget::EightHPWidget(EightHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 8, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/EightHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelEightHP = Model::create<EightHP, EightHPWidget>("Bogaudio", "Bogaudio-EightHP", "8HP"); diff --git a/src/EighteenHP.cpp b/src/EighteenHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct EighteenHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - EighteenHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void EighteenHP::onReset() { -} - -void EighteenHP::step() { -} - - -struct EighteenHPWidget : ModuleWidget { - EighteenHPWidget(EighteenHP* module); -}; - -EighteenHPWidget::EighteenHPWidget(EighteenHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 18, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/EighteenHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelEighteenHP = Model::create<EighteenHP, EighteenHPWidget>("Bogaudio", "Bogaudio-EighteenHP", "18HP"); diff --git a/src/FifteenHP.cpp b/src/FifteenHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct FifteenHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - FifteenHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void FifteenHP::onReset() { -} - -void FifteenHP::step() { -} - - -struct FifteenHPWidget : ModuleWidget { - FifteenHPWidget(FifteenHP* module); -}; - -FifteenHPWidget::FifteenHPWidget(FifteenHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/FifteenHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelFifteenHP = Model::create<FifteenHP, FifteenHPWidget>("Bogaudio", "Bogaudio-FifteenHP", "15HP"); diff --git a/src/Manual.cpp b/src/Manual.cpp @@ -1,42 +1,5 @@ -#include "bogaudio.hpp" - -struct Manual : Module { - enum ParamsIds { - TRIGGER_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - OUT1_OUTPUT, - OUT2_OUTPUT, - OUT3_OUTPUT, - OUT4_OUTPUT, - OUT5_OUTPUT, - OUT6_OUTPUT, - OUT7_OUTPUT, - OUT8_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - SchmittTrigger _trigger; - PulseGenerator _pulse; - - Manual() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; +#include "Manual.hpp" void Manual::onReset() { _trigger.reset(); @@ -64,48 +27,44 @@ void Manual::step() { outputs[OUT8_OUTPUT].value = out; } - struct ManualWidget : ModuleWidget { - ManualWidget(Manual* module); -}; - -ManualWidget::ManualWidget(Manual* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Manual.svg"))); - addChild(panel); + ManualWidget(Manual* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Manual.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto triggerParamPosition = Vec(13.5, 22.0); + + auto out1OutputPosition = Vec(10.5, 57.0); + auto out2OutputPosition = Vec(10.5, 87.0); + auto out3OutputPosition = Vec(10.5, 117.0); + auto out4OutputPosition = Vec(10.5, 147.0); + auto out5OutputPosition = Vec(10.5, 177.0); + auto out6OutputPosition = Vec(10.5, 207.0); + auto out7OutputPosition = Vec(10.5, 237.0); + auto out8OutputPosition = Vec(10.5, 267.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, Manual::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + + addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, Manual::OUT1_OUTPUT)); + addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, Manual::OUT2_OUTPUT)); + addOutput(Port::create<Port24>(out3OutputPosition, Port::OUTPUT, module, Manual::OUT3_OUTPUT)); + addOutput(Port::create<Port24>(out4OutputPosition, Port::OUTPUT, module, Manual::OUT4_OUTPUT)); + addOutput(Port::create<Port24>(out5OutputPosition, Port::OUTPUT, module, Manual::OUT5_OUTPUT)); + addOutput(Port::create<Port24>(out6OutputPosition, Port::OUTPUT, module, Manual::OUT6_OUTPUT)); + addOutput(Port::create<Port24>(out7OutputPosition, Port::OUTPUT, module, Manual::OUT7_OUTPUT)); + addOutput(Port::create<Port24>(out8OutputPosition, Port::OUTPUT, module, Manual::OUT8_OUTPUT)); } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - - // generated by svg_widgets.rb - auto triggerParamPosition = Vec(13.5, 22.0); - - auto out1OutputPosition = Vec(10.5, 57.0); - auto out2OutputPosition = Vec(10.5, 87.0); - auto out3OutputPosition = Vec(10.5, 117.0); - auto out4OutputPosition = Vec(10.5, 147.0); - auto out5OutputPosition = Vec(10.5, 177.0); - auto out6OutputPosition = Vec(10.5, 207.0); - auto out7OutputPosition = Vec(10.5, 237.0); - auto out8OutputPosition = Vec(10.5, 267.0); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, Manual::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - - addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, Manual::OUT1_OUTPUT)); - addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, Manual::OUT2_OUTPUT)); - addOutput(Port::create<Port24>(out3OutputPosition, Port::OUTPUT, module, Manual::OUT3_OUTPUT)); - addOutput(Port::create<Port24>(out4OutputPosition, Port::OUTPUT, module, Manual::OUT4_OUTPUT)); - addOutput(Port::create<Port24>(out5OutputPosition, Port::OUTPUT, module, Manual::OUT5_OUTPUT)); - addOutput(Port::create<Port24>(out6OutputPosition, Port::OUTPUT, module, Manual::OUT6_OUTPUT)); - addOutput(Port::create<Port24>(out7OutputPosition, Port::OUTPUT, module, Manual::OUT7_OUTPUT)); - addOutput(Port::create<Port24>(out8OutputPosition, Port::OUTPUT, module, Manual::OUT8_OUTPUT)); -} - +}; Model* modelManual = Model::create<Manual, ManualWidget>("Bogaudio", "Bogaudio-Manual", "Manual", UTILITY_TAG); diff --git a/src/Manual.hpp b/src/Manual.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelManual; + +namespace bogaudio { + +struct Manual : Module { + enum ParamsIds { + TRIGGER_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + NUM_INPUTS + }; + + enum OutputsIds { + OUT1_OUTPUT, + OUT2_OUTPUT, + OUT3_OUTPUT, + OUT4_OUTPUT, + OUT5_OUTPUT, + OUT6_OUTPUT, + OUT7_OUTPUT, + OUT8_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + SchmittTrigger _trigger; + PulseGenerator _pulse; + + Manual() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + onReset(); + } + + virtual void onReset() override; + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/Noise.cpp b/src/Noise.cpp @@ -1,41 +1,5 @@ -#include "bogaudio.hpp" -#include "dsp/noise.hpp" - -using namespace bogaudio::dsp; - -struct Noise : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - ABS_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - WHITE_OUTPUT, - PINK_OUTPUT, - RED_OUTPUT, - GAUSS_OUTPUT, - ABS_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - WhiteNoiseGenerator _white; - PinkNoiseGenerator _pink; - RedNoiseGenerator _red; - GaussianNoiseGenerator _gauss; - - Noise() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} - - virtual void step() override; -}; +#include "Noise.hpp" void Noise::step() { if (outputs[WHITE_OUTPUT].active) { @@ -61,42 +25,38 @@ void Noise::step() { outputs[ABS_OUTPUT].value = in; } - struct NoiseWidget : ModuleWidget { - NoiseWidget(Noise* module); -}; - -NoiseWidget::NoiseWidget(Noise* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Noise.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + NoiseWidget(Noise* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Noise.svg"))); + addChild(panel); + } - // generated by svg_widgets.rb - auto absInputPosition = Vec(10.5, 245.0); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - auto whiteOutputPosition = Vec(10.5, 24.0); - auto pinkOutputPosition = Vec(10.5, 65.0); - auto redOutputPosition = Vec(10.5, 106.0); - auto gaussOutputPosition = Vec(10.5, 147.0); - auto absOutputPosition = Vec(10.5, 283.0); - // end generated by svg_widgets.rb + // generated by svg_widgets.rb + auto absInputPosition = Vec(10.5, 245.0); - addInput(Port::create<Port24>(absInputPosition, Port::INPUT, module, Noise::ABS_INPUT)); + auto whiteOutputPosition = Vec(10.5, 24.0); + auto pinkOutputPosition = Vec(10.5, 65.0); + auto redOutputPosition = Vec(10.5, 106.0); + auto gaussOutputPosition = Vec(10.5, 147.0); + auto absOutputPosition = Vec(10.5, 283.0); + // end generated by svg_widgets.rb - addOutput(Port::create<Port24>(whiteOutputPosition, Port::OUTPUT, module, Noise::WHITE_OUTPUT)); - addOutput(Port::create<Port24>(pinkOutputPosition, Port::OUTPUT, module, Noise::PINK_OUTPUT)); - addOutput(Port::create<Port24>(redOutputPosition, Port::OUTPUT, module, Noise::RED_OUTPUT)); - addOutput(Port::create<Port24>(gaussOutputPosition, Port::OUTPUT, module, Noise::GAUSS_OUTPUT)); - addOutput(Port::create<Port24>(absOutputPosition, Port::OUTPUT, module, Noise::ABS_OUTPUT)); -} + addInput(Port::create<Port24>(absInputPosition, Port::INPUT, module, Noise::ABS_INPUT)); + addOutput(Port::create<Port24>(whiteOutputPosition, Port::OUTPUT, module, Noise::WHITE_OUTPUT)); + addOutput(Port::create<Port24>(pinkOutputPosition, Port::OUTPUT, module, Noise::PINK_OUTPUT)); + addOutput(Port::create<Port24>(redOutputPosition, Port::OUTPUT, module, Noise::RED_OUTPUT)); + addOutput(Port::create<Port24>(gaussOutputPosition, Port::OUTPUT, module, Noise::GAUSS_OUTPUT)); + addOutput(Port::create<Port24>(absOutputPosition, Port::OUTPUT, module, Noise::ABS_OUTPUT)); + } +}; Model* modelNoise = Model::create<Noise, NoiseWidget>("Bogaudio", "Bogaudio-Noise", "Noise", NOISE_TAG, UTILITY_TAG); diff --git a/src/Noise.hpp b/src/Noise.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/noise.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelNoise; + +namespace bogaudio { + +struct Noise : Module { + enum ParamsIds { + NUM_PARAMS + }; + + enum InputsIds { + ABS_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + WHITE_OUTPUT, + PINK_OUTPUT, + RED_OUTPUT, + GAUSS_OUTPUT, + ABS_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + WhiteNoiseGenerator _white; + PinkNoiseGenerator _pink; + RedNoiseGenerator _red; + GaussianNoiseGenerator _gauss; + + Noise() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} + + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/Offset.cpp b/src/Offset.cpp @@ -1,31 +1,5 @@ -#include "bogaudio.hpp" - -struct Offset : Module { - enum ParamIds { - OFFSET_PARAM, - SCALE_PARAM, - NUM_PARAMS - }; - - enum InputIds { - OFFSET_INPUT, - SCALE_INPUT, - IN_INPUT, - NUM_INPUTS - }; - - enum OutputIds { - OUT_OUTPUT, - NUM_OUTPUTS - }; - - Offset() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} - - virtual void step() override; - - float knobValue(const Param& knob, const Input& cv) const; -}; +#include "Offset.hpp" void Offset::step() { float offset = knobValue(params[OFFSET_PARAM], inputs[OFFSET_INPUT]); @@ -48,45 +22,41 @@ float Offset::knobValue(const Param& knob, const Input& cv) const { return v; } - struct OffsetWidget : ModuleWidget { - OffsetWidget(Offset* module); -}; - -OffsetWidget::OffsetWidget(Offset* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + OffsetWidget(Offset* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Offset.svg"))); - addChild(panel); - } + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Offset.svg"))); + addChild(panel); + } - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - float knobNudge = 0.4; - // generated by svg_widgets.rb - auto offsetParamPosition = Vec(7.5 + knobNudge, 39.5 + knobNudge); - auto scaleParamPosition = Vec(7.5 + knobNudge, 151.5 + knobNudge); + float knobNudge = 0.4; + // generated by svg_widgets.rb + auto offsetParamPosition = Vec(7.5 + knobNudge, 39.5 + knobNudge); + auto scaleParamPosition = Vec(7.5 + knobNudge, 151.5 + knobNudge); - auto offsetInputPosition = Vec(10.5, 81.0); - auto scaleInputPosition = Vec(10.5, 193.0); - auto inInputPosition = Vec(10.5, 243.0); + auto offsetInputPosition = Vec(10.5, 81.0); + auto scaleInputPosition = Vec(10.5, 193.0); + auto inInputPosition = Vec(10.5, 243.0); - auto outOutputPosition = Vec(10.5, 281.0); - // end generated by svg_widgets.rb + auto outOutputPosition = Vec(10.5, 281.0); + // end generated by svg_widgets.rb - addParam(ParamWidget::create<Knob29>(offsetParamPosition, module, Offset::OFFSET_PARAM, -1.0, 1.0, 0.0)); - addParam(ParamWidget::create<Knob29>(scaleParamPosition, module, Offset::SCALE_PARAM, -1.0, 1.0, 0.316)); + addParam(ParamWidget::create<Knob29>(offsetParamPosition, module, Offset::OFFSET_PARAM, -1.0, 1.0, 0.0)); + addParam(ParamWidget::create<Knob29>(scaleParamPosition, module, Offset::SCALE_PARAM, -1.0, 1.0, 0.316)); - addInput(Port::create<Port24>(offsetInputPosition, Port::INPUT, module, Offset::OFFSET_INPUT)); - addInput(Port::create<Port24>(scaleInputPosition, Port::INPUT, module, Offset::SCALE_INPUT)); - addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Offset::IN_INPUT)); - - addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Offset::OUT_OUTPUT)); -} + addInput(Port::create<Port24>(offsetInputPosition, Port::INPUT, module, Offset::OFFSET_INPUT)); + addInput(Port::create<Port24>(scaleInputPosition, Port::INPUT, module, Offset::SCALE_INPUT)); + addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Offset::IN_INPUT)); + addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Offset::OUT_OUTPUT)); + } +}; Model* modelOffset = Model::create<Offset, OffsetWidget>("Bogaudio", "Bogaudio-Offset", "Offset", ATTENUATOR_TAG, UTILITY_TAG); diff --git a/src/Offset.hpp b/src/Offset.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelOffset; + +namespace bogaudio { + +struct Offset : Module { + enum ParamIds { + OFFSET_PARAM, + SCALE_PARAM, + NUM_PARAMS + }; + + enum InputIds { + OFFSET_INPUT, + SCALE_INPUT, + IN_INPUT, + NUM_INPUTS + }; + + enum OutputIds { + OUT_OUTPUT, + NUM_OUTPUTS + }; + + Offset() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} + + virtual void step() override; + + float knobValue(const Param& knob, const Input& cv) const; +}; + +} // namespace bogaudio diff --git a/src/Reftone.cpp b/src/Reftone.cpp @@ -1,50 +1,5 @@ -#include "bogaudio.hpp" -#include "dsp/oscillator.hpp" -#include "dsp/pitch.hpp" - -using namespace bogaudio::dsp; - -struct Reftone : Module { - enum ParamsIds { - PITCH_PARAM, - OCTAVE_PARAM, - FINE_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - CV_OUTPUT, - OUT_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - int _pitch = 9; - int _octave = 4; - float _fine = 0.0; - float _frequency = 440.0; - SineOscillator _sine; - - Reftone() - : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) - , _sine(engineGetSampleRate(), _frequency, 5.0) - { - } - - virtual void onSampleRateChange() override { - _sine.setSampleRate(engineGetSampleRate()); - } - - virtual void step() override; -}; +#include "Reftone.hpp" void Reftone::step() { // C4 -- the pitch.hpp reference frequency -- in knob values: @@ -219,55 +174,52 @@ float ReftoneDisplay::textRenderWidth(NVGcontext* vg, const char* s, int size) { struct ReftoneWidget : ModuleWidget { - ReftoneWidget(Reftone* module); -}; - -ReftoneWidget::ReftoneWidget(Reftone* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + ReftoneWidget(Reftone* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Reftone.svg"))); + addChild(panel); + } - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Reftone.svg"))); - addChild(panel); - } + { + auto inset = Vec(3.5, 18); + auto size = Vec(38, 48); + auto display = new ReftoneDisplay(module, size); + display->box.pos = inset; + display->box.size = size; + addChild(display); + } - { - auto inset = Vec(3.5, 18); - auto size = Vec(38, 48); - auto display = new ReftoneDisplay(module, size); - display->box.pos = inset; - display->box.size = size; - addChild(display); - } + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + // generated by svg_widgets.rb + auto pitchParamPosition = Vec(9.5, 89.5); + auto octaveParamPosition = Vec(9.5, 143.5); + auto fineParamPosition = Vec(9.5, 197.5); - // generated by svg_widgets.rb - auto pitchParamPosition = Vec(9.5, 89.5); - auto octaveParamPosition = Vec(9.5, 143.5); - auto fineParamPosition = Vec(9.5, 197.5); + auto cvOutputPosition = Vec(10.5, 239.0); + auto outOutputPosition = Vec(10.5, 274.0); + // end generated by svg_widgets.rb - auto cvOutputPosition = Vec(10.5, 239.0); - auto outOutputPosition = Vec(10.5, 274.0); - // end generated by svg_widgets.rb + { + auto w = ParamWidget::create<Knob26>(pitchParamPosition, module, Reftone::PITCH_PARAM, 0.0, 11.0, 9.0); + dynamic_cast<Knob*>(w)->snap = true; + addParam(w); + } + { + auto w = ParamWidget::create<Knob26>(octaveParamPosition, module, Reftone::OCTAVE_PARAM, 1.0, 8.0, 4.0); + dynamic_cast<Knob*>(w)->snap = true; + addParam(w); + } + addParam(ParamWidget::create<Knob26>(fineParamPosition, module, Reftone::FINE_PARAM, -0.99, 0.99, 0.0)); - { - auto w = ParamWidget::create<Knob26>(pitchParamPosition, module, Reftone::PITCH_PARAM, 0.0, 11.0, 9.0); - dynamic_cast<Knob*>(w)->snap = true; - addParam(w); - } - { - auto w = ParamWidget::create<Knob26>(octaveParamPosition, module, Reftone::OCTAVE_PARAM, 1.0, 8.0, 4.0); - dynamic_cast<Knob*>(w)->snap = true; - addParam(w); + addOutput(Port::create<Port24>(cvOutputPosition, Port::OUTPUT, module, Reftone::CV_OUTPUT)); + addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Reftone::OUT_OUTPUT)); } - addParam(ParamWidget::create<Knob26>(fineParamPosition, module, Reftone::FINE_PARAM, -0.99, 0.99, 0.0)); - - addOutput(Port::create<Port24>(cvOutputPosition, Port::OUTPUT, module, Reftone::CV_OUTPUT)); - addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Reftone::OUT_OUTPUT)); -} - +}; Model* modelReftone = Model::create<Reftone, ReftoneWidget>("Bogaudio", "Bogaudio-Reftone", "Reftone", TUNER_TAG, UTILITY_TAG); diff --git a/src/Reftone.hpp b/src/Reftone.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/oscillator.hpp" +#include "dsp/pitch.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelReftone; + +namespace bogaudio { + +struct Reftone : Module { + enum ParamsIds { + PITCH_PARAM, + OCTAVE_PARAM, + FINE_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + NUM_INPUTS + }; + + enum OutputsIds { + CV_OUTPUT, + OUT_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + int _pitch = 9; + int _octave = 4; + float _fine = 0.0; + float _frequency = 440.0; + SineOscillator _sine; + + Reftone() + : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) + , _sine(engineGetSampleRate(), _frequency, 5.0) + { + } + + virtual void onSampleRateChange() override { + _sine.setSampleRate(engineGetSampleRate()); + } + + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/SampleHold.cpp b/src/SampleHold.cpp @@ -1,49 +1,5 @@ -#include "bogaudio.hpp" -#include "dsp/noise.hpp" - -using namespace bogaudio::dsp; - -struct SampleHold : Module { - enum ParamIds { - TRIGGER1_PARAM, - TRIGGER2_PARAM, - NUM_PARAMS - }; - - enum InputIds { - TRIGGER1_INPUT, - IN1_INPUT, - TRIGGER2_INPUT, - IN2_INPUT, - NUM_INPUTS - }; - - enum OutputIds { - OUT1_OUTPUT, - OUT2_OUTPUT, - NUM_OUTPUTS - }; - - SchmittTrigger _trigger1, _trigger2; - float _value1, _value2; - WhiteNoiseGenerator _noise; - - SampleHold() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; - void step( - Param& triggerParam, - Input& triggerInput, - Input& in, - Output& out, - SchmittTrigger& trigger, - float& value - ); -}; +#include "SampleHold.hpp" void SampleHold::onReset() { _trigger1.reset(); @@ -91,48 +47,44 @@ void SampleHold::step( out.value = value; } - struct SampleHoldWidget : ModuleWidget { - SampleHoldWidget(SampleHold* module); -}; - -SampleHoldWidget::SampleHoldWidget(SampleHold* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/SampleHold.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + SampleHoldWidget(SampleHold* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/SampleHold.svg"))); + addChild(panel); + } - // generated by svg_widgets.rb - auto trigger1ParamPosition = Vec(13.5, 33.0); - auto trigger2ParamPosition = Vec(13.5, 193.0); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - auto trigger1InputPosition = Vec(10.5, 56.0); - auto in1InputPosition = Vec(10.5, 93.0); - auto trigger2InputPosition = Vec(10.5, 216.0); - auto in2InputPosition = Vec(10.5, 253.0); + // generated by svg_widgets.rb + auto trigger1ParamPosition = Vec(13.5, 33.0); + auto trigger2ParamPosition = Vec(13.5, 193.0); - auto out1OutputPosition = Vec(10.5, 131.0); - auto out2OutputPosition = Vec(10.5, 291.0); - // end generated by svg_widgets.rb + auto trigger1InputPosition = Vec(10.5, 56.0); + auto in1InputPosition = Vec(10.5, 93.0); + auto trigger2InputPosition = Vec(10.5, 216.0); + auto in2InputPosition = Vec(10.5, 253.0); - addParam(ParamWidget::create<Button18>(trigger1ParamPosition, module, SampleHold::TRIGGER1_PARAM, 0.0, 1.0, 0.0)); - addParam(ParamWidget::create<Button18>(trigger2ParamPosition, module, SampleHold::TRIGGER2_PARAM, 0.0, 1.0, 0.0)); + auto out1OutputPosition = Vec(10.5, 131.0); + auto out2OutputPosition = Vec(10.5, 291.0); + // end generated by svg_widgets.rb - addInput(Port::create<Port24>(trigger1InputPosition, Port::INPUT, module, SampleHold::TRIGGER1_INPUT)); - addInput(Port::create<Port24>(in1InputPosition, Port::INPUT, module, SampleHold::IN1_INPUT)); - addInput(Port::create<Port24>(trigger2InputPosition, Port::INPUT, module, SampleHold::TRIGGER2_INPUT)); - addInput(Port::create<Port24>(in2InputPosition, Port::INPUT, module, SampleHold::IN2_INPUT)); + addParam(ParamWidget::create<Button18>(trigger1ParamPosition, module, SampleHold::TRIGGER1_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<Button18>(trigger2ParamPosition, module, SampleHold::TRIGGER2_PARAM, 0.0, 1.0, 0.0)); - addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, SampleHold::OUT1_OUTPUT)); - addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, SampleHold::OUT2_OUTPUT)); -} + addInput(Port::create<Port24>(trigger1InputPosition, Port::INPUT, module, SampleHold::TRIGGER1_INPUT)); + addInput(Port::create<Port24>(in1InputPosition, Port::INPUT, module, SampleHold::IN1_INPUT)); + addInput(Port::create<Port24>(trigger2InputPosition, Port::INPUT, module, SampleHold::TRIGGER2_INPUT)); + addInput(Port::create<Port24>(in2InputPosition, Port::INPUT, module, SampleHold::IN2_INPUT)); + addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, SampleHold::OUT1_OUTPUT)); + addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, SampleHold::OUT2_OUTPUT)); + } +}; Model* modelSampleHold = Model::create<SampleHold, SampleHoldWidget>("Bogaudio", "Bogaudio-SampleHold", "S&H", SAMPLE_AND_HOLD_TAG, DUAL_TAG, UTILITY_TAG); diff --git a/src/SampleHold.hpp b/src/SampleHold.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/noise.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelSampleHold; + +namespace bogaudio { + +struct SampleHold : Module { + enum ParamIds { + TRIGGER1_PARAM, + TRIGGER2_PARAM, + NUM_PARAMS + }; + + enum InputIds { + TRIGGER1_INPUT, + IN1_INPUT, + TRIGGER2_INPUT, + IN2_INPUT, + NUM_INPUTS + }; + + enum OutputIds { + OUT1_OUTPUT, + OUT2_OUTPUT, + NUM_OUTPUTS + }; + + SchmittTrigger _trigger1, _trigger2; + float _value1, _value2; + WhiteNoiseGenerator _noise; + + SampleHold() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) { + onReset(); + } + + virtual void onReset() override; + virtual void step() override; + void step( + Param& triggerParam, + Input& triggerInput, + Input& in, + Output& out, + SchmittTrigger& trigger, + float& value + ); +}; + +} // namespace bogaudio diff --git a/src/Shaper.cpp b/src/Shaper.cpp @@ -1,184 +1,81 @@ -#include "shaper_core.hpp" - -struct Shaper : TriggerOnLoadModule { - enum ParamIds { - ATTACK_PARAM, - ON_PARAM, - DECAY_PARAM, - OFF_PARAM, - ENV_PARAM, - SIGNAL_PARAM, - TRIGGER_PARAM, - SPEED_PARAM, - LOOP_PARAM, - NUM_PARAMS - }; - - enum InputIds { - SIGNAL_INPUT, - TRIGGER_INPUT, - NUM_INPUTS - }; - - enum OutputIds { - SIGNAL_OUTPUT, - ENV_OUTPUT, - INV_OUTPUT, - TRIGGER_OUTPUT, - NUM_OUTPUTS - }; - - enum LightIds { - ATTACK_LIGHT, - ON_LIGHT, - DECAY_LIGHT, - OFF_LIGHT, - NUM_LIGHTS - }; - - ShaperCore _core; - - Shaper() : TriggerOnLoadModule( - NUM_PARAMS, - NUM_INPUTS, - NUM_OUTPUTS, - NUM_LIGHTS - ) - , _core( - params[ATTACK_PARAM], - params[ON_PARAM], - params[DECAY_PARAM], - params[OFF_PARAM], - params[ENV_PARAM], - params[SIGNAL_PARAM], - params[TRIGGER_PARAM], - params[SPEED_PARAM], - params[LOOP_PARAM], - - inputs[SIGNAL_INPUT], - inputs[TRIGGER_INPUT], - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - - outputs[SIGNAL_OUTPUT], - outputs[ENV_OUTPUT], - outputs[INV_OUTPUT], - outputs[TRIGGER_OUTPUT], - NULL, - NULL, - NULL, - NULL, - - lights[ATTACK_LIGHT], - lights[ON_LIGHT], - lights[DECAY_LIGHT], - lights[OFF_LIGHT], - - _triggerOnLoad, - _shouldTriggerOnLoad - ) - { - onReset(); - } - - virtual void onReset() override { - _core.reset(); - } +#include "Shaper.hpp" - virtual void step() override { - _core.step(); +struct ShaperWidget : ModuleWidget { + ShaperWidget(Shaper* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Shaper.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto attackParamPosition = Vec(29.08, 33.08); + auto triggerParamPosition = Vec(89.04, 43.04); + auto onParamPosition = Vec(29.08, 89.08); + auto speedParamPosition = Vec(119.0, 96.0); + auto decayParamPosition = Vec(29.08, 145.08); + auto loopParamPosition = Vec(119.0, 152.0); + auto offParamPosition = Vec(29.08, 201.08); + auto envParamPosition = Vec(82.38, 257.08); + auto signalParamPosition = Vec(82.38, 313.08); + + auto triggerInputPosition = Vec(114.0, 40.0); + auto signalInputPosition = Vec(11.5, 320.0); + + auto triggerOutputPosition = Vec(114.0, 208.0); + auto envOutputPosition = Vec(11.5, 264.0); + auto invOutputPosition = Vec(40.5, 264.0); + auto signalOutputPosition = Vec(40.5, 320.0); + + auto attackLightPosition = Vec(12.0, 80.0); + auto onLightPosition = Vec(12.0, 121.0); + auto decayLightPosition = Vec(12.0, 189.0); + auto offLightPosition = Vec(12.0, 237.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Knob38>(attackParamPosition, module, Shaper::ATTACK_PARAM, 0.0, 1.0, 0.12)); + addParam(ParamWidget::create<Knob38>(onParamPosition, module, Shaper::ON_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(decayParamPosition, module, Shaper::DECAY_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(offParamPosition, module, Shaper::OFF_PARAM, 0.0, 1.0, 0.07)); + addParam(ParamWidget::create<Knob38>(envParamPosition, module, Shaper::ENV_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<Knob38>(signalParamPosition, module, Shaper::SIGNAL_PARAM, 0.0, 1.0, 0.5)); + + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, Shaper::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, Shaper::TRIGGER_INPUT)); + + addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, Shaper::SPEED_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, Shaper::LOOP_PARAM, 0.0, 1.0, 1.0)); + addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, Shaper::TRIGGER_OUTPUT)); + + addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, Shaper::ENV_OUTPUT)); + addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, Shaper::INV_OUTPUT)); + + addInput(Port::create<Port24>(signalInputPosition, Port::INPUT, module, Shaper::SIGNAL_INPUT)); + addOutput(Port::create<Port24>(signalOutputPosition, Port::OUTPUT, module, Shaper::SIGNAL_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, Shaper::ATTACK_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(onLightPosition, module, Shaper::ON_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, Shaper::DECAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(offLightPosition, module, Shaper::OFF_LIGHT)); } - virtual bool shouldTriggerOnNextLoad() override { - return _core._stage != _core.STOPPED_STAGE; + virtual Menu* createContextMenu() override { + Shaper* shaper = dynamic_cast<Shaper*>(module); + assert(shaper); + Menu* menu = ModuleWidget::createContextMenu(); + menu->addChild(new MenuLabel()); + menu->addChild(new TriggerOnLoadMenuItem(shaper, "Resume Loop on Load")); + return menu; } }; - -struct ShaperWidget : ModuleWidget { - ShaperWidget(Shaper* module); - virtual Menu* createContextMenu() override; -}; - -ShaperWidget::ShaperWidget(Shaper* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Shaper.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(0, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - - // generated by svg_widgets.rb - auto attackParamPosition = Vec(29.08, 33.08); - auto triggerParamPosition = Vec(89.04, 43.04); - auto onParamPosition = Vec(29.08, 89.08); - auto speedParamPosition = Vec(119.0, 96.0); - auto decayParamPosition = Vec(29.08, 145.08); - auto loopParamPosition = Vec(119.0, 152.0); - auto offParamPosition = Vec(29.08, 201.08); - auto envParamPosition = Vec(82.38, 257.08); - auto signalParamPosition = Vec(82.38, 313.08); - - auto triggerInputPosition = Vec(114.0, 40.0); - auto signalInputPosition = Vec(11.5, 320.0); - - auto triggerOutputPosition = Vec(114.0, 208.0); - auto envOutputPosition = Vec(11.5, 264.0); - auto invOutputPosition = Vec(40.5, 264.0); - auto signalOutputPosition = Vec(40.5, 320.0); - - auto attackLightPosition = Vec(12.0, 80.0); - auto onLightPosition = Vec(12.0, 121.0); - auto decayLightPosition = Vec(12.0, 189.0); - auto offLightPosition = Vec(12.0, 237.0); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Knob38>(attackParamPosition, module, Shaper::ATTACK_PARAM, 0.0, 1.0, 0.12)); - addParam(ParamWidget::create<Knob38>(onParamPosition, module, Shaper::ON_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(decayParamPosition, module, Shaper::DECAY_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(offParamPosition, module, Shaper::OFF_PARAM, 0.0, 1.0, 0.07)); - addParam(ParamWidget::create<Knob38>(envParamPosition, module, Shaper::ENV_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<Knob38>(signalParamPosition, module, Shaper::SIGNAL_PARAM, 0.0, 1.0, 0.5)); - - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, Shaper::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, Shaper::TRIGGER_INPUT)); - - addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, Shaper::SPEED_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, Shaper::LOOP_PARAM, 0.0, 1.0, 1.0)); - addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, Shaper::TRIGGER_OUTPUT)); - - addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, Shaper::ENV_OUTPUT)); - addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, Shaper::INV_OUTPUT)); - - addInput(Port::create<Port24>(signalInputPosition, Port::INPUT, module, Shaper::SIGNAL_INPUT)); - addOutput(Port::create<Port24>(signalOutputPosition, Port::OUTPUT, module, Shaper::SIGNAL_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, Shaper::ATTACK_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(onLightPosition, module, Shaper::ON_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, Shaper::DECAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(offLightPosition, module, Shaper::OFF_LIGHT)); -} - -Menu* ShaperWidget::createContextMenu() { - Shaper* shaper = dynamic_cast<Shaper*>(module); - assert(shaper); - Menu* menu = ModuleWidget::createContextMenu(); - menu->addChild(new MenuLabel()); - menu->addChild(new TriggerOnLoadMenuItem(shaper, "Resume Loop on Load")); - return menu; -} - - Model* modelShaper = Model::create<Shaper, ShaperWidget>("Bogaudio", "Bogaudio-Shaper", "Shaper", ENVELOPE_GENERATOR_TAG, AMPLIFIER_TAG); diff --git a/src/Shaper.hpp b/src/Shaper.hpp @@ -0,0 +1,108 @@ +#pragma once + +#include "bogaudio.hpp" +#include "shaper_core.hpp" + +extern Model* modelShaper; + +namespace bogaudio { + +struct Shaper : TriggerOnLoadModule { + enum ParamIds { + ATTACK_PARAM, + ON_PARAM, + DECAY_PARAM, + OFF_PARAM, + ENV_PARAM, + SIGNAL_PARAM, + TRIGGER_PARAM, + SPEED_PARAM, + LOOP_PARAM, + NUM_PARAMS + }; + + enum InputIds { + SIGNAL_INPUT, + TRIGGER_INPUT, + NUM_INPUTS + }; + + enum OutputIds { + SIGNAL_OUTPUT, + ENV_OUTPUT, + INV_OUTPUT, + TRIGGER_OUTPUT, + NUM_OUTPUTS + }; + + enum LightIds { + ATTACK_LIGHT, + ON_LIGHT, + DECAY_LIGHT, + OFF_LIGHT, + NUM_LIGHTS + }; + + ShaperCore _core; + + Shaper() : TriggerOnLoadModule( + NUM_PARAMS, + NUM_INPUTS, + NUM_OUTPUTS, + NUM_LIGHTS + ) + , _core( + params[ATTACK_PARAM], + params[ON_PARAM], + params[DECAY_PARAM], + params[OFF_PARAM], + params[ENV_PARAM], + params[SIGNAL_PARAM], + params[TRIGGER_PARAM], + params[SPEED_PARAM], + params[LOOP_PARAM], + + inputs[SIGNAL_INPUT], + inputs[TRIGGER_INPUT], + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + + outputs[SIGNAL_OUTPUT], + outputs[ENV_OUTPUT], + outputs[INV_OUTPUT], + outputs[TRIGGER_OUTPUT], + NULL, + NULL, + NULL, + NULL, + + lights[ATTACK_LIGHT], + lights[ON_LIGHT], + lights[DECAY_LIGHT], + lights[OFF_LIGHT], + + _triggerOnLoad, + _shouldTriggerOnLoad + ) + { + onReset(); + } + + virtual void onReset() override { + _core.reset(); + } + + virtual void step() override { + _core.step(); + } + + virtual bool shouldTriggerOnNextLoad() override { + return _core._stage != _core.STOPPED_STAGE; + } +}; + +} // namespace bogaudio diff --git a/src/ShaperPlus.cpp b/src/ShaperPlus.cpp @@ -1,213 +1,103 @@ -#include "shaper_core.hpp" - -struct ShaperPlus : TriggerOnLoadModule { - enum ParamIds { - ATTACK_PARAM, - ON_PARAM, - DECAY_PARAM, - OFF_PARAM, - ENV_PARAM, - SIGNAL_PARAM, - TRIGGER_PARAM, - SPEED_PARAM, - LOOP_PARAM, - NUM_PARAMS - }; - enum InputIds { - SIGNAL_INPUT, - TRIGGER_INPUT, - ATTACK_INPUT, - ON_INPUT, - DECAY_INPUT, - OFF_INPUT, - ENV_INPUT, - SIGNALCV_INPUT, - NUM_INPUTS - }; - enum OutputIds { - SIGNAL_OUTPUT, - ENV_OUTPUT, - INV_OUTPUT, - TRIGGER_OUTPUT, - ATTACK_OUTPUT, - ON_OUTPUT, - DECAY_OUTPUT, - OFF_OUTPUT, - NUM_OUTPUTS - }; - enum LightIds { - ATTACK_LIGHT, - ON_LIGHT, - DECAY_LIGHT, - OFF_LIGHT, - NUM_LIGHTS - }; - - ShaperCore _core; - - ShaperPlus() : TriggerOnLoadModule( - NUM_PARAMS, - NUM_INPUTS, - NUM_OUTPUTS, - NUM_LIGHTS - ) - , _core( - params[ATTACK_PARAM], - params[ON_PARAM], - params[DECAY_PARAM], - params[OFF_PARAM], - params[ENV_PARAM], - params[SIGNAL_PARAM], - params[TRIGGER_PARAM], - params[SPEED_PARAM], - params[LOOP_PARAM], - - inputs[SIGNAL_INPUT], - inputs[TRIGGER_INPUT], - &inputs[ATTACK_INPUT], - &inputs[ON_INPUT], - &inputs[DECAY_INPUT], - &inputs[OFF_INPUT], - &inputs[ENV_INPUT], - &inputs[SIGNALCV_INPUT], - - outputs[SIGNAL_OUTPUT], - outputs[ENV_OUTPUT], - outputs[INV_OUTPUT], - outputs[TRIGGER_OUTPUT], - &outputs[ATTACK_OUTPUT], - &outputs[ON_OUTPUT], - &outputs[DECAY_OUTPUT], - &outputs[OFF_OUTPUT], - - lights[ATTACK_LIGHT], - lights[ON_LIGHT], - lights[DECAY_LIGHT], - lights[OFF_LIGHT], - - _triggerOnLoad, - _shouldTriggerOnLoad - ) - { - onReset(); - } - - virtual void onReset() override { - _core.reset(); - } +#include "ShaperPlus.hpp" - virtual void step() override { - _core.step(); +struct ShaperPlusWidget : ModuleWidget { + ShaperPlusWidget(ShaperPlus* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/ShaperPlus.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + + // generated by svg_widgets.rb + auto attackParamPosition = Vec(29.08, 33.08); + auto triggerParamPosition = Vec(89.04, 43.04); + auto onParamPosition = Vec(29.08, 89.08); + auto speedParamPosition = Vec(119.0, 96.0); + auto decayParamPosition = Vec(29.08, 145.08); + auto loopParamPosition = Vec(119.0, 152.0); + auto offParamPosition = Vec(29.08, 201.08); + auto envParamPosition = Vec(82.38, 257.08); + auto signalParamPosition = Vec(82.38, 313.08); + + auto triggerInputPosition = Vec(114.0, 40.0); + auto attackInputPosition = Vec(152.0, 40.0); + auto onInputPosition = Vec(152.0, 96.0); + auto decayInputPosition = Vec(152.0, 152.0); + auto offInputPosition = Vec(152.0, 208.0); + auto envInputPosition = Vec(152.0, 264.0); + auto signalInputPosition = Vec(11.5, 320.0); + auto signalcvInputPosition = Vec(152.0, 320.0); + + auto attackOutputPosition = Vec(189.0, 40.0); + auto onOutputPosition = Vec(189.0, 96.0); + auto decayOutputPosition = Vec(189.0, 152.0); + auto offOutputPosition = Vec(189.0, 208.0); + auto envOutputPosition = Vec(11.5, 264.0); + auto invOutputPosition = Vec(40.5, 264.0); + auto triggerOutputPosition = Vec(189.0, 264.0); + auto signalOutputPosition = Vec(40.5, 320.0); + + auto attackLightPosition = Vec(12.0, 80.0); + auto onLightPosition = Vec(12.0, 121.0); + auto decayLightPosition = Vec(12.0, 189.0); + auto offLightPosition = Vec(12.0, 237.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Knob38>(attackParamPosition, module, ShaperPlus::ATTACK_PARAM, 0.0, 1.0, 0.12)); + addParam(ParamWidget::create<Knob38>(onParamPosition, module, ShaperPlus::ON_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(decayParamPosition, module, ShaperPlus::DECAY_PARAM, 0.0, 1.0, 0.32)); + addParam(ParamWidget::create<Knob38>(offParamPosition, module, ShaperPlus::OFF_PARAM, 0.0, 1.0, 0.07)); + addParam(ParamWidget::create<Knob38>(envParamPosition, module, ShaperPlus::ENV_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<Knob38>(signalParamPosition, module, ShaperPlus::SIGNAL_PARAM, 0.0, 1.0, 0.5)); + + addParam(ParamWidget::create<Button18>(triggerParamPosition, module, ShaperPlus::TRIGGER_PARAM, 0.0, 1.0, 0.0)); + addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, ShaperPlus::TRIGGER_INPUT)); + + addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, ShaperPlus::SPEED_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, ShaperPlus::LOOP_PARAM, 0.0, 1.0, 1.0)); + addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, ShaperPlus::TRIGGER_OUTPUT)); + + addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, ShaperPlus::ENV_OUTPUT)); + addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, ShaperPlus::INV_OUTPUT)); + + addInput(Port::create<Port24>(signalInputPosition, Port::INPUT, module, ShaperPlus::SIGNAL_INPUT)); + addOutput(Port::create<Port24>(signalOutputPosition, Port::OUTPUT, module, ShaperPlus::SIGNAL_OUTPUT)); + + addInput(Port::create<Port24>(attackInputPosition, Port::INPUT, module, ShaperPlus::ATTACK_INPUT)); + addInput(Port::create<Port24>(onInputPosition, Port::INPUT, module, ShaperPlus::ON_INPUT)); + addInput(Port::create<Port24>(decayInputPosition, Port::INPUT, module, ShaperPlus::DECAY_INPUT)); + addInput(Port::create<Port24>(offInputPosition, Port::INPUT, module, ShaperPlus::OFF_INPUT)); + addInput(Port::create<Port24>(envInputPosition, Port::INPUT, module, ShaperPlus::ENV_INPUT)); + addInput(Port::create<Port24>(signalcvInputPosition, Port::INPUT, module, ShaperPlus::SIGNALCV_INPUT)); + + addOutput(Port::create<Port24>(attackOutputPosition, Port::OUTPUT, module, ShaperPlus::ATTACK_OUTPUT)); + addOutput(Port::create<Port24>(onOutputPosition, Port::OUTPUT, module, ShaperPlus::ON_OUTPUT)); + addOutput(Port::create<Port24>(decayOutputPosition, Port::OUTPUT, module, ShaperPlus::DECAY_OUTPUT)); + addOutput(Port::create<Port24>(offOutputPosition, Port::OUTPUT, module, ShaperPlus::OFF_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, ShaperPlus::ATTACK_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(onLightPosition, module, ShaperPlus::ON_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, ShaperPlus::DECAY_LIGHT)); + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(offLightPosition, module, ShaperPlus::OFF_LIGHT)); } - virtual bool shouldTriggerOnNextLoad() override { - return _core._stage != _core.STOPPED_STAGE; + virtual Menu* createContextMenu() override { + ShaperPlus* shaperPlus = dynamic_cast<ShaperPlus*>(module); + assert(shaperPlus); + Menu* menu = ModuleWidget::createContextMenu(); + menu->addChild(new MenuLabel()); + menu->addChild(new TriggerOnLoadMenuItem(shaperPlus, "Resume Loop on Load")); + return menu; } }; - -struct ShaperPlusWidget : ModuleWidget { - ShaperPlusWidget(ShaperPlus* module); - virtual Menu* createContextMenu() override; -}; - -ShaperPlusWidget::ShaperPlusWidget(ShaperPlus* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/ShaperPlus.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); - - // generated by svg_widgets.rb - auto attackParamPosition = Vec(29.08, 33.08); - auto triggerParamPosition = Vec(89.04, 43.04); - auto onParamPosition = Vec(29.08, 89.08); - auto speedParamPosition = Vec(119.0, 96.0); - auto decayParamPosition = Vec(29.08, 145.08); - auto loopParamPosition = Vec(119.0, 152.0); - auto offParamPosition = Vec(29.08, 201.08); - auto envParamPosition = Vec(82.38, 257.08); - auto signalParamPosition = Vec(82.38, 313.08); - - auto triggerInputPosition = Vec(114.0, 40.0); - auto attackInputPosition = Vec(152.0, 40.0); - auto onInputPosition = Vec(152.0, 96.0); - auto decayInputPosition = Vec(152.0, 152.0); - auto offInputPosition = Vec(152.0, 208.0); - auto envInputPosition = Vec(152.0, 264.0); - auto signalInputPosition = Vec(11.5, 320.0); - auto signalcvInputPosition = Vec(152.0, 320.0); - - auto attackOutputPosition = Vec(189.0, 40.0); - auto onOutputPosition = Vec(189.0, 96.0); - auto decayOutputPosition = Vec(189.0, 152.0); - auto offOutputPosition = Vec(189.0, 208.0); - auto envOutputPosition = Vec(11.5, 264.0); - auto invOutputPosition = Vec(40.5, 264.0); - auto triggerOutputPosition = Vec(189.0, 264.0); - auto signalOutputPosition = Vec(40.5, 320.0); - - auto attackLightPosition = Vec(12.0, 80.0); - auto onLightPosition = Vec(12.0, 121.0); - auto decayLightPosition = Vec(12.0, 189.0); - auto offLightPosition = Vec(12.0, 237.0); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Knob38>(attackParamPosition, module, ShaperPlus::ATTACK_PARAM, 0.0, 1.0, 0.12)); - addParam(ParamWidget::create<Knob38>(onParamPosition, module, ShaperPlus::ON_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(decayParamPosition, module, ShaperPlus::DECAY_PARAM, 0.0, 1.0, 0.32)); - addParam(ParamWidget::create<Knob38>(offParamPosition, module, ShaperPlus::OFF_PARAM, 0.0, 1.0, 0.07)); - addParam(ParamWidget::create<Knob38>(envParamPosition, module, ShaperPlus::ENV_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<Knob38>(signalParamPosition, module, ShaperPlus::SIGNAL_PARAM, 0.0, 1.0, 0.5)); - - addParam(ParamWidget::create<Button18>(triggerParamPosition, module, ShaperPlus::TRIGGER_PARAM, 0.0, 1.0, 0.0)); - addInput(Port::create<Port24>(triggerInputPosition, Port::INPUT, module, ShaperPlus::TRIGGER_INPUT)); - - addParam(ParamWidget::create<SliderSwitch2State14>(speedParamPosition, module, ShaperPlus::SPEED_PARAM, 0.0, 1.0, 1.0)); - addParam(ParamWidget::create<SliderSwitch2State14>(loopParamPosition, module, ShaperPlus::LOOP_PARAM, 0.0, 1.0, 1.0)); - addOutput(Port::create<Port24>(triggerOutputPosition, Port::OUTPUT, module, ShaperPlus::TRIGGER_OUTPUT)); - - addOutput(Port::create<Port24>(envOutputPosition, Port::OUTPUT, module, ShaperPlus::ENV_OUTPUT)); - addOutput(Port::create<Port24>(invOutputPosition, Port::OUTPUT, module, ShaperPlus::INV_OUTPUT)); - - addInput(Port::create<Port24>(signalInputPosition, Port::INPUT, module, ShaperPlus::SIGNAL_INPUT)); - addOutput(Port::create<Port24>(signalOutputPosition, Port::OUTPUT, module, ShaperPlus::SIGNAL_OUTPUT)); - - addInput(Port::create<Port24>(attackInputPosition, Port::INPUT, module, ShaperPlus::ATTACK_INPUT)); - addInput(Port::create<Port24>(onInputPosition, Port::INPUT, module, ShaperPlus::ON_INPUT)); - addInput(Port::create<Port24>(decayInputPosition, Port::INPUT, module, ShaperPlus::DECAY_INPUT)); - addInput(Port::create<Port24>(offInputPosition, Port::INPUT, module, ShaperPlus::OFF_INPUT)); - addInput(Port::create<Port24>(envInputPosition, Port::INPUT, module, ShaperPlus::ENV_INPUT)); - addInput(Port::create<Port24>(signalcvInputPosition, Port::INPUT, module, ShaperPlus::SIGNALCV_INPUT)); - - addOutput(Port::create<Port24>(attackOutputPosition, Port::OUTPUT, module, ShaperPlus::ATTACK_OUTPUT)); - addOutput(Port::create<Port24>(onOutputPosition, Port::OUTPUT, module, ShaperPlus::ON_OUTPUT)); - addOutput(Port::create<Port24>(decayOutputPosition, Port::OUTPUT, module, ShaperPlus::DECAY_OUTPUT)); - addOutput(Port::create<Port24>(offOutputPosition, Port::OUTPUT, module, ShaperPlus::OFF_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(attackLightPosition, module, ShaperPlus::ATTACK_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(onLightPosition, module, ShaperPlus::ON_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(decayLightPosition, module, ShaperPlus::DECAY_LIGHT)); - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(offLightPosition, module, ShaperPlus::OFF_LIGHT)); -} - -Menu* ShaperPlusWidget::createContextMenu() { - ShaperPlus* shaperPlus = dynamic_cast<ShaperPlus*>(module); - assert(shaperPlus); - Menu* menu = ModuleWidget::createContextMenu(); - menu->addChild(new MenuLabel()); - menu->addChild(new TriggerOnLoadMenuItem(shaperPlus, "Resume Loop on Load")); - return menu; -} - - Model* modelShaperPlus = Model::create<ShaperPlus, ShaperPlusWidget>("Bogaudio", "Bogaudio-ShaperPlus", "Shaper+", ENVELOPE_GENERATOR_TAG, AMPLIFIER_TAG); diff --git a/src/ShaperPlus.hpp b/src/ShaperPlus.hpp @@ -0,0 +1,115 @@ +#pragma once + +#include "bogaudio.hpp" +#include "shaper_core.hpp" + +extern Model* modelShaperPlus; + +namespace bogaudio { + +struct ShaperPlus : TriggerOnLoadModule { + enum ParamIds { + ATTACK_PARAM, + ON_PARAM, + DECAY_PARAM, + OFF_PARAM, + ENV_PARAM, + SIGNAL_PARAM, + TRIGGER_PARAM, + SPEED_PARAM, + LOOP_PARAM, + NUM_PARAMS + }; + enum InputIds { + SIGNAL_INPUT, + TRIGGER_INPUT, + ATTACK_INPUT, + ON_INPUT, + DECAY_INPUT, + OFF_INPUT, + ENV_INPUT, + SIGNALCV_INPUT, + NUM_INPUTS + }; + enum OutputIds { + SIGNAL_OUTPUT, + ENV_OUTPUT, + INV_OUTPUT, + TRIGGER_OUTPUT, + ATTACK_OUTPUT, + ON_OUTPUT, + DECAY_OUTPUT, + OFF_OUTPUT, + NUM_OUTPUTS + }; + enum LightIds { + ATTACK_LIGHT, + ON_LIGHT, + DECAY_LIGHT, + OFF_LIGHT, + NUM_LIGHTS + }; + + ShaperCore _core; + + ShaperPlus() : TriggerOnLoadModule( + NUM_PARAMS, + NUM_INPUTS, + NUM_OUTPUTS, + NUM_LIGHTS + ) + , _core( + params[ATTACK_PARAM], + params[ON_PARAM], + params[DECAY_PARAM], + params[OFF_PARAM], + params[ENV_PARAM], + params[SIGNAL_PARAM], + params[TRIGGER_PARAM], + params[SPEED_PARAM], + params[LOOP_PARAM], + + inputs[SIGNAL_INPUT], + inputs[TRIGGER_INPUT], + &inputs[ATTACK_INPUT], + &inputs[ON_INPUT], + &inputs[DECAY_INPUT], + &inputs[OFF_INPUT], + &inputs[ENV_INPUT], + &inputs[SIGNALCV_INPUT], + + outputs[SIGNAL_OUTPUT], + outputs[ENV_OUTPUT], + outputs[INV_OUTPUT], + outputs[TRIGGER_OUTPUT], + &outputs[ATTACK_OUTPUT], + &outputs[ON_OUTPUT], + &outputs[DECAY_OUTPUT], + &outputs[OFF_OUTPUT], + + lights[ATTACK_LIGHT], + lights[ON_LIGHT], + lights[DECAY_LIGHT], + lights[OFF_LIGHT], + + _triggerOnLoad, + _shouldTriggerOnLoad + ) + { + onReset(); + } + + virtual void onReset() override { + _core.reset(); + } + + virtual void step() override { + _core.step(); + } + + virtual bool shouldTriggerOnNextLoad() override { + return _core._stage != _core.STOPPED_STAGE; + } +}; + +} // namespace bogaudio diff --git a/src/SixHP.cpp b/src/SixHP.cpp @@ -1,55 +0,0 @@ - -#include "bogaudio.hpp" - -struct SixHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - SixHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void SixHP::onReset() { -} - -void SixHP::step() { -} - - -struct SixHPWidget : ModuleWidget { - SixHPWidget(SixHP* module); -}; - -SixHPWidget::SixHPWidget(SixHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 6, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/SixHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelSixHP = Model::create<SixHP, SixHPWidget>("Bogaudio", "Bogaudio-SixHP", "6HP"); diff --git a/src/Stack.cpp b/src/Stack.cpp @@ -1,43 +1,5 @@ -#include "bogaudio.hpp" -#include "dsp/pitch.hpp" - -using namespace bogaudio::dsp; - -struct Stack : Module { - enum ParamsIds { - SEMIS_PARAM, - OCTAVE_PARAM, - FINE_PARAM, - QUANTIZE_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - CV_INPUT, - IN_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - THRU_OUTPUT, - OUT_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - QUANTIZE_LIGHT, - NUM_LIGHTS - }; - - const float _minCVOut = semitoneToCV(24.0); // C1 - const float _maxCVOut = semitoneToCV(120.0); // C9 - - Stack() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - } - - virtual void step() override; -}; +#include "Stack.hpp" void Stack::step() { lights[QUANTIZE_LIGHT].value = params[QUANTIZE_PARAM].value > 0.5; @@ -65,63 +27,59 @@ void Stack::step() { } } - struct StackWidget : ModuleWidget { - StackWidget(Stack* module); -}; - -StackWidget::StackWidget(Stack* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Stack.svg"))); - addChild(panel); + StackWidget(Stack* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Stack.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto semisParamPosition = Vec(9.5, 32.5); + auto octaveParamPosition = Vec(14.5, 86.5); + auto fineParamPosition = Vec(14.5, 126.5); + auto quantizeParamPosition = Vec(26.9, 191.9); + + auto cvInputPosition = Vec(10.5, 157.0); + auto inInputPosition = Vec(10.5, 215.0); + + auto thruOutputPosition = Vec(10.5, 253.0); + auto outOutputPosition = Vec(10.5, 289.0); + + auto quantizeLightPosition = Vec(21.0, 195.0); + // end generated by svg_widgets.rb + + { + auto w = ParamWidget::create<Knob26>(semisParamPosition, module, Stack::SEMIS_PARAM, 0.0, 11.0, 0.0); + dynamic_cast<Knob*>(w)->snap = true; + addParam(w); + } + { + auto w = ParamWidget::create<Knob16>(octaveParamPosition, module, Stack::OCTAVE_PARAM, -3.0, 3.0, 0.0); + auto k = dynamic_cast<SVGKnob*>(w); + k->snap = true; + k->minAngle = -0.5 * M_PI; + k->maxAngle = 0.5 * M_PI; + addParam(w); + } + addParam(ParamWidget::create<Knob16>(fineParamPosition, module, Stack::FINE_PARAM, -0.99, 0.99, 0.0)); + addParam(ParamWidget::create<StatefulButton9>(quantizeParamPosition, module, Stack::QUANTIZE_PARAM, 0.0, 1.0, 1.0)); + + addInput(Port::create<Port24>(cvInputPosition, Port::INPUT, module, Stack::CV_INPUT)); + addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Stack::IN_INPUT)); + + addOutput(Port::create<Port24>(thruOutputPosition, Port::OUTPUT, module, Stack::THRU_OUTPUT)); + addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Stack::OUT_OUTPUT)); + + addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(quantizeLightPosition, module, Stack::QUANTIZE_LIGHT)); } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - - // generated by svg_widgets.rb - auto semisParamPosition = Vec(9.5, 32.5); - auto octaveParamPosition = Vec(14.5, 86.5); - auto fineParamPosition = Vec(14.5, 126.5); - auto quantizeParamPosition = Vec(26.9, 191.9); - - auto cvInputPosition = Vec(10.5, 157.0); - auto inInputPosition = Vec(10.5, 215.0); - - auto thruOutputPosition = Vec(10.5, 253.0); - auto outOutputPosition = Vec(10.5, 289.0); - - auto quantizeLightPosition = Vec(21.0, 195.0); - // end generated by svg_widgets.rb - - { - auto w = ParamWidget::create<Knob26>(semisParamPosition, module, Stack::SEMIS_PARAM, 0.0, 11.0, 0.0); - dynamic_cast<Knob*>(w)->snap = true; - addParam(w); - } - { - auto w = ParamWidget::create<Knob16>(octaveParamPosition, module, Stack::OCTAVE_PARAM, -3.0, 3.0, 0.0); - auto k = dynamic_cast<SVGKnob*>(w); - k->snap = true; - k->minAngle = -0.5 * M_PI; - k->maxAngle = 0.5 * M_PI; - addParam(w); - } - addParam(ParamWidget::create<Knob16>(fineParamPosition, module, Stack::FINE_PARAM, -0.99, 0.99, 0.0)); - addParam(ParamWidget::create<StatefulButton9>(quantizeParamPosition, module, Stack::QUANTIZE_PARAM, 0.0, 1.0, 1.0)); - - addInput(Port::create<Port24>(cvInputPosition, Port::INPUT, module, Stack::CV_INPUT)); - addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Stack::IN_INPUT)); - - addOutput(Port::create<Port24>(thruOutputPosition, Port::OUTPUT, module, Stack::THRU_OUTPUT)); - addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Stack::OUT_OUTPUT)); - - addChild(ModuleLightWidget::create<TinyLight<GreenLight>>(quantizeLightPosition, module, Stack::QUANTIZE_LIGHT)); -} - +}; Model* modelStack = Model::create<Stack, StackWidget>("Bogaudio", "Bogaudio-Stack", "Stack"); diff --git a/src/Stack.hpp b/src/Stack.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/pitch.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelStack; + +namespace bogaudio { + +struct Stack : Module { + enum ParamsIds { + SEMIS_PARAM, + OCTAVE_PARAM, + FINE_PARAM, + QUANTIZE_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + CV_INPUT, + IN_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + THRU_OUTPUT, + OUT_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + QUANTIZE_LIGHT, + NUM_LIGHTS + }; + + const float _minCVOut = semitoneToCV(24.0); // C1 + const float _maxCVOut = semitoneToCV(120.0); // C9 + + Stack() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + } + + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/Switch.cpp b/src/Switch.cpp @@ -1,48 +1,11 @@ -#include "bogaudio.hpp" +#include "Switch.hpp" -namespace bogaudio { - -struct Switch : Module { - enum ParamsIds { - GATE_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - GATE_INPUT, - HIGH1_INPUT, - LOW1_INPUT, - HIGH2_INPUT, - LOW2_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - OUT1_OUTPUT, - OUT2_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - SchmittTrigger _trigger; - - Switch() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void Switch::onReset() { +void bogaudio::Switch::onReset() { _trigger.reset(); } -void Switch::step() { +void bogaudio::Switch::step() { _trigger.process(params[GATE_PARAM].value + inputs[GATE_INPUT].value); if (_trigger.isHigh()) { outputs[OUT1_OUTPUT].value = inputs[HIGH1_INPUT].value; @@ -54,50 +17,44 @@ void Switch::step() { } } -} // namespace bogaudio - - struct SwitchWidget : ModuleWidget { - SwitchWidget(bogaudio::Switch* module); -}; - -SwitchWidget::SwitchWidget(bogaudio::Switch* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Switch.svg"))); - addChild(panel); + SwitchWidget(bogaudio::Switch* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Switch.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto gateParamPosition = Vec(13.5, 22.0); + + auto gateInputPosition = Vec(10.5, 44.0); + auto high1InputPosition = Vec(10.5, 90.0); + auto low1InputPosition = Vec(10.5, 126.0); + auto high2InputPosition = Vec(10.5, 209.0); + auto low2InputPosition = Vec(10.5, 245.0); + + auto out1OutputPosition = Vec(10.5, 164.0); + auto out2OutputPosition = Vec(10.5, 283.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<Button18>(gateParamPosition, module, bogaudio::Switch::GATE_PARAM, 0.0, 1.0, 0.0)); + + addInput(Port::create<Port24>(gateInputPosition, Port::INPUT, module, bogaudio::Switch::GATE_INPUT)); + addInput(Port::create<Port24>(high1InputPosition, Port::INPUT, module, bogaudio::Switch::HIGH1_INPUT)); + addInput(Port::create<Port24>(low1InputPosition, Port::INPUT, module, bogaudio::Switch::LOW1_INPUT)); + addInput(Port::create<Port24>(high2InputPosition, Port::INPUT, module, bogaudio::Switch::HIGH2_INPUT)); + addInput(Port::create<Port24>(low2InputPosition, Port::INPUT, module, bogaudio::Switch::LOW2_INPUT)); + + addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, bogaudio::Switch::OUT1_OUTPUT)); + addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, bogaudio::Switch::OUT2_OUTPUT)); } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - - // generated by svg_widgets.rb - auto gateParamPosition = Vec(13.5, 22.0); - - auto gateInputPosition = Vec(10.5, 44.0); - auto high1InputPosition = Vec(10.5, 90.0); - auto low1InputPosition = Vec(10.5, 126.0); - auto high2InputPosition = Vec(10.5, 209.0); - auto low2InputPosition = Vec(10.5, 245.0); - - auto out1OutputPosition = Vec(10.5, 164.0); - auto out2OutputPosition = Vec(10.5, 283.0); - // end generated by svg_widgets.rb - - addParam(ParamWidget::create<Button18>(gateParamPosition, module, bogaudio::Switch::GATE_PARAM, 0.0, 1.0, 0.0)); - - addInput(Port::create<Port24>(gateInputPosition, Port::INPUT, module, bogaudio::Switch::GATE_INPUT)); - addInput(Port::create<Port24>(high1InputPosition, Port::INPUT, module, bogaudio::Switch::HIGH1_INPUT)); - addInput(Port::create<Port24>(low1InputPosition, Port::INPUT, module, bogaudio::Switch::LOW1_INPUT)); - addInput(Port::create<Port24>(high2InputPosition, Port::INPUT, module, bogaudio::Switch::HIGH2_INPUT)); - addInput(Port::create<Port24>(low2InputPosition, Port::INPUT, module, bogaudio::Switch::LOW2_INPUT)); - - addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, bogaudio::Switch::OUT1_OUTPUT)); - addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, bogaudio::Switch::OUT2_OUTPUT)); -} - +}; Model* modelSwitch = Model::create<bogaudio::Switch, SwitchWidget>("Bogaudio", "Bogaudio-Switch", "Switch", SWITCH_TAG, UTILITY_TAG); diff --git a/src/Switch.hpp b/src/Switch.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelSwitch; + +namespace bogaudio { + +struct Switch : Module { + enum ParamsIds { + GATE_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + GATE_INPUT, + HIGH1_INPUT, + LOW1_INPUT, + HIGH2_INPUT, + LOW2_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + OUT1_OUTPUT, + OUT2_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + SchmittTrigger _trigger; + + Switch() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + onReset(); + } + + virtual void onReset() override; + virtual void step() override; +}; + +} // namespace bogaudio diff --git a/src/TenHP.cpp b/src/TenHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct TenHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - TenHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void TenHP::onReset() { -} - -void TenHP::step() { -} - - -struct TenHPWidget : ModuleWidget { - TenHPWidget(TenHP* module); -}; - -TenHPWidget::TenHPWidget(TenHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/TenHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(0, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelTenHP = Model::create<TenHP, TenHPWidget>("Bogaudio", "Bogaudio-TenHP", "10HP"); diff --git a/src/Test.cpp b/src/Test.cpp @@ -1,154 +1,5 @@ -// #define LPF 1 -// #define SINE 1 -// #define SQUARE 1 -// #define SAW 1 -// #define TRIANGLE 1 -#define SINEBANK 1 - -#include "bogaudio.hpp" -#include "pitch.hpp" -#ifdef LPF -#include "dsp/filter.hpp" -#elif SINE -#include "dsp/oscillator.hpp" -#elif SQUARE -#include "dsp/oscillator.hpp" -#elif SAW -#include "dsp/oscillator.hpp" -#elif TRIANGLE -#include "dsp/oscillator.hpp" -#elif SINEBANK -#include "dsp/oscillator.hpp" -#else -#error what -#endif - -using namespace bogaudio::dsp; - -struct Test : Module { - enum ParamsIds { - PARAM1_PARAM, - PARAM2_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - CV1_INPUT, - CV2_INPUT, - IN_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - OUT_OUTPUT, - OUT2_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - -#ifdef LPF - LowPassFilter _lpf; -#elif SINE - SineOscillator _sine; -#elif SQUARE - SquareOscillator _square; -#elif SAW - SawOscillator _saw; -#elif TRIANGLE - TriangleOscillator _triangle; -#elif SINEBANK - SineBankOscillator _sineBank; -#endif - - Test() - : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) -#ifdef LPF - , _lpf(44100.0, 1000.0, 1.0) -#elif SINE - , _sine(44100.0, 1000.0, 5.0) -#elif SQUARE - , _square(44100.0, 1000.0, 5.0) -#elif SAW - , _saw(44100.0, 1000.0, 5.0) -#elif TRIANGLE - , _triangle(44100.0, 1000.0, 5.0) -#elif SINEBANK - , _sineBank(44101.0, 1000.0, 50) -#endif - { - onReset(); - -#ifdef SINEBANK - const float baseAmplitude = 5.0; - switch (5) { - case 1: { - // saw - float phase = M_PI; - for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { - _sineBank.setPartial(i, i, baseAmplitude / (float)i, &phase); - } - break; - } - - case 2: { - // square - for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { - _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)i : 0.0); - } - break; - } - - case 3: { - // triangle - if (false) { - float phase = M_PI / 2.0; - for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { - _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)(i * i) : 0.0, &phase); - } - } - else { - float phase = 0.0f; - _sineBank.setPartial(1, 1.0f, baseAmplitude, &phase); - for (int i = 2, n = _sineBank.partialCount(); i < n; ++i) { - float k = 2*i - 1; - _sineBank.setPartial(i, k, powf(-1.0f, k) * baseAmplitude/(k * k), &phase); - } - } - break; - } - - case 4: { - // saw-square - for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { - _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)i : baseAmplitude / (float)(2 * i)); - } - break; - } - - case 5: { - // ? - float phase = 0.0; - float factor = 0.717; - float factor2 = factor; - float multiple = 1.0; - for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { - _sineBank.setPartial(i, multiple, baseAmplitude / multiple, &phase); - multiple += i % 2 == 1 ? factor : factor2; - } - break; - } - } -#endif - } - - virtual void onReset() override; - virtual void step() override; - float oscillatorPitch(); -}; +#include "Test.hpp" void Test::onReset() { } @@ -210,44 +61,41 @@ float Test::oscillatorPitch() { struct TestWidget : ModuleWidget { - TestWidget(Test* module); -}; - -TestWidget::TestWidget(Test* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/Test.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + TestWidget(Test* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/Test.svg"))); + addChild(panel); + } - // generated by svg_widgets.rb - auto param1ParamPosition = Vec(9.5, 28.5); - auto param2ParamPosition = Vec(9.5, 128.5); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - auto cv1InputPosition = Vec(10.5, 66.0); - auto cv2InputPosition = Vec(10.5, 168.0); - auto inInputPosition = Vec(10.5, 258.0); + // generated by svg_widgets.rb + auto param1ParamPosition = Vec(9.5, 28.5); + auto param2ParamPosition = Vec(9.5, 128.5); - auto outOutputPosition = Vec(10.5, 296.0); - auto out2OutputPosition = Vec(20.5, 316.0); - // end generated by svg_widgets.rb + auto cv1InputPosition = Vec(10.5, 66.0); + auto cv2InputPosition = Vec(10.5, 168.0); + auto inInputPosition = Vec(10.5, 258.0); - addParam(ParamWidget::create<Knob26>(param1ParamPosition, module, Test::PARAM1_PARAM, 0.0, 1.0, 0.5)); - addParam(ParamWidget::create<Knob26>(param2ParamPosition, module, Test::PARAM2_PARAM, 0.0, 1.0, 0.5)); + auto outOutputPosition = Vec(10.5, 296.0); + auto out2OutputPosition = Vec(20.5, 316.0); + // end generated by svg_widgets.rb - addInput(Port::create<Port24>(cv1InputPosition, Port::INPUT, module, Test::CV1_INPUT)); - addInput(Port::create<Port24>(cv2InputPosition, Port::INPUT, module, Test::CV2_INPUT)); - addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Test::IN_INPUT)); + addParam(ParamWidget::create<Knob26>(param1ParamPosition, module, Test::PARAM1_PARAM, 0.0, 1.0, 0.5)); + addParam(ParamWidget::create<Knob26>(param2ParamPosition, module, Test::PARAM2_PARAM, 0.0, 1.0, 0.5)); - addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Test::OUT_OUTPUT)); - addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, Test::OUT2_OUTPUT)); -} + addInput(Port::create<Port24>(cv1InputPosition, Port::INPUT, module, Test::CV1_INPUT)); + addInput(Port::create<Port24>(cv2InputPosition, Port::INPUT, module, Test::CV2_INPUT)); + addInput(Port::create<Port24>(inInputPosition, Port::INPUT, module, Test::IN_INPUT)); + addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, Test::OUT_OUTPUT)); + addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, Test::OUT2_OUTPUT)); + } +}; Model* modelTest = Model::create<Test, TestWidget>("Bogaudio", "Bogaudio-Test", "Test"); diff --git a/src/Test.hpp b/src/Test.hpp @@ -0,0 +1,160 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelTest; + +// #define LPF 1 +// #define SINE 1 +// #define SQUARE 1 +// #define SAW 1 +// #define TRIANGLE 1 +#define SINEBANK 1 + +#include "pitch.hpp" +#ifdef LPF +#include "dsp/filter.hpp" +#elif SINE +#include "dsp/oscillator.hpp" +#elif SQUARE +#include "dsp/oscillator.hpp" +#elif SAW +#include "dsp/oscillator.hpp" +#elif TRIANGLE +#include "dsp/oscillator.hpp" +#elif SINEBANK +#include "dsp/oscillator.hpp" +#else +#error what +#endif + +using namespace bogaudio::dsp; + +namespace bogaudio { + + +struct Test : Module { + enum ParamsIds { + PARAM1_PARAM, + PARAM2_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + CV1_INPUT, + CV2_INPUT, + IN_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + OUT_OUTPUT, + OUT2_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + +#ifdef LPF + LowPassFilter _lpf; +#elif SINE + SineOscillator _sine; +#elif SQUARE + SquareOscillator _square; +#elif SAW + SawOscillator _saw; +#elif TRIANGLE + TriangleOscillator _triangle; +#elif SINEBANK + SineBankOscillator _sineBank; +#endif + + Test() + : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) +#ifdef LPF + , _lpf(44100.0, 1000.0, 1.0) +#elif SINE + , _sine(44100.0, 1000.0, 5.0) +#elif SQUARE + , _square(44100.0, 1000.0, 5.0) +#elif SAW + , _saw(44100.0, 1000.0, 5.0) +#elif TRIANGLE + , _triangle(44100.0, 1000.0, 5.0) +#elif SINEBANK + , _sineBank(44101.0, 1000.0, 50) +#endif + { + onReset(); + +#ifdef SINEBANK + const float baseAmplitude = 5.0; + switch (5) { + case 1: { + // saw + float phase = M_PI; + for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { + _sineBank.setPartial(i, i, baseAmplitude / (float)i, &phase); + } + break; + } + + case 2: { + // square + for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { + _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)i : 0.0); + } + break; + } + + case 3: { + // triangle + if (false) { + float phase = M_PI / 2.0; + for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { + _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)(i * i) : 0.0, &phase); + } + } + else { + float phase = 0.0f; + _sineBank.setPartial(1, 1.0f, baseAmplitude, &phase); + for (int i = 2, n = _sineBank.partialCount(); i < n; ++i) { + float k = 2*i - 1; + _sineBank.setPartial(i, k, powf(-1.0f, k) * baseAmplitude/(k * k), &phase); + } + } + break; + } + + case 4: { + // saw-square + for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { + _sineBank.setPartial(i, i, i % 2 == 1 ? baseAmplitude / (float)i : baseAmplitude / (float)(2 * i)); + } + break; + } + + case 5: { + // ? + float phase = 0.0; + float factor = 0.717; + float factor2 = factor; + float multiple = 1.0; + for (int i = 1, n = _sineBank.partialCount(); i <= n; ++i) { + _sineBank.setPartial(i, multiple, baseAmplitude / multiple, &phase); + multiple += i % 2 == 1 ? factor : factor2; + } + break; + } + } +#endif + } + + virtual void onReset() override; + virtual void step() override; + float oscillatorPitch(); +}; + +} // namespace bogaudio diff --git a/src/ThirteenHP.cpp b/src/ThirteenHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct ThirteenHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - ThirteenHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void ThirteenHP::onReset() { -} - -void ThirteenHP::step() { -} - - -struct ThirteenHPWidget : ModuleWidget { - ThirteenHPWidget(ThirteenHP* module); -}; - -ThirteenHPWidget::ThirteenHPWidget(ThirteenHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 13, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThirteenHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(0, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelThirteenHP = Model::create<ThirteenHP, ThirteenHPWidget>("Bogaudio", "Bogaudio-ThirteenHP", "13HP"); diff --git a/src/ThirtyHP.cpp b/src/ThirtyHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct ThirtyHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - ThirtyHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void ThirtyHP::onReset() { -} - -void ThirtyHP::step() { -} - - -struct ThirtyHPWidget : ModuleWidget { - ThirtyHPWidget(ThirtyHP* module); -}; - -ThirtyHPWidget::ThirtyHPWidget(ThirtyHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 30, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThirtyHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelThirtyHP = Model::create<ThirtyHP, ThirtyHPWidget>("Bogaudio", "Bogaudio-ThirtyHP", "30HP"); diff --git a/src/ThreeHP.cpp b/src/ThreeHP.cpp @@ -1,55 +0,0 @@ - -#include "bogaudio.hpp" - -struct ThreeHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - ThreeHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void ThreeHP::onReset() { -} - -void ThreeHP::step() { -} - - -struct ThreeHPWidget : ModuleWidget { - ThreeHPWidget(ThreeHP* module); -}; - -ThreeHPWidget::ThreeHPWidget(ThreeHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThreeHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelThreeHP = Model::create<ThreeHP, ThreeHPWidget>("Bogaudio", "Bogaudio-ThreeHP", "3HP"); diff --git a/src/TwelveHP.cpp b/src/TwelveHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct TwelveHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - TwelveHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void TwelveHP::onReset() { -} - -void TwelveHP::step() { -} - - -struct TwelveHPWidget : ModuleWidget { - TwelveHPWidget(TwelveHP* module); -}; - -TwelveHPWidget::TwelveHPWidget(TwelveHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 12, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwelveHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(0, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); -} - - -Model* modelTwelveHP = Model::create<TwelveHP, TwelveHPWidget>("Bogaudio", "Bogaudio-TwelveHP", "12HP"); diff --git a/src/TwentyFiveHP.cpp b/src/TwentyFiveHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct TwentyFiveHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - TwentyFiveHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void TwentyFiveHP::onReset() { -} - -void TwentyFiveHP::step() { -} - - -struct TwentyFiveHPWidget : ModuleWidget { - TwentyFiveHPWidget(TwentyFiveHP* module); -}; - -TwentyFiveHPWidget::TwentyFiveHPWidget(TwentyFiveHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 25, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyFiveHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelTwentyFiveHP = Model::create<TwentyFiveHP, TwentyFiveHPWidget>("Bogaudio", "Bogaudio-TwentyFiveHP", "25HP"); diff --git a/src/TwentyHP.cpp b/src/TwentyHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct TwentyHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - TwentyHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void TwentyHP::onReset() { -} - -void TwentyHP::step() { -} - - -struct TwentyHPWidget : ModuleWidget { - TwentyHPWidget(TwentyHP* module); -}; - -TwentyHPWidget::TwentyHPWidget(TwentyHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelTwentyHP = Model::create<TwentyHP, TwentyHPWidget>("Bogaudio", "Bogaudio-TwentyHP", "20HP"); diff --git a/src/TwentyTwoHP.cpp b/src/TwentyTwoHP.cpp @@ -1,57 +0,0 @@ - -#include "bogaudio.hpp" - -struct TwentyTwoHP : Module { - enum ParamsIds { - NUM_PARAMS - }; - - enum InputsIds { - NUM_INPUTS - }; - - enum OutputsIds { - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - TwentyTwoHP() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - onReset(); - } - - virtual void onReset() override; - virtual void step() override; -}; - -void TwentyTwoHP::onReset() { -} - -void TwentyTwoHP::step() { -} - - -struct TwentyTwoHPWidget : ModuleWidget { - TwentyTwoHPWidget(TwentyTwoHP* module); -}; - -TwentyTwoHPWidget::TwentyTwoHPWidget(TwentyTwoHP* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 22, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyTwoHP.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(15, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); - addChild(Widget::create<ScrewSilver>(Vec(15, 365))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); -} - - -Model* modelTwentyTwoHP = Model::create<TwentyTwoHP, TwentyTwoHPWidget>("Bogaudio", "Bogaudio-TwentyTwoHP", "22HP"); diff --git a/src/VCA.cpp b/src/VCA.cpp @@ -1,36 +1,5 @@ -#include "bogaudio.hpp" - -struct VCA : Module { - enum ParamsIds { - LEVEL1_PARAM, - LEVEL2_PARAM, - NUM_PARAMS - }; - - enum InputsIds { - CV1_INPUT, - IN1_INPUT, - CV2_INPUT, - IN2_INPUT, - NUM_INPUTS - }; - - enum OutputsIds { - OUT1_OUTPUT, - OUT2_OUTPUT, - NUM_OUTPUTS - }; - - enum LightsIds { - NUM_LIGHTS - }; - - VCA() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} - - virtual void step() override; - void channelStep(Input& input, Output& output, Param& knob, Input& cv); -}; +#include "VCA.hpp" void VCA::step() { channelStep(inputs[IN1_INPUT], outputs[OUT1_OUTPUT], params[LEVEL1_PARAM], inputs[CV1_INPUT]); @@ -51,48 +20,44 @@ void VCA::channelStep(Input& input, Output& output, Param& knob, Input& cv) { } } - struct VCAWidget : ModuleWidget { - VCAWidget(VCA* module); -}; - -VCAWidget::VCAWidget(VCA* module) : ModuleWidget(module) { - box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); - - { - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/VCA.svg"))); - addChild(panel); - } - - addChild(Widget::create<ScrewSilver>(Vec(0, 0))); - addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + VCAWidget(VCA* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/VCA.svg"))); + addChild(panel); + } - // generated by svg_widgets.rb - auto level1ParamPosition = Vec(9.5, 28.5); - auto level2ParamPosition = Vec(9.5, 189.5); + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); - auto cv1InputPosition = Vec(10.5, 66.0); - auto in1InputPosition = Vec(10.5, 101.0); - auto cv2InputPosition = Vec(10.5, 227.0); - auto in2InputPosition = Vec(10.5, 262.0); + // generated by svg_widgets.rb + auto level1ParamPosition = Vec(9.5, 28.5); + auto level2ParamPosition = Vec(9.5, 189.5); - auto out1OutputPosition = Vec(10.5, 139.0); - auto out2OutputPosition = Vec(10.5, 300.0); - // end generated by svg_widgets.rb + auto cv1InputPosition = Vec(10.5, 66.0); + auto in1InputPosition = Vec(10.5, 101.0); + auto cv2InputPosition = Vec(10.5, 227.0); + auto in2InputPosition = Vec(10.5, 262.0); - addParam(ParamWidget::create<Knob26>(level1ParamPosition, module, VCA::LEVEL1_PARAM, 0.0, 1.0, 0.5)); - addParam(ParamWidget::create<Knob26>(level2ParamPosition, module, VCA::LEVEL2_PARAM, 0.0, 1.0, 0.5)); + auto out1OutputPosition = Vec(10.5, 139.0); + auto out2OutputPosition = Vec(10.5, 300.0); + // end generated by svg_widgets.rb - addInput(Port::create<Port24>(cv1InputPosition, Port::INPUT, module, VCA::CV1_INPUT)); - addInput(Port::create<Port24>(in1InputPosition, Port::INPUT, module, VCA::IN1_INPUT)); - addInput(Port::create<Port24>(cv2InputPosition, Port::INPUT, module, VCA::CV2_INPUT)); - addInput(Port::create<Port24>(in2InputPosition, Port::INPUT, module, VCA::IN2_INPUT)); + addParam(ParamWidget::create<Knob26>(level1ParamPosition, module, VCA::LEVEL1_PARAM, 0.0, 1.0, 0.5)); + addParam(ParamWidget::create<Knob26>(level2ParamPosition, module, VCA::LEVEL2_PARAM, 0.0, 1.0, 0.5)); - addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, VCA::OUT1_OUTPUT)); - addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, VCA::OUT2_OUTPUT)); -} + addInput(Port::create<Port24>(cv1InputPosition, Port::INPUT, module, VCA::CV1_INPUT)); + addInput(Port::create<Port24>(in1InputPosition, Port::INPUT, module, VCA::IN1_INPUT)); + addInput(Port::create<Port24>(cv2InputPosition, Port::INPUT, module, VCA::CV2_INPUT)); + addInput(Port::create<Port24>(in2InputPosition, Port::INPUT, module, VCA::IN2_INPUT)); + addOutput(Port::create<Port24>(out1OutputPosition, Port::OUTPUT, module, VCA::OUT1_OUTPUT)); + addOutput(Port::create<Port24>(out2OutputPosition, Port::OUTPUT, module, VCA::OUT2_OUTPUT)); + } +}; Model* modelVCA = Model::create<VCA, VCAWidget>("Bogaudio", "Bogaudio-VCA", "VCA", AMPLIFIER_TAG, DUAL_TAG, UTILITY_TAG); diff --git a/src/VCA.hpp b/src/VCA.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelVCA; + +namespace bogaudio { + +struct VCA : Module { + enum ParamsIds { + LEVEL1_PARAM, + LEVEL2_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + CV1_INPUT, + IN1_INPUT, + CV2_INPUT, + IN2_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + OUT1_OUTPUT, + OUT2_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + VCA() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} + + virtual void step() override; + void channelStep(Input& input, Output& output, Param& knob, Input& cv); +}; + +} // namespace bogaudio diff --git a/src/bogaudio.cpp b/src/bogaudio.cpp @@ -1,5 +1,27 @@ + #include "bogaudio.hpp" +#include "Shaper.hpp" +#include "ShaperPlus.hpp" +#include "DADSRH.hpp" +#include "DADSRHPlus.hpp" + +#include "Analyzer.hpp" + +#include "Detune.hpp" +#include "DGate.hpp" +#include "Manual.hpp" +#include "Noise.hpp" +#include "Offset.hpp" +#include "Reftone.hpp" +#include "SampleHold.hpp" +#include "Stack.hpp" +#include "Switch.hpp" +#include "VCA.hpp" + +#include "Test.hpp" +#include "template_panels.hpp" + Plugin *plugin; void init(rack::Plugin *p) { diff --git a/src/bogaudio.hpp b/src/bogaudio.hpp @@ -1,3 +1,4 @@ +#pragma once #include <stdlib.h> #include <stdio.h> @@ -15,36 +16,3 @@ using namespace rack; using namespace bogaudio; extern Plugin *plugin; - -extern Model* modelShaper; -extern Model* modelShaperPlus; -extern Model* modelDADSRH; -extern Model* modelDADSRHPlus; - -extern Model* modelAnalyzer; - -extern Model* modelDetune; -extern Model* modelDGate; -extern Model* modelManual; -extern Model* modelNoise; -extern Model* modelOffset; -extern Model* modelReftone; -extern Model* modelSampleHold; -extern Model* modelStack; -extern Model* modelSwitch; -extern Model* modelVCA; - -extern Model* modelTest; - -extern Model* modelThreeHP; -extern Model* modelSixHP; -extern Model* modelEightHP; -extern Model* modelTenHP; -extern Model* modelTwelveHP; -extern Model* modelThirteenHP; -extern Model* modelFifteenHP; -extern Model* modelEighteenHP; -extern Model* modelTwentyHP; -extern Model* modelTwentyTwoHP; -extern Model* modelTwentyFiveHP; -extern Model* modelThirtyHP; diff --git a/src/dadsrh_core.hpp b/src/dadsrh_core.hpp @@ -1,3 +1,4 @@ +#pragma once #include "bogaudio.hpp" diff --git a/src/shaper_core.hpp b/src/shaper_core.hpp @@ -1,3 +1,4 @@ +#pragma once #include "bogaudio.hpp" diff --git a/src/template_panels.cpp b/src/template_panels.cpp @@ -0,0 +1,246 @@ + +#include "template_panels.hpp" + +struct ThreeHPWidget : ModuleWidget { + ThreeHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThreeHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelThreeHP = Model::create<Module, ThreeHPWidget>("Bogaudio", "Bogaudio-ThreeHP", "3HP"); + + +struct SixHPWidget : ModuleWidget { + SixHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 6, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/SixHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelSixHP = Model::create<Module, SixHPWidget>("Bogaudio", "Bogaudio-SixHP", "6HP"); + + +struct EightHPWidget : ModuleWidget { + EightHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 8, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/EightHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelEightHP = Model::create<Module, EightHPWidget>("Bogaudio", "Bogaudio-EightHP", "8HP"); + + +struct TenHPWidget : ModuleWidget { + TenHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/TenHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelTenHP = Model::create<Module, TenHPWidget>("Bogaudio", "Bogaudio-TenHP", "10HP"); + + +struct TwelveHPWidget : ModuleWidget { + TwelveHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 12, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwelveHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelTwelveHP = Model::create<Module, TwelveHPWidget>("Bogaudio", "Bogaudio-TwelveHP", "12HP"); + +struct ThirteenHPWidget : ModuleWidget { + ThirteenHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 13, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThirteenHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + } +}; + +Model* modelThirteenHP = Model::create<Module, ThirteenHPWidget>("Bogaudio", "Bogaudio-ThirteenHP", "13HP"); + + +struct FifteenHPWidget : ModuleWidget { + FifteenHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 15, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/FifteenHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelFifteenHP = Model::create<Module, FifteenHPWidget>("Bogaudio", "Bogaudio-FifteenHP", "15HP"); + + +struct EighteenHPWidget : ModuleWidget { + EighteenHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 18, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/EighteenHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelEighteenHP = Model::create<Module, EighteenHPWidget>("Bogaudio", "Bogaudio-EighteenHP", "18HP"); + + +struct TwentyHPWidget : ModuleWidget { + TwentyHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelTwentyHP = Model::create<Module, TwentyHPWidget>("Bogaudio", "Bogaudio-TwentyHP", "20HP"); + + +struct TwentyTwoHPWidget : ModuleWidget { + TwentyTwoHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 22, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyTwoHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelTwentyTwoHP = Model::create<Module, TwentyTwoHPWidget>("Bogaudio", "Bogaudio-TwentyTwoHP", "22HP"); + + +struct TwentyFiveHPWidget : ModuleWidget { + TwentyFiveHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 25, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/TwentyFiveHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelTwentyFiveHP = Model::create<Module, TwentyFiveHPWidget>("Bogaudio", "Bogaudio-TwentyFiveHP", "25HP"); + + +struct ThirtyHPWidget : ModuleWidget { + ThirtyHPWidget(Module* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * 30, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/ThirtyHP.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 0))); + addChild(Widget::create<ScrewSilver>(Vec(15, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 30, 365))); + } +}; + +Model* modelThirtyHP = Model::create<Module, ThirtyHPWidget>("Bogaudio", "Bogaudio-ThirtyHP", "30HP"); diff --git a/src/template_panels.hpp b/src/template_panels.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "bogaudio.hpp" + +extern Model* modelThreeHP; +extern Model* modelSixHP; +extern Model* modelEightHP; +extern Model* modelTenHP; +extern Model* modelTwelveHP; +extern Model* modelThirteenHP; +extern Model* modelFifteenHP; +extern Model* modelEighteenHP; +extern Model* modelTwentyHP; +extern Model* modelTwentyTwoHP; +extern Model* modelTwentyFiveHP; +extern Model* modelThirtyHP;