(First plugin in Carla rack can be controlled for now)pull/88/head
| @@ -77,10 +77,10 @@ | |||
| ] | |||
| }, | |||
| { | |||
| "slug": "IldaeilExpIn8", | |||
| "slug": "CardinalExpIn8", | |||
| "disabled": false, | |||
| "name": "Ildaeil Expander Inputs 8", | |||
| "description": "Expander to add 8 parameters CV inputs to Ildaeil", | |||
| "name": "Cardinal Expander Inputs 8", | |||
| "description": "Expander to add 8 parameters CV inputs to Cardinal's plugin hosts", | |||
| "tags": [ | |||
| "Expander" | |||
| ] | |||
| @@ -1,13 +1,25 @@ | |||
| //Expander module for Ildaeil | |||
| //Expander module for Cardinal's plugin hosts | |||
| // | |||
| //Based on code from GateSeq64 and GateSeq64Expander by Marc Boulé | |||
| //Adapted for Ildaeil by Simon-L | |||
| #include "plugin.hpp" | |||
| #include "expanders.hpp" | |||
| static const unsigned int ildaeil_expanderRefreshStepSkips = 4; | |||
| struct IldaeilExpIn8 : Module { | |||
| struct CardinalExpIn8 : CardinalExpander, Module { | |||
| void sendExpMessage() { | |||
| for (int i = 0; i < NUM_INPUTS; i++) { | |||
| float *messageToBase = (float*)rightExpander.module->leftExpander.producerMessage; | |||
| messageToBase[i] = (inputs[i].isConnected() ? inputs[i].getVoltage() : 0.0); | |||
| } | |||
| rightExpander.module->leftExpander.messageFlipRequested = true; | |||
| } | |||
| void processExpMessage() {} | |||
| enum InputIds { | |||
| PARAM1_INPUT, | |||
| PARAM2_INPUT, | |||
| @@ -20,12 +32,8 @@ struct IldaeilExpIn8 : Module { | |||
| NUM_INPUTS | |||
| }; | |||
| // Expander | |||
| float rightMessages[2][2] = {};// messages from Ildaeil | |||
| unsigned int expanderRefreshCounter = 0; | |||
| IldaeilExpIn8() { | |||
| CardinalExpIn8() { | |||
| config(0, NUM_INPUTS, 0, 0); | |||
| rightExpander.producerMessage = rightMessages[0]; | |||
| @@ -42,25 +50,20 @@ struct IldaeilExpIn8 : Module { | |||
| } | |||
| 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() : 0.0); | |||
| } | |||
| rightExpander.module->leftExpander.messageFlipRequested = true; | |||
| bool basePresent = (rightExpander.module && isCardinalExpandable(rightExpander.module)); | |||
| if (basePresent) { | |||
| sendExpMessage(); | |||
| } | |||
| }// process() | |||
| }; | |||
| struct IldaeilExpIn8Widget : ModuleWidget { | |||
| IldaeilExpIn8Widget(IldaeilExpIn8 *module) { | |||
| struct CardinalExpIn8Widget : ModuleWidget { | |||
| CardinalExpIn8Widget(CardinalExpIn8 *module) { | |||
| setModule(module); | |||
| setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/IldaeilExpIn8.svg"))); | |||
| setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CardinalExpIn8.svg"))); | |||
| box.size = Vec(RACK_GRID_WIDTH * 2, RACK_GRID_HEIGHT); | |||
| // Screws | |||
| @@ -70,16 +73,16 @@ struct IldaeilExpIn8Widget : ModuleWidget { | |||
| 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)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 75), module, CardinalExpIn8::PARAM1_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 105), module, CardinalExpIn8::PARAM2_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 135), module, CardinalExpIn8::PARAM3_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 165), module, CardinalExpIn8::PARAM4_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 195), module, CardinalExpIn8::PARAM5_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 225), module, CardinalExpIn8::PARAM6_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 255), module, CardinalExpIn8::PARAM7_INPUT)); | |||
| addInput(createInput<PJ301MPort>(Vec(3, 54 + 285), module, CardinalExpIn8::PARAM8_INPUT)); | |||
| } | |||
| }; | |||
| Model *modelIldaeilExpIn8 = createModel<IldaeilExpIn8, IldaeilExpIn8Widget>("IldaeilExpIn8"); | |||
| Model *modelCardinalExpIn8 = createModel<CardinalExpIn8, CardinalExpIn8Widget>("CardinalExpIn8"); | |||
| @@ -16,6 +16,7 @@ | |||
| */ | |||
| #include "plugincontext.hpp" | |||
| #include "expanders.hpp" | |||
| #include "CarlaNativePlugin.h" | |||
| #include "CarlaBackendUtils.hpp" | |||
| @@ -54,7 +55,7 @@ static intptr_t host_dispatcher(NativeHostHandle handle, NativeHostDispatcherOpc | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| struct CarlaModule : Module { | |||
| struct CarlaModule : Module, CardinalExpander { | |||
| enum ParamIds { | |||
| BIPOLAR_INPUTS, | |||
| BIPOLAR_OUTPUTS, | |||
| @@ -123,6 +124,8 @@ struct CarlaModule : Module { | |||
| std::memset(dataOut, 0, sizeof(dataOut)); | |||
| setupExpanding(this); | |||
| fCarlaPluginDescriptor = carla_get_native_patchbay_cv8_plugin(); | |||
| DISTRHO_SAFE_ASSERT_RETURN(fCarlaPluginDescriptor != nullptr,); | |||
| @@ -259,11 +262,34 @@ struct CarlaModule : Module { | |||
| patchStorage = getPatchStorageDirectory(); | |||
| } | |||
| void sendExpMessage() {} | |||
| void processExpMessage() { | |||
| // Unimplemented | |||
| float *messagesFromExpander = (float*)leftExpander.consumerMessage; | |||
| if (carla_get_current_plugin_count(fCarlaHostHandle)) { | |||
| const uint32_t pcount = carla_get_parameter_count(fCarlaHostHandle, 0); | |||
| for (uint i = 0; i < 8; i++) { | |||
| if (i < pcount && leftExpander.module->inputs[i].isConnected()) { | |||
| const ::ParameterRanges* const pranges = carla_get_parameter_ranges(fCarlaHostHandle, 0, i); | |||
| float scaled_param = (messagesFromExpander[i] + 10.0) * (pranges->max - pranges->min) / (20.0 + pranges->min); | |||
| carla_set_parameter_value(fCarlaHostHandle, 0, i, scaled_param); | |||
| fCarlaHostDescriptor.ui_parameter_changed(this, i, scaled_param); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| void process(const ProcessArgs& args) override | |||
| { | |||
| if (fCarlaPluginHandle == nullptr) | |||
| return; | |||
| bool expanderPresent = (leftExpander.module && isCardinalExpander(leftExpander.module)); | |||
| if (expanderPresent) { | |||
| processExpMessage(); | |||
| } | |||
| const float inputOffset = params[BIPOLAR_INPUTS].getValue() > 0.1f ? -5.0f : 0.0f; | |||
| const float outputOffset = params[BIPOLAR_OUTPUTS].getValue() > 0.1f ? -5.0f : 0.0f; | |||
| @@ -26,6 +26,7 @@ | |||
| */ | |||
| #include "plugincontext.hpp" | |||
| #include "expanders.hpp" | |||
| #ifndef HEADLESS | |||
| # include "ImGuiWidget.hpp" | |||
| @@ -220,7 +221,7 @@ struct JuceInitializer { | |||
| }; | |||
| #endif | |||
| struct IldaeilModule : Module { | |||
| struct IldaeilModule : CardinalExpander, Module { | |||
| enum ParamIds { | |||
| NUM_PARAMS | |||
| }; | |||
| @@ -244,8 +245,22 @@ struct IldaeilModule : Module { | |||
| NUM_LIGHTS | |||
| }; | |||
| // Expander | |||
| float leftMessages[2][8] = {};// messages from expander | |||
| void sendExpMessage() {} | |||
| void processExpMessage() { | |||
| float *messagesFromExpander = (float*)leftExpander.consumerMessage; | |||
| if (carla_get_current_plugin_count(fCarlaHostHandle)) { | |||
| const uint32_t pcount = carla_get_parameter_count(fCarlaHostHandle, 0); | |||
| for (uint i = 0; i < 8; i++) { | |||
| if (i < pcount && leftExpander.module->inputs[i].isConnected()) { | |||
| const ::ParameterRanges* const pranges = carla_get_parameter_ranges(fCarlaHostHandle, 0, i); | |||
| float scaled_param = (messagesFromExpander[i] + 10.0) * (pranges->max - pranges->min) / (20.0 + pranges->min); | |||
| carla_set_parameter_value(fCarlaHostHandle, 0, i, scaled_param); | |||
| fCarlaHostDescriptor.ui_parameter_changed(this, i, scaled_param); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| #ifndef HEADLESS | |||
| SharedResourcePointer<JuceInitializer> juceInitializer; | |||
| @@ -277,14 +292,6 @@ struct IldaeilModule : Module { | |||
| { | |||
| config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); | |||
| leftExpander.producerMessage = leftMessages[0]; | |||
| leftExpander.consumerMessage = leftMessages[1]; | |||
| for (uint i = 0; i < 8; ++i) | |||
| { | |||
| leftMessages[1][i] = 0.0; | |||
| } | |||
| for (uint i=0; i<2; ++i) | |||
| { | |||
| const char name[] = { 'A','u','d','i','o',' ','#',static_cast<char>('0'+i+1),'\0' }; | |||
| @@ -301,6 +308,8 @@ struct IldaeilModule : Module { | |||
| std::memset(audioDataOut1, 0, sizeof(audioDataOut1)); | |||
| std::memset(audioDataOut2, 0, sizeof(audioDataOut2)); | |||
| setupExpanding(this); | |||
| fCarlaPluginDescriptor = carla_get_native_rack_plugin(); | |||
| DISTRHO_SAFE_ASSERT_RETURN(fCarlaPluginDescriptor != nullptr,); | |||
| @@ -444,18 +453,10 @@ struct IldaeilModule : Module { | |||
| if (fCarlaPluginHandle == nullptr) | |||
| return; | |||
| bool expanderPresent = (leftExpander.module && leftExpander.module->model == modelIldaeilExpIn8); | |||
| float *messagesFromExpander = (float*)leftExpander.consumerMessage;// could be invalid pointer when !expanderPresent, so read it only when expanderPresent | |||
| bool expanderPresent = (leftExpander.module && isCardinalExpander(leftExpander.module)); | |||
| if (expanderPresent) { | |||
| const uint32_t pcount = carla_get_parameter_count(fCarlaHostHandle, 0); | |||
| for (uint i = 0; i < 8; i++) { | |||
| if (i < pcount && leftExpander.module->inputs[i].isConnected()) { | |||
| const ::ParameterRanges* const pranges = carla_get_parameter_ranges(fCarlaHostHandle, 0, i); | |||
| float scaled_param = (messagesFromExpander[i] + 10.0) * (pranges->max - pranges->min) / (20.0 + pranges->min); | |||
| carla_set_parameter_value(fCarlaHostHandle, 0, i, scaled_param); | |||
| fCarlaHostDescriptor.ui_parameter_changed(this, i, scaled_param); | |||
| } | |||
| } | |||
| // d_stdout("hm?"); | |||
| processExpMessage(); | |||
| } | |||
| const unsigned i = audioDataFill++; | |||
| @@ -1395,7 +1396,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { | |||
| } | |||
| else | |||
| { | |||
| bool expanderPresent = (module->leftExpander.module && module->leftExpander.module->model == modelIldaeilExpIn8); | |||
| bool expanderPresent = (module->leftExpander.module && module->isCardinalExpander(module->leftExpander.module)); | |||
| const bool disabled = expanderPresent && (i < 8) && (module->leftExpander.module->inputs[i].isConnected()); | |||
| if (disabled) | |||
| ImGui::BeginDisabled(); | |||
| @@ -0,0 +1,21 @@ | |||
| struct CardinalExpander | |||
| { | |||
| CardinalExpander(){ | |||
| }; | |||
| ~CardinalExpander(){}; | |||
| bool isCardinalExpandable(Module *x) { return x->model == modelIldaeil || x->model == modelCarla; }; | |||
| bool isCardinalExpander(Module *x) { return x->model == modelCardinalExpIn8; }; | |||
| virtual void sendExpMessage() = 0; | |||
| virtual void processExpMessage() = 0; | |||
| float rightMessages[2][8] = {}; // messages from right-side | |||
| float leftMessages[2][8] = {};// messages from left-side | |||
| void setupExpanding(Module *module) { | |||
| module->leftExpander.producerMessage = leftMessages[0]; | |||
| module->leftExpander.consumerMessage = leftMessages[1]; | |||
| } | |||
| }; | |||
| @@ -34,4 +34,4 @@ extern Model* modelHostCV; | |||
| extern Model* modelHostParameters; | |||
| extern Model* modelHostTime; | |||
| extern Model* modelIldaeil; | |||
| extern Model* modelIldaeilExpIn8; | |||
| extern Model* modelCardinalExpIn8; | |||
| @@ -186,7 +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 | |||
| PLUGIN_FILES += Cardinal/src/CardinalExpIn8.cpp | |||
| ifneq ($(HEADLESS),true) | |||
| PLUGIN_FILES += Cardinal/src/ImGuiWidget.cpp | |||
| @@ -647,7 +647,7 @@ static void initStatic__Cardinal() | |||
| p->addModel(modelHostParameters); | |||
| p->addModel(modelHostTime); | |||
| p->addModel(modelIldaeil); | |||
| p->addModel(modelIldaeilExpIn8); | |||
| p->addModel(modelCardinalExpIn8); | |||
| } | |||
| } | |||