From b18b118e95e35de524838ddbe93f129f2c55fb32 Mon Sep 17 00:00:00 2001 From: "U-ACTIVED\\danielez" Date: Wed, 21 Feb 2018 19:41:48 +0100 Subject: [PATCH] Updated to Rack 0.6 API --- Makefile | 31 +++++--------------------- src/MessedUpOsc.cpp | 51 +++++++++++++++++++++++-------------------- src/RODENTMODULES.cpp | 20 +++++------------ src/RODENTMODULES.hpp | 8 +------ 4 files changed, 38 insertions(+), 72 deletions(-) diff --git a/Makefile b/Makefile index e93e47b..5cc43aa 100755 --- a/Makefile +++ b/Makefile @@ -1,30 +1,9 @@ +SLUG = RODENTMODULES +VERSION = 0.6.0dev -# FLAGS will be passed to both the C and C++ compiler -FLAGS += -CFLAGS += -CXXFLAGS += - -# Careful about linking to libraries, since you can't assume much about the user's environment and library search path. -# Static libraries are fine. -LDFLAGS += - -# Add .cpp and .c files to the build SOURCES = $(wildcard src/*.cpp) +DISTRIBUTABLES += $(wildcard LICENSE*) res -# Must include the VCV plugin Makefile framework -include ../../plugin.mk - - -# Convenience target for including files in the distributable release -DIST_NAME = Template -.PHONY: dist -dist: all -ifndef VERSION - $(error VERSION must be defined when making distributables) -endif - mkdir -p dist/$(DIST_NAME) - cp LICENSE* dist/$(DIST_NAME)/ - cp $(TARGET) dist/$(DIST_NAME)/ - cp -R res dist/$(DIST_NAME)/ - cd dist && zip -5 -r $(DIST_NAME)-$(VERSION)-$(ARCH).zip $(DIST_NAME) +RACK_DIR ?= ../.. +include $(RACK_DIR)/plugin.mk \ No newline at end of file diff --git a/src/MessedUpOsc.cpp b/src/MessedUpOsc.cpp index 24bf73d..908b263 100755 --- a/src/MessedUpOsc.cpp +++ b/src/MessedUpOsc.cpp @@ -26,11 +26,6 @@ struct MessedUpOsc : Module { MessedUpOsc() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} void step() override; - - // For more advanced Module features, read Rack's engine.hpp header file - // - toJson, fromJson: serialization of internal data - // - onSampleRateChange: event triggered by a change of sample rate - // - reset, randomize: implements special behavior when user clicks these from the context menu }; @@ -41,7 +36,7 @@ void MessedUpOsc::step() { // Compute the frequency from the pitch parameter and input float pitch = params[PITCH_PARAM].value; pitch += inputs[PITCH_INPUT].value; - pitch = clampf(pitch, -4.0, 4.0); + pitch = clamp(pitch, -4.0f, 4.0f); float freq = 440.0 * powf(2.0, pitch); // Accumulate the phase @@ -74,9 +69,14 @@ void MessedUpOsc::step() { } -MessedUpOscWidget::MessedUpOscWidget() { - MessedUpOsc *module = new MessedUpOsc(); - setModule(module); +struct MessedUpOscWidget : ModuleWidget { + MessedUpOscWidget(MessedUpOsc *module); +}; + + +MessedUpOscWidget::MessedUpOscWidget(MessedUpOsc *module) : ModuleWidget(module) { + + /* box.size = Vec(208, RACK_GRID_HEIGHT); { @@ -85,19 +85,22 @@ MessedUpOscWidget::MessedUpOscWidget() { panel->setBackground(SVG::load(assetPlugin(plugin, "res/MessedUpOsc.svg"))); addChild(panel); } - - addChild(createScrew(Vec(15, 0))); - addChild(createScrew(Vec(box.size.x - 30, 0))); - addChild(createScrew(Vec(15, 365))); - addChild(createScrew(Vec(box.size.x - 30, 365))); - - addParam(createParam(Vec(65, 230), module, MessedUpOsc::PITCH_PARAM, -3.0, 3.0, 0.0)); - addParam(createParam(Vec(24, 150), module, MessedUpOsc::PW_PARAM, -3.0, 3.0, 0.0)); - - addInput(createInput(Vec(115, 236), module, MessedUpOsc::PITCH_INPUT)); - - addInput(createInput(Vec(137, 152), module, MessedUpOsc::PW_INPUT)); - - addOutput(createOutput(Vec(90, 300), module, MessedUpOsc::SQUARE_OUTPUT)); - + */ + + setPanel(SVG::load(assetPlugin(plugin, "res/MessedUpOsc.svg"))); + + addChild(Widget::create(Vec(15, 0))); + addChild(Widget::create(Vec(box.size.x - 30, 0))); + addChild(Widget::create(Vec(15, 365))); + addChild(Widget::create(Vec(box.size.x - 30, 365))); + + addParam(ParamWidget::create(Vec(65, 230), module, MessedUpOsc::PITCH_PARAM, -3.0, 3.0, 0.0)); + addParam(ParamWidget::create(Vec(24, 150), module, MessedUpOsc::PW_PARAM, -3.0, 3.0, 0.0)); + + addInput(Port::create(Vec(115, 236), Port::INPUT, module, MessedUpOsc::PITCH_INPUT)); + addInput(Port::create(Vec(137, 152), Port::INPUT, module, MessedUpOsc::PW_INPUT)); + + addOutput(Port::create(Vec(90, 300), Port::OUTPUT, module, MessedUpOsc::SQUARE_OUTPUT)); } + +Model *modelMessedUpOsc = Model::create("RODENTMODULES", "MessedUpOsc", "Messed Up Oscillator", OSCILLATOR_TAG); \ No newline at end of file diff --git a/src/RODENTMODULES.cpp b/src/RODENTMODULES.cpp index 4d574ec..7484c15 100755 --- a/src/RODENTMODULES.cpp +++ b/src/RODENTMODULES.cpp @@ -1,22 +1,12 @@ #include "RODENTMODULES.hpp" -// The plugin-wide instance of the Plugin class Plugin *plugin; void init(rack::Plugin *p) { plugin = p; - // This is the unique identifier for your plugin - p->slug = "RODENTMODULES"; -#ifdef VERSION - p->version = TOSTRING(heck); -#endif - p->website = "https://rodent-cat.bandcamp.com/"; - p->manual = "NONE YET"; - - // For each module, specify the ModuleWidget subclass, manufacturer slug (for saving in patches), manufacturer human-readable name, module slug, and module name - p->addModel(createModel("RODENTMODULES", "MessedUpOsc", "Messed Up Oscillator", OSCILLATOR_TAG)); - - // Any other plugin initialization may go here. - // As an alternative, consider lazy-loading assets and lookup tables when your module is created to reduce startup times of Rack. -} + p->slug = TOSTRING(SLUG); + p->version = TOSTRING(VERSION); + + p->addModel(modelMessedUpOsc); +} \ No newline at end of file diff --git a/src/RODENTMODULES.hpp b/src/RODENTMODULES.hpp index 3ece741..118f306 100755 --- a/src/RODENTMODULES.hpp +++ b/src/RODENTMODULES.hpp @@ -6,10 +6,4 @@ using namespace rack; extern Plugin *plugin; -//////////////////// -// module widgets -//////////////////// - -struct MessedUpOscWidget : ModuleWidget { - MessedUpOscWidget(); -}; +extern Model *modelMessedUpOsc; \ No newline at end of file