Skip to content

Commit

Permalink
Update to VCV Rack 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djpeterso23662 committed Feb 25, 2023
1 parent 5421ff5 commit 7008233
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ Plugins](https://vcvrack.com/plugins.html) page.

Update to VCV Rack 1.0.0 APIs. Public release through the [VCV Rack
Plugins](https://vcvrack.com/plugins.html) page.

### Version 2.0.0

Update to VCV Rack 2.0.0 APIs. Public release through the [VCV Rack
Plugins](https://vcvrack.com/plugins.html) page.
7 changes: 4 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"slug": "NocturnalEncoder",
"name": "Nocturnal Encoder",
"version": "1.0.0",
"version": "2.0.0",
"license": "BSD-3-Clause",
"brand": "Nocturnal Encoder",
"description": "This plugin exists to provide a low-cost connection between hardware Eurorack synthesizers and VCV Rack.",
"author": "David Peterson",
"authorEmail": "[email protected]",
"authorUrl": "https://github.com/djpeterso23662",
"pluginUrl": "https://github.com/djpeterso23662/NocturnalEncoder",
"manualUrl": "https://github.com/djpeterso23662/NocturnalEncoder/blob/master/README.md",
"sourceUrl": "https://github.com/djpeterso23662/NocturnalEncoder",
"donateUrl": "",
"changelogUrl": "",
"changelogUrl": "https://github.com/djpeterso23662/NocturnalEncoder#changes",
"modules": [
{
"slug": "AMDecoder",
Expand All @@ -30,7 +31,7 @@
"description": "Dual Amplitude Modulation Encoder",
"tags": [
"Oscillator",
"Amplifier",
"Voltage-controlled amplifier",
"Dual"
]
}
Expand Down
16 changes: 13 additions & 3 deletions src/AMDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,26 @@ struct AMDecoder : Module {
configParam(CH2_ATTENUVERTER_PARAM, -1.0, 1.0, 1.0, "Attenuverter CH2 -1 to +1");
configParam(CH2_OFFSET_PARAM, -10.0, 10.0, 0.0, "Offset CH2 -10v to +10v");
configParam(CH2_SCALE_PARAM, 1.0, 3.0, 1.0, "Scale CH2 1x to 3x");
configLight(CH1_WARN_LIGHT, "IN 1 above +10V warning light");
configLight(CH1_ACTIVITY_LIGHT, "OUT 1 level light");
configLight(CH2_WARN_LIGHT, "IN 2 above +10V warning light");
configLight(CH2_ACTIVITY_LIGHT, "OUT 2 level light");
configInput(CH1_SIGNAL_INPUT, "IN 1");
configInput(CH2_SIGNAL_INPUT, "IN 2");
configOutput(CH1_CV_OUTPUT, "OUT 1");
configOutput(CH1_TRIGGER_OUTPUT, "GATE 1");
configOutput(CH2_CV_OUTPUT, "OUT 2");
configOutput(CH2_TRIGGER_OUTPUT, "GATE 2");
}

void process(const ProcessArgs& args) override {
for (int c = 0; c < 2; c++) {
float in = inputs[CH1_SIGNAL_INPUT + c].getVoltage();
if (in > 9.99f) {
lights[CH1_WARN_LIGHT + c].value = 1.0f;
lights[CH1_WARN_LIGHT + c].setBrightness(1.0f);
}
else {
lights[CH1_WARN_LIGHT + c].value = 0.0f;
lights[CH1_WARN_LIGHT + c].setBrightness(0.0f);
}
float shape = 0.0f;
float delta = in - out[c];
Expand Down Expand Up @@ -115,7 +125,7 @@ struct AMDecoder : Module {
outputs[CH1_TRIGGER_OUTPUT + c].setVoltage( 0.0f);
}
}
lights[CH1_ACTIVITY_LIGHT + c].value = out[c] / 10.0;
lights[CH1_ACTIVITY_LIGHT + c].setBrightness(out[c] / 10.0f);

} //for (int c = 0; c < 2; c++)
}
Expand Down
12 changes: 8 additions & 4 deletions src/AMEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ struct AMEncoder : Module {
AMEncoder() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(CARRIER_LEVEL_PARAM, 0.0, 1.0, 1.0, "Carrier signal volume");
configLight(CH1_WARN_LIGHT, "IN 1 above +10V warning light");
configLight(CH2_WARN_LIGHT, "IN 2 above +10V warning light");
configInput(CH1_CV_INPUT, "IN 1");
configInput(CH2_CV_INPUT, "IN 2");
configOutput(CH1_SIGNAL_OUTPUT, "OUT 1");
configOutput(CH2_SIGNAL_OUTPUT, "OUT 1");
}

void process(const ProcessArgs& args) override {
Expand All @@ -52,8 +58,8 @@ struct AMEncoder : Module {
processChannel(carrier, inputs[CH1_CV_INPUT], outputs[CH1_SIGNAL_OUTPUT]);
processChannel(carrier, inputs[CH2_CV_INPUT], outputs[CH2_SIGNAL_OUTPUT]);

lights[CH1_WARN_LIGHT].value = clamp(inputs[CH1_CV_INPUT].getVoltage() / 10.0f * -1.0f, 0.0f, 1.0f);
lights[CH2_WARN_LIGHT].value = clamp(inputs[CH2_CV_INPUT].getVoltage() / 10.0f * -1.0f, 0.0f, 1.0f);
lights[CH1_WARN_LIGHT].setBrightness(clamp(inputs[CH1_CV_INPUT].getVoltage() / 10.0f * -1.0f, 0.0f, 1.0f));
lights[CH2_WARN_LIGHT].setBrightness(clamp(inputs[CH2_CV_INPUT].getVoltage() / 10.0f * -1.0f, 0.0f, 1.0f));
}

static void processChannel(float in, Input &lin, Output &out) {
Expand All @@ -72,9 +78,7 @@ struct AMEncoderWidget : ModuleWidget {
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/AMEncoder.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(createParam<NocturnalWhiteKnob>(Vec(12.25,316.125), module, AMEncoder::CARRIER_LEVEL_PARAM));

Expand Down
2 changes: 0 additions & 2 deletions src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ void init(Plugin* p) {
p->addModel(modelAMDecoder);
p->addModel(modelAMEncoder);

// 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.
}
1 change: 1 addition & 0 deletions src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct NocturnalWhiteKnob : RoundKnob {
}

virtual std::string formatCurrentValue() {
ParamQuantity* paramQuantity = getParamQuantity();
if(paramQuantity != NULL){
return std::to_string(static_cast<unsigned int>(paramQuantity->getValue()));
}
Expand Down

0 comments on commit 7008233

Please sign in to comment.