Make Host CV work for mini variant, hide unused jacks
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
919e21703b
commit
45022608ab
4 changed files with 140 additions and 56 deletions
|
@ -313,19 +313,23 @@ struct HostAudio8 : HostAudio<8> {
|
|||
template<int numIO>
|
||||
struct HostAudioWidget : ModuleWidgetWith8HP {
|
||||
HostAudio<numIO>* const module;
|
||||
CardinalPluginContext* const pcontext;
|
||||
|
||||
HostAudioWidget(HostAudio<numIO>* const m)
|
||||
: module(m)
|
||||
: module(m),
|
||||
pcontext(static_cast<CardinalPluginContext*>(APP))
|
||||
{
|
||||
setModule(m);
|
||||
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostAudio.svg")));
|
||||
|
||||
createAndAddScrews();
|
||||
|
||||
const uint8_t ioCount = pcontext->variant == kCardinalVariantMain ? 8 : 2;
|
||||
|
||||
for (uint i=0; i<numIO; ++i)
|
||||
{
|
||||
createAndAddInput(i);
|
||||
createAndAddOutput(i);
|
||||
createAndAddInput(i, i, i<ioCount);
|
||||
createAndAddOutput(i, i, i<ioCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,11 +399,13 @@ struct HostAudioWidget8 : HostAudioWidget<8> {
|
|||
|
||||
void draw(const DrawArgs& args) override
|
||||
{
|
||||
const uint8_t ioCount = pcontext->variant == kCardinalVariantMain ? 8 : 2;
|
||||
|
||||
drawBackground(args.vg);
|
||||
drawOutputJacksArea(args.vg, 8);
|
||||
drawOutputJacksArea(args.vg, ioCount);
|
||||
setupTextLines(args.vg);
|
||||
|
||||
for (int i=0; i<8; ++i)
|
||||
for (int i=0; i<ioCount; ++i)
|
||||
{
|
||||
char text[] = {'A','u','d','i','o',' ',static_cast<char>('0'+i+1),'\0'};
|
||||
drawTextLine(args.vg, i, text);
|
||||
|
|
|
@ -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);
|
||||
outputs[i].setVoltage(dataIns[i+ioOffset][k] - outputOffset);
|
||||
|
||||
outputOffset = params[BIPOLAR_OUTPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f;
|
||||
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+CARDINAL_AUDIO_IO_OFFSET][k] - outputOffset);
|
||||
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());}
|
||||
));
|
||||
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 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", "",
|
||||
[=]() {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 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 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 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());}
|
||||
));
|
||||
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
|
||||
|
|
|
@ -37,16 +37,20 @@ struct ModuleWidgetWithSideScrews : ModuleWidget {
|
|||
createAndAddInput(paramId, paramId);
|
||||
}
|
||||
|
||||
void createAndAddInput(const uint posY, const uint paramId) {
|
||||
addInput(createInput<PJ301MPort>(Vec(startX_In, startY + padding * posY), module, paramId));
|
||||
void createAndAddInput(const uint posY, const uint paramId, bool visible = true) {
|
||||
PortWidget* const widget = createInput<PJ301MPort>(Vec(startX_In, startY + padding * posY), module, paramId);
|
||||
widget->visible = visible;
|
||||
addInput(widget);
|
||||
}
|
||||
|
||||
void createAndAddOutput(const uint paramId) {
|
||||
createAndAddOutput(paramId, paramId);
|
||||
}
|
||||
|
||||
void createAndAddOutput(const uint posY, const uint paramId) {
|
||||
addOutput(createOutput<PJ301MPort>(Vec(startX_Out, startY + padding * posY), module, paramId));
|
||||
void createAndAddOutput(const uint posY, const uint paramId, bool visible = true) {
|
||||
PortWidget* const widget = createOutput<PJ301MPort>(Vec(startX_Out, startY + padding * posY), module, paramId);
|
||||
widget->visible = visible;
|
||||
addOutput(widget);
|
||||
}
|
||||
|
||||
void createAndAddScrews() {
|
||||
|
|
|
@ -375,7 +375,11 @@ public:
|
|||
context->dataOuts = new float*[DISTRHO_PLUGIN_NUM_OUTPUTS];
|
||||
|
||||
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_INPUTS;++i)
|
||||
*const_cast<float**>(&context->dataIns[i]) = new float[1];
|
||||
{
|
||||
float** const bufferptr = const_cast<float**>(&context->dataIns[i]);
|
||||
*bufferptr = new float[1];
|
||||
(*bufferptr)[0] = 0.f;
|
||||
}
|
||||
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS;++i)
|
||||
context->dataOuts[i] = new float[1];
|
||||
|
||||
|
@ -619,6 +623,8 @@ public:
|
|||
#if CARDINAL_VARIANT_MINI
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS;++i)
|
||||
context->dataOuts[i][0] = 0.f;
|
||||
++context->processCounter;
|
||||
context->engine->stepBlock(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue