Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/Cardinal/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
"tags": [
"Utility"
]
},
{
"slug": "IldaeilExpIn8",
"disabled": false,
"name": "Ildaeil Expander Inputs 8",
"description": "Expander to add 8 parameters CV inputs to Ildaeil",
"tags": [
"Expander"
]
}
]
}
128 changes: 128 additions & 0 deletions plugins/Cardinal/res/IldaeilExpIn8.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions plugins/Cardinal/src/Ildaeil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ struct IldaeilModule : Module {
NUM_LIGHTS
};

// Expander
float leftMessages[2][8] = {};// messages from expander

#ifndef HEADLESS
SharedResourcePointer<JuceInitializer> juceInitializer;
#endif
Expand Down Expand Up @@ -273,6 +276,16 @@ struct IldaeilModule : Module {
: pcontext(static_cast<CardinalPluginContext*>(APP))
{
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);

leftExpander.producerMessage = leftMessages[0];
leftExpander.consumerMessage = leftMessages[1];

// must init those that have no-connect info to non-connected, or else mother may read 0.0 init value if ever refresh limiters make it such that after a connection of expander the mother reads before the first pass through the expander's writing code, and this may do something undesired (ex: change track in Foundry on expander connected while track CV jack is empty) (comment originally in GateSeq64 by Marc Boulé)
for (uint i = 0; i < 8; ++i)
{
leftMessages[1][i] = std::numeric_limits<float>::quiet_NaN();
}

for (uint i=0; i<2; ++i)
{
const char name[] = { 'A','u','d','i','o',' ','#',static_cast<char>('0'+i+1),'\0' };
Expand Down Expand Up @@ -1031,6 +1044,20 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
fileBrowserHandle = nullptr;
}

if (fPluginGenericUI != nullptr && module->fCarlaHostHandle != nullptr) {
bool expanderPresent = (module->leftExpander.module && module->leftExpander.module->model == modelIldaeilExpIn8);
float *messagesFromExpander = (float*)module->leftExpander.consumerMessage;// could be invalid pointer when !expanderPresent, so read it only when expanderPresent
if (expanderPresent) {
for (uint i = 0; i < 8; i++) {
if (i < fPluginGenericUI->parameterCount && module->leftExpander.module->inputs[i].isConnected()) {
float scaled_param = (messagesFromExpander[i] + 10.0) * (fPluginGenericUI->parameters[i].max - fPluginGenericUI->parameters[i].min) / (20.0 + fPluginGenericUI->parameters[i].min);
fPluginGenericUI->values[i] = scaled_param;
carla_set_parameter_value(module->fCarlaHostHandle, 0, 0, scaled_param);

@Simon-L Simon-L Dec 12, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@falkTX I'm unsure about that part, if there's a more elegant way. How does that look to you? From my test and understanding of this module, both ui->values[] and call to carla_set_parameter_value have to be updated to the new value in order to update both the DSP and the UI.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this should be done in a different way, I will handle it soon

}
}
}
}

if (fDrawingState == kDrawingPluginGenericUI && fPluginGenericUI != nullptr && fPluginHasOutputParameters)
{
updatePluginGenericUI(handle);
Expand Down
85 changes: 85 additions & 0 deletions plugins/Cardinal/src/IldaeilExpIn8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//Expander module for Ildaeil
//
//Based on code from GateSeq64 and GateSeq64Expander by Marc Boulé
//Adapted for Ildaeil by Simon-L

#include "plugin.hpp"

static const unsigned int ildaeil_expanderRefreshStepSkips = 4;

struct IldaeilExpIn8 : Module {
enum InputIds {
PARAM1_INPUT,
PARAM2_INPUT,
PARAM3_INPUT,
PARAM4_INPUT,
PARAM5_INPUT,
PARAM6_INPUT,
PARAM7_INPUT,
PARAM8_INPUT,
NUM_INPUTS
};

// Expander
float rightMessages[2][2] = {};// messages from Ildaeil

unsigned int expanderRefreshCounter = 0;

IldaeilExpIn8() {
config(0, NUM_INPUTS, 0, 0);

rightExpander.producerMessage = rightMessages[0];
rightExpander.consumerMessage = rightMessages[1];

configInput(PARAM1_INPUT, "Parameter 1");
configInput(PARAM2_INPUT, "Parameter 2");
configInput(PARAM3_INPUT, "Parameter 3");
configInput(PARAM4_INPUT, "Parameter 4");
configInput(PARAM5_INPUT, "Parameter 5");
configInput(PARAM6_INPUT, "Parameter 6");
configInput(PARAM7_INPUT, "Parameter 7");
configInput(PARAM8_INPUT, "Parameter 8");

}


void process(const ProcessArgs &args) override {
bool ildaeilPresent = (rightExpander.module && rightExpander.module->model == modelIldaeil);
if (ildaeilPresent) {
float *messagesToIldaeil = (float*)rightExpander.module->leftExpander.producerMessage;
for (int i = 0; i < NUM_INPUTS; i++) {
messagesToIldaeil[i] = (inputs[i].isConnected() ? inputs[i].getVoltage() : std::numeric_limits<float>::quiet_NaN());
}
rightExpander.module->leftExpander.messageFlipRequested = true;
}
}// process()
};


struct IldaeilExpIn8Widget : ModuleWidget {
IldaeilExpIn8Widget(IldaeilExpIn8 *module) {
setModule(module);

setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/IldaeilExpIn8.svg")));
box.size = Vec(RACK_GRID_WIDTH * 2, RACK_GRID_HEIGHT);

// Screws
addChild(createWidget<ScrewBlack>(Vec(0, 0)));
addChild(createWidget<ScrewBlack>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

// Inputs
addInput(createInput<PJ301MPort>(Vec(3, 54 + 75), module, IldaeilExpIn8::PARAM1_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 105), module, IldaeilExpIn8::PARAM2_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 135), module, IldaeilExpIn8::PARAM3_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 165), module, IldaeilExpIn8::PARAM4_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 195), module, IldaeilExpIn8::PARAM5_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 225), module, IldaeilExpIn8::PARAM6_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 255), module, IldaeilExpIn8::PARAM7_INPUT));
addInput(createInput<PJ301MPort>(Vec(3, 54 + 285), module, IldaeilExpIn8::PARAM8_INPUT));
}

};

Model *modelIldaeilExpIn8 = createModel<IldaeilExpIn8, IldaeilExpIn8Widget>("IldaeilExpIn8");
1 change: 1 addition & 0 deletions plugins/Cardinal/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ extern Model* modelHostCV;
extern Model* modelHostParameters;
extern Model* modelHostTime;
extern Model* modelIldaeil;
extern Model* modelIldaeilExpIn8;
1 change: 1 addition & 0 deletions plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ PLUGIN_FILES += Cardinal/src/HostCV.cpp
PLUGIN_FILES += Cardinal/src/HostParameters.cpp
PLUGIN_FILES += Cardinal/src/HostTime.cpp
PLUGIN_FILES += Cardinal/src/Ildaeil.cpp
PLUGIN_FILES += Cardinal/src/IldaeilExpIn8.cpp

ifneq ($(HEADLESS),true)
PLUGIN_FILES += Cardinal/src/ImGuiWidget.cpp
Expand Down
1 change: 1 addition & 0 deletions plugins/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ static void initStatic__Cardinal()
p->addModel(modelHostParameters);
p->addModel(modelHostTime);
p->addModel(modelIldaeil);
p->addModel(modelIldaeilExpIn8);
}
}

Expand Down