|
|
|
@@ -18,8 +18,6 @@ |
|
|
|
#include "plugincontext.hpp" |
|
|
|
#include "ModuleWidgets.hpp" |
|
|
|
|
|
|
|
#define CARDINAL_AUDIO_IO_OFFSET 8 |
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
USE_NAMESPACE_DISTRHO; |
|
|
|
@@ -54,17 +52,28 @@ struct HostCV : TerminalModule { |
|
|
|
throw rack::Exception("Plugin context is null"); |
|
|
|
|
|
|
|
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_INPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Inputs 1-5")->randomizeEnabled = false; |
|
|
|
|
|
|
|
if (pcontext->variant == kCardinalVariantMini) |
|
|
|
{ |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_INPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Inputs")->randomizeEnabled = false; |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_OUTPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Outputs")->randomizeEnabled = false; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_INPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Inputs 1-5")->randomizeEnabled = false; |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_OUTPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Outputs 1-5")->randomizeEnabled = false; |
|
|
|
} |
|
|
|
|
|
|
|
configParam<SwitchQuantity>(BIPOLAR_INPUTS_6_10, 0.f, 1.f, 0.f, "Bipolar Inputs 6-10")->randomizeEnabled = false; |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_OUTPUTS_1_5, 0.f, 1.f, 0.f, "Bipolar Outputs 1-5")->randomizeEnabled = false; |
|
|
|
configParam<SwitchQuantity>(BIPOLAR_OUTPUTS_6_10, 0.f, 1.f, 0.f, "Bipolar Outputs 6-10")->randomizeEnabled = false; |
|
|
|
} |
|
|
|
|
|
|
|
void processTerminalInput(const ProcessArgs&) override |
|
|
|
{ |
|
|
|
if (pcontext->variant != kCardinalVariantMain) |
|
|
|
if (pcontext->variant != kCardinalVariantMain && pcontext->variant != kCardinalVariantMini) |
|
|
|
return; |
|
|
|
|
|
|
|
const uint8_t ioOffset = pcontext->variant == kCardinalVariantMini ? 2 : 8; |
|
|
|
const uint32_t bufferSize = pcontext->bufferSize; |
|
|
|
const uint32_t processCounter = pcontext->processCounter; |
|
|
|
|
|
|
|
@@ -87,27 +96,38 @@ struct HostCV : TerminalModule { |
|
|
|
} |
|
|
|
else if (const float* const* const dataIns = pcontext->dataIns) |
|
|
|
{ |
|
|
|
if (dataIns[CARDINAL_AUDIO_IO_OFFSET] == nullptr) |
|
|
|
if (dataIns[ioOffset] == nullptr) |
|
|
|
return; |
|
|
|
|
|
|
|
float outputOffset; |
|
|
|
outputOffset = params[BIPOLAR_OUTPUTS_1_5].getValue() > 0.1f ? 5.0f : 0.0f; |
|
|
|
outputOffset = params[BIPOLAR_OUTPUTS_1_5].getValue() > 0.1f ? 5.f : 0.f; |
|
|
|
|
|
|
|
for (int i=0; i<5; ++i) |
|
|
|
outputs[i].setVoltage(dataIns[i+CARDINAL_AUDIO_IO_OFFSET][k] - outputOffset); |
|
|
|
|
|
|
|
outputOffset = params[BIPOLAR_OUTPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f; |
|
|
|
|
|
|
|
for (int i=5; i<10; ++i) |
|
|
|
outputs[i].setVoltage(dataIns[i+CARDINAL_AUDIO_IO_OFFSET][k] - outputOffset); |
|
|
|
outputs[i].setVoltage(dataIns[i+ioOffset][k] - outputOffset); |
|
|
|
|
|
|
|
if (pcontext->variant == kCardinalVariantMain) |
|
|
|
{ |
|
|
|
outputOffset = params[BIPOLAR_OUTPUTS_6_10].getValue() > 0.1f ? 5.f : 0.f; |
|
|
|
|
|
|
|
for (int i=5; i<10; ++i) |
|
|
|
outputs[i].setVoltage(dataIns[i+ioOffset][k] - outputOffset); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
for (int i=5; i<10; ++i) |
|
|
|
outputs[i].setVoltage(0.f); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void processTerminalOutput(const ProcessArgs&) override |
|
|
|
{ |
|
|
|
if (pcontext->variant != kCardinalVariantMain || pcontext->bypassed) |
|
|
|
if (pcontext->variant != kCardinalVariantMain && pcontext->variant != kCardinalVariantMini) |
|
|
|
return; |
|
|
|
if (pcontext->bypassed) |
|
|
|
return; |
|
|
|
|
|
|
|
const uint8_t ioOffset = pcontext->variant == kCardinalVariantMini ? 2 : 8; |
|
|
|
const uint32_t bufferSize = pcontext->bufferSize; |
|
|
|
|
|
|
|
// only incremented on output |
|
|
|
@@ -119,54 +139,87 @@ struct HostCV : TerminalModule { |
|
|
|
|
|
|
|
float** const dataOuts = pcontext->dataOuts; |
|
|
|
|
|
|
|
if (dataOuts[CARDINAL_AUDIO_IO_OFFSET] == nullptr) |
|
|
|
if (dataOuts[ioOffset] == nullptr) |
|
|
|
return; |
|
|
|
|
|
|
|
float inputOffset; |
|
|
|
inputOffset = params[BIPOLAR_INPUTS_1_5].getValue() > 0.1f ? 5.0f : 0.0f; |
|
|
|
|
|
|
|
for (int i=0; i<5; ++i) |
|
|
|
dataOuts[i+CARDINAL_AUDIO_IO_OFFSET][k] += inputs[i].getVoltage() + inputOffset; |
|
|
|
dataOuts[i+ioOffset][k] += inputs[i].getVoltage() + inputOffset; |
|
|
|
|
|
|
|
inputOffset = params[BIPOLAR_INPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f; |
|
|
|
if (pcontext->variant == kCardinalVariantMain) |
|
|
|
{ |
|
|
|
inputOffset = params[BIPOLAR_INPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f; |
|
|
|
|
|
|
|
for (int i=5; i<10; ++i) |
|
|
|
dataOuts[i+CARDINAL_AUDIO_IO_OFFSET][k] += inputs[i].getVoltage() + inputOffset; |
|
|
|
for (int i=5; i<10; ++i) |
|
|
|
dataOuts[i+ioOffset][k] += inputs[i].getVoltage() + inputOffset; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
#ifndef HEADLESS |
|
|
|
struct HostCVWidget : ModuleWidgetWith8HP { |
|
|
|
CardinalPluginContext* const pcontext; |
|
|
|
|
|
|
|
HostCVWidget(HostCV* const module) |
|
|
|
: pcontext(static_cast<CardinalPluginContext*>(APP)) |
|
|
|
{ |
|
|
|
setModule(module); |
|
|
|
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostCV.svg"))); |
|
|
|
|
|
|
|
createAndAddScrews(); |
|
|
|
|
|
|
|
uint8_t maxVisible; |
|
|
|
switch (pcontext->variant) |
|
|
|
{ |
|
|
|
case kCardinalVariantMain: |
|
|
|
maxVisible = HostCV::NUM_INPUTS; |
|
|
|
break; |
|
|
|
case kCardinalVariantMini: |
|
|
|
maxVisible = 5; |
|
|
|
break; |
|
|
|
default: |
|
|
|
maxVisible = 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
for (uint i=0; i<HostCV::NUM_INPUTS; ++i) |
|
|
|
createAndAddInput(i); |
|
|
|
createAndAddInput(i, i, i<maxVisible); |
|
|
|
|
|
|
|
for (uint i=0; i<HostCV::NUM_OUTPUTS; ++i) |
|
|
|
createAndAddOutput(i); |
|
|
|
createAndAddOutput(i, i, i<maxVisible); |
|
|
|
} |
|
|
|
|
|
|
|
void draw(const DrawArgs& args) override |
|
|
|
{ |
|
|
|
drawBackground(args.vg); |
|
|
|
drawOutputJacksArea(args.vg, HostCV::NUM_INPUTS); |
|
|
|
|
|
|
|
if (pcontext->variant != kCardinalVariantMain && pcontext->variant != kCardinalVariantMini) |
|
|
|
return; |
|
|
|
|
|
|
|
drawOutputJacksArea(args.vg, pcontext->variant == kCardinalVariantMini ? 5 : HostCV::NUM_INPUTS); |
|
|
|
setupTextLines(args.vg); |
|
|
|
|
|
|
|
drawTextLine(args.vg, 0, "CV 1"); |
|
|
|
drawTextLine(args.vg, 1, "CV 2"); |
|
|
|
drawTextLine(args.vg, 2, "CV 3"); |
|
|
|
drawTextLine(args.vg, 3, "CV 4"); |
|
|
|
drawTextLine(args.vg, 4, "CV 5"); |
|
|
|
drawTextLine(args.vg, 5, "CV 6"); |
|
|
|
drawTextLine(args.vg, 6, "CV 7"); |
|
|
|
drawTextLine(args.vg, 7, "CV 8"); |
|
|
|
drawTextLine(args.vg, 8, "CV 9"); |
|
|
|
drawTextLine(args.vg, 9, "CV 10"); |
|
|
|
switch (pcontext->variant) |
|
|
|
{ |
|
|
|
case kCardinalVariantMain: |
|
|
|
drawTextLine(args.vg, 5, "CV 6"); |
|
|
|
drawTextLine(args.vg, 6, "CV 7"); |
|
|
|
drawTextLine(args.vg, 7, "CV 8"); |
|
|
|
drawTextLine(args.vg, 8, "CV 9"); |
|
|
|
drawTextLine(args.vg, 9, "CV 10"); |
|
|
|
// fall through |
|
|
|
case kCardinalVariantMini: |
|
|
|
drawTextLine(args.vg, 0, "CV 1"); |
|
|
|
drawTextLine(args.vg, 1, "CV 2"); |
|
|
|
drawTextLine(args.vg, 2, "CV 3"); |
|
|
|
drawTextLine(args.vg, 3, "CV 4"); |
|
|
|
drawTextLine(args.vg, 4, "CV 5"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
ModuleWidgetWith8HP::draw(args); |
|
|
|
} |
|
|
|
@@ -175,25 +228,40 @@ struct HostCVWidget : ModuleWidgetWith8HP { |
|
|
|
{ |
|
|
|
menu->addChild(new ui::MenuSeparator); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Inputs 1-5", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_INPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Inputs 6-10", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_INPUTS_6_10].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_INPUTS_6_10].setValue(1.0f - module->params[HostCV::BIPOLAR_INPUTS_6_10].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Outputs 1-5", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_OUTPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Outputs 6-10", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_OUTPUTS_6_10].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_OUTPUTS_6_10].setValue(1.0f - module->params[HostCV::BIPOLAR_OUTPUTS_6_10].getValue());} |
|
|
|
)); |
|
|
|
if (pcontext->variant == kCardinalVariantMini) |
|
|
|
{ |
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Inputs", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_INPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Outputs", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_OUTPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Inputs 1-5", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_INPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_INPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Inputs 6-10", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_INPUTS_6_10].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_INPUTS_6_10].setValue(1.0f - module->params[HostCV::BIPOLAR_INPUTS_6_10].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Outputs 1-5", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_OUTPUTS_1_5].setValue(1.0f - module->params[HostCV::BIPOLAR_OUTPUTS_1_5].getValue());} |
|
|
|
)); |
|
|
|
|
|
|
|
menu->addChild(createCheckMenuItem("Bipolar Outputs 6-10", "", |
|
|
|
[=]() {return module->params[HostCV::BIPOLAR_OUTPUTS_6_10].getValue() > 0.1f;}, |
|
|
|
[=]() {module->params[HostCV::BIPOLAR_OUTPUTS_6_10].setValue(1.0f - module->params[HostCV::BIPOLAR_OUTPUTS_6_10].getValue());} |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
#else |
|
|
|
|