The basics of a plugin!
This commit is contained in:
parent
7ffd616915
commit
c4801ac7fe
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/build
|
||||||
|
/dist
|
||||||
|
/plugin.so
|
||||||
|
/plugin.dylib
|
||||||
|
/plugin.dll
|
||||||
|
.DS_Store
|
23
Makefile
Normal file
23
Makefile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# If RACK_DIR is not defined when calling the Makefile, default to two directories above
|
||||||
|
RACK_DIR ?= ../..
|
||||||
|
|
||||||
|
# FLAGS will be passed to both the C and C++ compiler
|
||||||
|
FLAGS +=
|
||||||
|
CFLAGS +=
|
||||||
|
CXXFLAGS +=
|
||||||
|
|
||||||
|
# Careful about linking to shared libraries, since you can't assume much about the user's environment and library search path.
|
||||||
|
# Static libraries are fine, but they should be added to this plugin's build system.
|
||||||
|
LDFLAGS +=
|
||||||
|
|
||||||
|
# Add .cpp files to the build
|
||||||
|
SOURCES += $(wildcard src/*.cpp)
|
||||||
|
|
||||||
|
# Add files to the ZIP package when running `make dist`
|
||||||
|
# The compiled plugin and "plugin.json" are automatically added.
|
||||||
|
DISTRIBUTABLES += res
|
||||||
|
DISTRIBUTABLES += $(wildcard LICENSE*)
|
||||||
|
DISTRIBUTABLES += $(wildcard presets)
|
||||||
|
|
||||||
|
# Include the Rack plugin Makefile framework
|
||||||
|
include $(RACK_DIR)/plugin.mk
|
25
plugin.json
Normal file
25
plugin.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"slug": "a10u8r_plugin",
|
||||||
|
"name": "A10U8R",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"brand": "ewpratten",
|
||||||
|
"author": "Evan Pratten",
|
||||||
|
"authorEmail": "contact@ewpratten.com",
|
||||||
|
"authorUrl": "https://ewpratten.com",
|
||||||
|
"pluginUrl": "https://ewpratten.com/products/vcvrack/a10u8r",
|
||||||
|
"manualUrl": "",
|
||||||
|
"sourceUrl": "https://github.com/ewpratten/A10U8R",
|
||||||
|
"donateUrl": "https://ewpratten.com/donate",
|
||||||
|
"changelogUrl": "",
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"slug": "a10u8r_module",
|
||||||
|
"name": "a10u8r_module",
|
||||||
|
"description": "A simple, hacky, attenuator",
|
||||||
|
"tags": [
|
||||||
|
"Attenuator"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
100
res/module.svg
Normal file
100
res/module.svg
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="30.48mm"
|
||||||
|
height="128.5mm"
|
||||||
|
viewBox="0 0 30.480002 128.50002"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||||
|
sodipodi:docname="module.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="1.4"
|
||||||
|
inkscape:cx="28.571429"
|
||||||
|
inkscape:cy="196.07143"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
units="mm"
|
||||||
|
inkscape:snap-bbox="true"
|
||||||
|
inkscape:snap-page="true"
|
||||||
|
inkscape:bbox-nodes="false"
|
||||||
|
inkscape:snap-bbox-edge-midpoints="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1043"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="268"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:snap-bbox-midpoints="true"
|
||||||
|
inkscape:snap-nodes="false"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-168.49998)">
|
||||||
|
<rect
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.64935839;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
|
||||||
|
id="rect420"
|
||||||
|
width="30.48"
|
||||||
|
height="128.5"
|
||||||
|
x="5.9211732e-17"
|
||||||
|
y="168.49997" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:label="components">
|
||||||
|
<circle
|
||||||
|
inkscape:label="output"
|
||||||
|
r="4"
|
||||||
|
cy="110.49068"
|
||||||
|
cx="15.24"
|
||||||
|
id="circle66-6"
|
||||||
|
style="display:inline;vector-effect:none;fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
|
||||||
|
<circle
|
||||||
|
inkscape:label="input"
|
||||||
|
r="4"
|
||||||
|
cy="25.80987"
|
||||||
|
cx="15.24"
|
||||||
|
id="circle66"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#00ff00;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
|
||||||
|
<circle
|
||||||
|
inkscape:label="value"
|
||||||
|
r="4"
|
||||||
|
cy="64.25"
|
||||||
|
cx="15.24"
|
||||||
|
id="circle66-7"
|
||||||
|
style="display:inline;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After (image error) Size: 3.5 KiB |
55
src/module.cpp
Normal file
55
src/module.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "plugin.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
struct A10u8r_module : Module {
|
||||||
|
enum ParamId {
|
||||||
|
VALUE_PARAM,
|
||||||
|
PARAMS_LEN
|
||||||
|
};
|
||||||
|
enum InputId {
|
||||||
|
INPUT_INPUT,
|
||||||
|
INPUTS_LEN
|
||||||
|
};
|
||||||
|
enum OutputId {
|
||||||
|
OUTPUT_OUTPUT,
|
||||||
|
OUTPUTS_LEN
|
||||||
|
};
|
||||||
|
enum LightId {
|
||||||
|
LIGHTS_LEN
|
||||||
|
};
|
||||||
|
|
||||||
|
A10u8r_module() {
|
||||||
|
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
|
||||||
|
configParam(VALUE_PARAM, 0.f, 1.f, 0.f, "");
|
||||||
|
configInput(INPUT_INPUT, "");
|
||||||
|
configOutput(OUTPUT_OUTPUT, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void process(const ProcessArgs& args) override {
|
||||||
|
float value = params[VALUE_PARAM].getValue();
|
||||||
|
float input = inputs[INPUT_INPUT].getVoltage();
|
||||||
|
outputs[OUTPUT_OUTPUT].setVoltage(value * input);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct A10u8r_moduleWidget : ModuleWidget {
|
||||||
|
A10u8r_moduleWidget(A10u8r_module* module) {
|
||||||
|
setModule(module);
|
||||||
|
setPanel(createPanel(asset::plugin(pluginInstance, "res/a10u8r_module.svg")));
|
||||||
|
|
||||||
|
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
|
||||||
|
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
|
||||||
|
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||||
|
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||||
|
|
||||||
|
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(15.24, 64.25)), module, A10u8r_module::VALUE_PARAM));
|
||||||
|
|
||||||
|
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(15.24, 25.81)), module, A10u8r_module::INPUT_INPUT));
|
||||||
|
|
||||||
|
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(15.24, 110.491)), module, A10u8r_module::OUTPUT_OUTPUT));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Model* modelA10u8r_module = createModel<A10u8r_module, A10u8r_moduleWidget>("a10u8r_module");
|
15
src/plugin.cpp
Normal file
15
src/plugin.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "plugin.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
Plugin* pluginInstance;
|
||||||
|
|
||||||
|
|
||||||
|
void init(Plugin* p) {
|
||||||
|
pluginInstance = p;
|
||||||
|
|
||||||
|
// Add modules here
|
||||||
|
p->addModel(modelA10u8r_module);
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
}
|
11
src/plugin.hpp
Normal file
11
src/plugin.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <rack.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace rack;
|
||||||
|
|
||||||
|
// Declare the Plugin, defined in plugin.cpp
|
||||||
|
extern Plugin* pluginInstance;
|
||||||
|
|
||||||
|
// Declare each Model, defined in each module source file
|
||||||
|
extern Model* modelA10u8r_module;
|
Reference in New Issue
Block a user