Skip to content

Commit

Permalink
[lv2] Quick fix for allowing calf plug-ins to run
Browse files Browse the repository at this point in the history
They want to have the connections made before showing the ui

Fixes #1319
  • Loading branch information
jcelerier committed Nov 23, 2021
1 parent c798143 commit fdbee35
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ static void setup_x11()
#endif
}

static void setup_suil()
{
#if defined(__linux__)
enum SuilArg { SUIL_ARG_NONE };
using suil_init_t = void (*)(int* argc, char*** argv, SuilArg key, ...);

if(auto lib = dlopen("libsuil-0.so.0", RTLD_LAZY | RTLD_LOCAL))
if(auto sym = reinterpret_cast<suil_init_t>(dlsym(lib, "suil_init")))
{
static int argc{0};
static char** argv{nullptr};
sym(&argc, &argv, SUIL_ARG_NONE);
}
#endif
}

static void setup_gdk()
{
#if defined(__linux__)
Expand Down Expand Up @@ -311,6 +327,7 @@ int main(int argc, char** argv)
#endif

setup_limits();
setup_suil();
setup_x11();
setup_gdk();
disable_denormals();
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/score-plugin-lv2/LV2/ApplicationPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ ApplicationPlugin::ApplicationPlugin(const score::ApplicationContext& app)
lv2_context->features(),
lilv}
{
static int argc{0};
static char** argv{nullptr};
suil_init(&argc, &argv, SUIL_ARG_NONE);

if (qEnvironmentVariableIsEmpty("SCORE_DISABLE_AUDIOPLUGINS"))
if (qEnvironmentVariableIsEmpty("SCORE_DISABLE_LV2"))
lv2_context->loadPlugins();
Expand Down
22 changes: 18 additions & 4 deletions src/plugins/score-plugin-lv2/LV2/EffectModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,16 @@ void Model::readPlugin()
auto& app_plug
= score::AppComponents().applicationPlugin<LV2::ApplicationPlugin>();
auto& h = app_plug.lv2_host_context;
ossia::float_vector fInControls, fOutControls, fParamMin, fParamMax,
fParamInit, fOtherControls;
ossia::float_vector fParamMin, fParamMax, fParamInit, fOtherControls;

LV2Data data{h, effectContext};

const std::size_t audio_in_size = data.audio_in_ports.size();
const std::size_t audio_out_size = data.audio_out_ports.size();
/*

const std::size_t in_size = data.control_in_ports.size();
const std::size_t out_size = data.control_out_ports.size();
const std::size_t midi_in_size = data.midi_in_ports.size();
/*const std::size_t midi_in_size = data.midi_in_ports.size();
const std::size_t midi_out_size = data.midi_out_ports.size();
*/
const std::size_t cv_size = data.cv_ports.size();
Expand Down Expand Up @@ -468,6 +467,21 @@ void Model::readPlugin()

effectContext.data.data_access
= lilv_instance_get_descriptor(effectContext.instance)->extension_data;

fInControls.resize(in_size);
fOutControls.resize(out_size);

auto fInstance = effectContext.instance;
for (std::size_t i = 0; i < in_size; i++)
{
lilv_instance_connect_port(fInstance, data.control_in_ports[i], &fInControls[i]);
}

for (std::size_t i = 0; i < out_size; i++)
{
lilv_instance_connect_port(
fInstance, data.control_out_ports[i], &fOutControls[i]);
}
}

void Model::reload()
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/score-plugin-lv2/LV2/EffectModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class Model : public Process::ProcessModel
void reload();
QString m_effectPath;
void readPlugin();

ossia::float_vector fInControls, fOutControls;
};

class LV2EffectComponent final
Expand Down

0 comments on commit fdbee35

Please sign in to comment.