37 static void init(
unsigned int samplingFreq,
PluginDef *plugin);
38 static void mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
39 static void to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
40 static void stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin);
42 static int registerparam(
const ParamReg& reg);
43 static int uiloader(
const UiBuilder& builder,
int form);
44 static void del_instance(
PluginDef *plugin);
50 Glib::ustring name_str;
51 Glib::ustring dest_str;
54 void connect(
int tp,
int i,
float *v);
55 inline void cleanup();
59 inline void mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0);
60 inline void stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1);
61 inline void down_to_mono(
int count,
float *input0,
float *input1,
float *output0);
62 inline void up_to_stereo(
int count,
float *input0,
float *output0,
float *output1);
63 std::string make_id(
const paradesc& p);
73 handle = dlopen(plug->
path.c_str(), RTLD_LOCAL|RTLD_NOW);
75 gx_print_error(
"ladspaloader",ustring::compose(_(
"Cannot open plugin: %1 [%2]"), plug->
path, dlerror()));
79 const char *dlsym_error = dlerror();
81 gx_print_error(
"ladspaloader",ustring::compose(_(
"Cannot load symbol 'ladspa_descriptor': %1"), dlsym_error));
88 for (
int i = 0; ; i++) {
99 gx_print_error(
"ladspaloader",ustring::compose(_(
"Cannot load ladspa descriptor #%1 from %2"), plug->
index, plug->
path));
112 for (
unsigned int i = 0; i < desc->
PortCount; ++i) {
122 bool to_mono =
false;
123 if (num_inputs == 1 && num_outputs == 1) {
125 }
else if (num_inputs == 2 && num_outputs == 2) {
130 "ladspaloader",ustring::compose(
131 _(
"cannot use ladspa plugin %1 with %2 inputs and %3 outputs"),
132 desc->
Label, num_inputs, num_outputs));
139 PluginDef& pl = *static_cast<PluginDef*>(
self);
145 :
PluginDef(), desc(desc_), handle(handle_), instance(),
146 ports(new
LADSPA_Data[desc->PortCount]), name_str(), dest_str(), pd(plug), is_activated(false) {
150 dest_str =
"LADSPA ";
151 dest_str += desc->
Name;
153 dest_str += desc->
Maker;
170 inline void LadspaDsp::cleanup() {
173 activate(
true,
this);
175 activate(
false,
this);
197 std::vector<std::string> v;
228 jw.
write(p->value_id);
229 jw.
write(p->value_label);
284 for (std::vector<paradesc*>::iterator i =
names.begin(); i !=
names.end(); ++i) {
291 plugdesc::~plugdesc() {
292 for (std::vector<paradesc*>::const_iterator it =
names.begin(); it !=
names.end(); ++it) {
297 LadspaDsp::~LadspaDsp() {
306 LadspaDsp&
self = *static_cast<LadspaDsp*>(plugin);
307 if (
start ==
self.is_activated) {
310 self.is_activated =
start;
313 self.desc->activate(
self.instance);
317 self.desc->deactivate(
self.instance);
323 void LadspaDsp::connect(
int tp,
int i,
float *v) {
324 for (
unsigned int n = 0; n < desc->
PortCount; ++n) {
346 void LadspaDsp::set_shortname() {
350 name_str = desc->
Name;
351 if (name_str.size() > 15) {
358 void LadspaDsp::init(
unsigned int samplingFreq,
PluginDef *plugin) {
359 LadspaDsp&
self = *static_cast<LadspaDsp*>(plugin);
361 if (samplingFreq == 0) {
364 self.instance =
self.desc->instantiate(
self.desc, samplingFreq);
366 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
367 self.desc->connect_port(
self.instance, (*it)->index, &
self.ports[(*it)->index]);
371 inline void LadspaDsp::mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0)
373 double fSlow0 = (0.01 * dry_wet);
374 double fSlow1 = (1 - fSlow0);
375 for (
int i=0; i<count; i++) {
376 output0[i] = ((fSlow0 * (double)input1[i]) + (fSlow1 * (double)input0[i]));
380 void LadspaDsp::mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
381 LadspaDsp&
self = *static_cast<LadspaDsp*>(plugin);
382 assert(
self.is_activated);
384 float wet_out[count];
387 self.desc->run(
self.instance, count);
388 self.mono_dry_wet(count, input, wet_out, output);
392 self.desc->run(
self.instance, count);
396 void LadspaDsp::up_to_stereo(
int count,
float *input0,
float *output0,
float *output1) {
397 memcpy(output0, input0, count *
sizeof(
float));
398 memcpy(output1, input0, count *
sizeof(
float));
401 void LadspaDsp::down_to_mono(
int count,
float *input0,
float *input1,
float *output0) {
402 for (
int i=0; i<count; i++) {
403 output0[i] = 0.5 * (input0[i] + input1[i]);
407 void LadspaDsp::to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
408 LadspaDsp&
self = *static_cast<LadspaDsp*>(plugin);
409 assert(
self.is_activated);
411 float wet_out[count];
413 float inputs1[count];
414 float outputs[count];
415 float outputs1[count];
416 self.up_to_stereo(count,input,inputs, inputs1);
421 self.desc->run(
self.instance, count);
422 self.down_to_mono(count,outputs,outputs1,wet_out);
423 self.mono_dry_wet(count, input, wet_out, output);
426 float inputs1[count];
427 float outputs[count];
428 float outputs1[count];
429 self.up_to_stereo(count,input,inputs, inputs1);
434 self.desc->run(
self.instance, count);
435 self.down_to_mono(count,outputs,outputs1,output);
439 inline void LadspaDsp::stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1)
441 double fSlow0 = (0.01 * dry_wet);
442 double fSlow1 = (1 - fSlow0);
443 for (
int i=0; i<count; i++) {
444 output0[i] = ((fSlow0 * (double)input2[i]) + (fSlow1 * (double)input0[i]));
445 output1[i] = ((fSlow0 * (double)input3[i]) + (fSlow1 * (double)input1[i]));
449 void LadspaDsp::stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin) {
450 LadspaDsp&
self = *static_cast<LadspaDsp*>(plugin);
451 assert(
self.is_activated);
453 float wet_out1[count];
454 float wet_out2[count];
459 self.desc->run(
self.instance, count);
460 self.stereo_dry_wet(count, input1, input2, wet_out1, wet_out2, output1, output2);
466 self.desc->run(
self.instance, count);
470 static Glib::ustring TrimLabel(
const char *label,
int cnt_in_row) {
471 const size_t minlen = 60 / cnt_in_row - 1;
472 const size_t maxlen = minlen + 10;
473 const size_t cutlen = (maxlen + minlen) / 2;
474 Glib::ustring pn(label);
475 size_t rem = pn.find_first_of(
"([");
476 if(rem != Glib::ustring::npos) {
479 while ((rem = pn.find_last_of(
" ")) == pn.size()-1) {
486 rem1 = pn.find_first_of(
" ", rem1);
487 if (rem1 == Glib::ustring::npos) {
490 while (rem1 > rem + minlen) {
493 pn.replace(lastpos, 1, 1,
'\n');
494 }
else if (rem1 < rem + maxlen) {
495 if (rem1 == pn.size()) {
499 pn.replace(rem1, 1, 1,
'\n');
502 pn.insert(rem,
"\n");
508 if (rem1 >= pn.size()) {
515 static Glib::ustring TrimEffectLabel(
const char *label,
int cnt_in_row) {
516 const size_t minlen = 60 / cnt_in_row - 1;
517 const size_t maxlen = minlen + 10;
518 const size_t cutlen = (maxlen + minlen) / 2;
519 Glib::ustring pn(label);
524 rem1 = pn.find_first_of(
" ", rem1);
525 if (rem1 == Glib::ustring::npos) {
528 while (rem1 > rem + minlen) {
531 pn.replace(lastpos, 1, 1,
'\n');
532 }
else if (rem1 < rem + maxlen) {
533 if (rem1 == pn.size()) {
537 pn.replace(rem1, 1, 1,
'\n');
540 pn.insert(rem,
"\n");
546 if (rem1 >= pn.size()) {
553 std::string LadspaDsp::make_id(
const paradesc& p) {
557 int LadspaDsp::registerparam(
const ParamReg& reg) {
558 LadspaDsp&
self = *static_cast<LadspaDsp*>(reg.
plugin);
562 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
568 std::vector<paradesc*>::const_iterator it2 = it+1;
569 while (it2 !=
self.pd->
names.end() && !(*it2)->newrow) {
578 const char *nm =
self.desc->PortNames[d->index];
579 Glib::ustring snm(d->name);
580 if (snm.empty() && d->tp !=
tp_none) {
581 snm = TrimLabel(nm, cnt_in_row);
584 reg.
registerEnumVar(
self.make_id(*d).c_str(), snm.c_str(),
"S", nm, d->values, &
self.ports[d->index],
585 d->dflt, d->low, d->up, d->step);
590 case tp_int: tp =
"S";
break;
597 default: assert(
false);
599 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(), tp, nm, &
self.ports[d->index],
600 d->dflt, d->low, d->up, d->step);
603 self.idd =
self.pd->id_str +
".dry_wet";
604 reg.
registerVar(
self.idd.c_str(),
"",
"S",
"dry/wet",&
self.dry_wet, 100, 0, 100, 1);
608 int LadspaDsp::uiloader(
const UiBuilder& b,
int form) {
612 LadspaDsp&
self = *static_cast<LadspaDsp*>(b.
plugin);
616 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
617 if ((n)==
self.pd->master_idx) {
623 const char *p =
self.pd->master_label.c_str();
635 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
649 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
652 if ( (rows == 1) || ( rows > 1 && row > 0 )) {
660 const char *p1 =
self.desc->PortNames[(*it)->index];
661 if (!(*it)->name.empty())
662 p1 = (*it)->name.c_str();
663 Glib::ustring trim = TrimEffectLabel(p1, 4);
664 const char *p = trim.c_str();
665 std::string
id =
self.make_id(**it);
666 if ((row == 1 && rows == 1 ) || (row >1 && rows >1 )) {
672 if (!(*it)->has_caption) {
678 if ((*it)->has_caption) {
685 if ((*it)->has_caption) {
692 if (!(*it)->has_caption) {
698 if ((*it)->has_caption) {
705 if (!(*it)->has_caption) {
708 if (((*it)->up - (*it)->low)<200) {
715 if ((*it)->has_caption) {
735 void LadspaDsp::del_instance(
PluginDef *plugin) {
736 delete static_cast<LadspaDsp*>(plugin);
744 static const int32_t min_block_length = 1;
745 static const int32_t max_block_length = 8192;
748 static std::vector<std::string> gx_uri_mapping = {
753 LV2_BUF_SIZE__maxBlockLength,
754 LV2_BUF_SIZE__minBlockLength,
758 LV2_Options_Option LV2Features::gx_options[2] = {
759 { LV2_OPTIONS_INSTANCE, 0, lv2_urid_map(NULL,LV2_BUF_SIZE__minBlockLength),
760 sizeof(int32_t), lv2_urid_map(NULL,LV2_ATOM__Int), &min_block_length },
761 { LV2_OPTIONS_INSTANCE, 0, lv2_urid_map(NULL,LV2_BUF_SIZE__maxBlockLength),
762 sizeof(int32_t), lv2_urid_map(NULL,LV2_ATOM__Int), &max_block_length },
765 LV2_Feature LV2Features::gx_options_feature = {
766 LV2_OPTIONS__options, gx_options
769 LV2_URID LV2Features::lv2_urid_map(LV2_URID_Map_Handle,
const char*
const uri_) {
770 if (uri_ ==
nullptr || uri_[0] ==
'\0') {
774 const std::string uri(uri_);
777 for (
const std::string& uri2 : gx_uri_mapping)
786 gx_uri_mapping.push_back(uri);
794 LV2_Feature LV2Features::gx_urid_map_feature = {
795 LV2_URID__map, &gx_urid_map
798 uint32_t LV2Features::lv2_uri_to_id(LV2_URI_Map_Callback_Data handle,
const char*,
const char* uri) {
799 return lv2_urid_map(handle, uri);
802 LV2_URI_Map_Feature LV2Features::gx_uri_map = {
806 LV2_Feature LV2Features::gx_uri_map_feature = {
807 LV2_URI_MAP_URI, &gx_uri_map
810 const char* LV2Features::lv2_urid_unmap(LV2_URID_Unmap_Handle,
const LV2_URID urid) {
811 if (urid == 0 || urid >= gx_uri_mapping.size())
814 return gx_uri_mapping[urid-1].c_str();
821 LV2_Feature LV2Features::gx_urid_unmap_feature = {
822 LV2_URID__unmap, &gx_urid_unmap
826 &gx_urid_map_feature,
828 &gx_urid_unmap_feature,
839 static void init(
unsigned int samplingFreq,
PluginDef *plugin);
840 static void mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
841 static void to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
842 static void stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin);
844 static int registerparam(
const ParamReg& reg);
845 static int uiloader(
const UiBuilder& builder,
int form);
846 static void del_instance(
PluginDef *plugin);
849 const LilvPlugin* plugin;
851 LilvInstance* instance;
853 Glib::ustring name_str;
854 Glib::ustring dest_str;
857 void connect(
const LilvNode* tp,
int i,
float *v);
858 inline void cleanup();
859 void set_shortname();
863 inline void mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0);
864 inline void stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1);
865 inline void down_to_mono(
int count,
float *input0,
float *input1,
float *output0);
866 inline void up_to_stereo(
int count,
float *input0,
float *output0,
float *output1);
867 std::string make_id(
const paradesc& p);
876 LilvNode* plugin_uri = lilv_new_uri(loader.world, plug->
path.c_str());
877 const LilvPlugin* plugin = lilv_plugins_get_by_uri(loader.lv2_plugins, plugin_uri);
878 lilv_node_free(plugin_uri);
880 gx_print_error(
"lv2loader",ustring::compose(_(
"Cannot open LV2 plugin: %1"), plug->
path));
884 int num_inputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_InputPort, 0);
885 int num_outputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_OutputPort, 0);
886 int num_controls = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_ControlPort, 0);
889 bool to_mono =
false;
890 if (num_inputs == 1 && num_outputs == 1) {
892 }
else if (num_inputs == 2 && num_outputs == 2) {
896 LilvNode *nm = lilv_plugin_get_name(plugin);
898 "lv2loader",ustring::compose(
899 _(
"cannot use LV2 plugin %1 with %2 inputs and %3 outputs"),
900 lilv_node_as_string(nm), num_inputs, num_outputs));
904 Lv2Dsp*
self =
new Lv2Dsp(plug, plugin, loader, mono, to_mono);
905 int desk_controls = 0;
906 for (std::vector<paradesc*>::const_iterator it = self->pd->names.begin(); it !=
self->pd->names.end(); ++it, ++desk_controls) ;
907 if (num_controls != desk_controls) {
908 LilvNode *nm = lilv_plugin_get_name(plugin);
910 "lv2loader",ustring::compose(
911 _(
"LV2 plugin %1 has changed it's ports, this may result in errors!!\nPlease go to the LADSPA/LV2 loader and select %1\nSelect 'Show Details' and press 'Restore Defaults'\nUn-load %1 (un-tick the box) and press 'save'.\nAfter this you could re-load %1 with it's new ports"),
912 lilv_node_as_string(nm)));
915 PluginDef& pl = *static_cast<PluginDef*>(
self);
920 Lv2Dsp::Lv2Dsp(
const plugdesc *plug,
const LilvPlugin* plugin_,
const LadspaLoader& loader_,
bool mono,
bool to_mono)
921 :
PluginDef(), loader(loader_), plugin(plugin_), name_node(lilv_plugin_get_name(plugin_)), instance(),
922 ports(new
LADSPA_Data[lilv_plugin_get_num_ports(plugin_)]), name_str(), dest_str(), pd(plug), is_activated(false) {
927 dest_str += lilv_node_as_string(name_node);
928 LilvNode *nd = lilv_plugin_get_author_name(plugin);
930 nd = lilv_plugin_get_project(plugin);
934 dest_str += lilv_node_as_string(nd);
938 name = lilv_node_as_string(name_node);
953 inline void Lv2Dsp::cleanup() {
956 activate(
true,
this);
958 activate(
false,
this);
960 lilv_instance_free(instance);
969 lilv_node_free(name_node);
973 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(plugin);
974 if (
start ==
self.is_activated) {
977 if (!
self.instance) {
981 self.is_activated =
start;
983 lilv_instance_activate(
self.instance);
985 lilv_instance_deactivate(
self.instance);
990 void Lv2Dsp::connect(
const LilvNode* tp,
int i,
float *v) {
991 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
992 for (
unsigned int n = 0; n < num_ports; ++n) {
993 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
994 if (!lilv_port_is_a(plugin, port, loader.lv2_AudioPort)) {
997 if (lilv_port_is_a(plugin, port, tp)) {
999 lilv_instance_connect_port(instance, n, v);
1015 void Lv2Dsp::set_shortname() {
1019 name_str = lilv_node_as_string(name_node);
1020 if (name_str.size() > 15) {
1028 void Lv2Dsp::init(
unsigned int samplingFreq,
PluginDef *pldef) {
1029 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(pldef);
1031 if (samplingFreq == 0) {
1035 if (!
self.instance) {
1040 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1041 lilv_instance_connect_port(
self.instance, (*it)->index, &
self.ports[(*it)->index]);
1045 inline void Lv2Dsp::mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0)
1047 double fSlow0 = (0.01 * dry_wet);
1048 double fSlow1 = (1 - fSlow0);
1049 for (
int i=0; i<count; i++) {
1050 output0[i] = ((fSlow0 * (double)input1[i]) + (fSlow1 * (double)input0[i]));
1054 void Lv2Dsp::mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
1055 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(plugin);
1056 assert(
self.is_activated);
1058 float wet_out[count];
1059 self.connect(
self.loader.lv2_InputPort, 0, input);
1060 self.connect(
self.loader.lv2_OutputPort, 0, wet_out);
1061 lilv_instance_run(
self.instance, count);
1062 self.mono_dry_wet(count, input, wet_out, output);
1064 self.connect(
self.loader.lv2_InputPort, 0, input);
1065 self.connect(
self.loader.lv2_OutputPort, 0, output);
1066 lilv_instance_run(
self.instance, count);
1070 void Lv2Dsp::up_to_stereo(
int count,
float *input0,
float *output0,
float *output1) {
1071 memcpy(output0, input0, count *
sizeof(
float));
1072 memcpy(output1, input0, count *
sizeof(
float));
1075 void Lv2Dsp::down_to_mono(
int count,
float *input0,
float *input1,
float *output0) {
1076 for (
int i=0; i<count; i++) {
1077 output0[i] = 0.5 * (input0[i] + input1[i]);
1081 void Lv2Dsp::to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
1082 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(plugin);
1083 assert(
self.is_activated);
1085 float wet_out[count];
1086 float inputs[count];
1087 float inputs1[count];
1088 float outputs[count];
1089 float outputs1[count];
1090 self.up_to_stereo(count,input,inputs, inputs1);
1091 self.connect(
self.loader.lv2_InputPort, 0, inputs);
1092 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
1093 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
1094 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
1095 lilv_instance_run(
self.instance, count);
1096 self.down_to_mono(count,outputs,outputs1,wet_out);
1097 self.mono_dry_wet(count, input, wet_out, output);
1099 float inputs[count];
1100 float inputs1[count];
1101 float outputs[count];
1102 float outputs1[count];
1103 self.up_to_stereo(count,input,inputs, inputs1);
1104 self.connect(
self.loader.lv2_InputPort, 0, inputs);
1105 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
1106 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
1107 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
1108 lilv_instance_run(
self.instance, count);
1109 self.down_to_mono(count,outputs,outputs1,output);
1113 inline void Lv2Dsp::stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1)
1115 double fSlow0 = (0.01 * dry_wet);
1116 double fSlow1 = (1 - fSlow0);
1117 for (
int i=0; i<count; i++) {
1118 output0[i] = ((fSlow0 * (double)input2[i]) + (fSlow1 * (double)input0[i]));
1119 output1[i] = ((fSlow0 * (double)input3[i]) + (fSlow1 * (double)input1[i]));
1123 void Lv2Dsp::stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin) {
1124 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(plugin);
1125 assert(
self.is_activated);
1127 float wet_out1[count];
1128 float wet_out2[count];
1129 self.connect(
self.loader.lv2_InputPort, 0, input1);
1130 self.connect(
self.loader.lv2_InputPort, 1, input2);
1131 self.connect(
self.loader.lv2_OutputPort, 0, wet_out1);
1132 self.connect(
self.loader.lv2_OutputPort, 1, wet_out2);
1133 lilv_instance_run(
self.instance, count);
1134 self.stereo_dry_wet(count, input1, input2, wet_out1, wet_out2, output1, output2);
1136 self.connect(
self.loader.lv2_InputPort, 0, input1);
1137 self.connect(
self.loader.lv2_InputPort, 1, input2);
1138 self.connect(
self.loader.lv2_OutputPort, 0, output1);
1139 self.connect(
self.loader.lv2_OutputPort, 1, output2);
1140 lilv_instance_run(
self.instance, count);
1144 std::string Lv2Dsp::make_id(
const paradesc& p) {
1148 void Lv2Dsp::set_enabled(
bool v,Parameter& p) {
1150 p.getFloat().set(1.0);
1152 p.getFloat().set(0.0);
1156 int Lv2Dsp::registerparam(
const ParamReg& reg) {
1157 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(reg.
plugin);
1161 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1162 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1163 if (n>=num_controls)
break;
1169 std::vector<paradesc*>::const_iterator it2 = it+1;
1170 while (it2 !=
self.pd->
names.end() && !(*it2)->newrow) {
1179 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, d->index);
1180 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1181 const char *nm = lilv_node_as_string(nm_node);
1182 Glib::ustring snm(d->name);
1183 if (snm.empty() && d->tp !=
tp_none) {
1184 snm = TrimLabel(nm, cnt_in_row);
1187 reg.
registerEnumVar(
self.make_id(*d).c_str(), snm.c_str(),
"S", nm, d->values, &
self.ports[d->index],
1188 d->dflt, d->low, d->up, d->step);
1190 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(),
"BA" , nm, &
self.ports[d->index],
1191 d->dflt, d->low, d->up, d->step);
1192 ParamMap& pmap =
self.loader.get_parameter_map();
1193 pmap[
self.pd->id_str +
".on_off"].signal_changed_bool().connect(
1194 sigc::bind(sigc::mem_fun(
self, &Lv2Dsp::set_enabled),sigc::ref(pmap[
self.make_id(*d)])));
1199 case tp_none: tp =
"S";
break;
1200 case tp_int: tp =
"S";
break;
1206 default: assert(
false);
1208 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(), tp, nm, &
self.ports[d->index],
1209 d->dflt, d->low, d->up, d->step);
1211 lilv_node_free(nm_node);
1213 self.idd =
self.pd->id_str +
".dry_wet";
1214 reg.
registerVar(
self.idd.c_str(),
"",
"S",
"dry/wet",&
self.dry_wet, 100, 0, 100, 1);
1218 int Lv2Dsp::uiloader(
const UiBuilder& b,
int form) {
1222 Lv2Dsp&
self = *static_cast<Lv2Dsp*>(b.
plugin);
1226 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1227 if ((n)==
self.pd->master_idx) {
1228 switch ((*it)->tp) {
1233 const char *p =
self.pd->master_label.c_str();
1248 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1249 if ((*it)->newrow) {
1255 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1256 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1257 if (n>=num_controls)
break;
1258 if ((*it)->newrow) {
1260 if ( (rows == 1) || ( rows > 1 && row > 0 )) {
1268 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, (*it)->index);
1269 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1270 const char *p1 = lilv_node_as_string(nm_node);
1271 if (!(*it)->name.empty())
1272 p1 = (*it)->name.c_str();
1273 Glib::ustring trim = TrimEffectLabel(p1, 4);
1274 const char *p = trim.c_str();
1275 std::string
id =
self.make_id(**it);
1276 if (num_controls<30) {
1277 if ((row == 1 && rows == 1 ) || (row >1 && rows >1 )) {
1280 }
else if (num_controls<35) {
1281 if ((row == 2 && rows == 2 ) || (row >2 && rows >2 )) {
1285 if ((row == 3 && rows == 3 ) || (row >3 && rows >3 )) {
1289 switch ((*it)->tp) {
1292 if (!(*it)->has_caption) {
1300 if ((*it)->has_caption) {
1307 if (!(*it)->has_caption) {
1313 if ((*it)->has_caption) {
1320 if (!(*it)->has_caption) {
1323 if (((*it)->up - (*it)->low)<200) {
1330 if ((*it)->has_caption) {
1341 lilv_node_free(nm_node);
1351 void Lv2Dsp::del_instance(
PluginDef *plugin) {
1352 delete static_cast<Lv2Dsp*>(plugin);
1369 : options(options_),
1371 world(lilv_world_new()),
1374 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1375 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1376 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1377 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)) {
1378 lilv_world_load_all(world);
1379 lv2_plugins = lilv_world_get_all_plugins(world);
1384 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1387 lilv_node_free(lv2_OutputPort);
1388 lilv_node_free(lv2_InputPort);
1389 lilv_node_free(lv2_ControlPort);
1390 lilv_node_free(lv2_AudioPort);
1391 lilv_world_free(world);
1396 read_module_list(ml);
1398 gx_print_error(
"ladspaloader",ustring::compose(_(
"Exception in LADSPA list reader: %1"), e.
what()));
1405 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1408 plugins = new_plugins;
1415 plugins = new_plugins;
1419 for (pluginarray::iterator i =
begin(); i !=
end(); ++i) {
1421 if ((*i)->path == desc->
path) {
1425 if ((*i)->UniqueID == desc->
UniqueID) {
1434 if (pdesc->quirks &
is_lv2) {
1435 static_cast<Lv2Dsp*>(pdef)->set_plugdesc(pdesc);
1437 static_cast<LadspaDsp*>(pdef)->set_plugdesc(pdesc);
1443 g_free(const_cast<char*>(p->value_id));
1451 for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i, ++n) {
1452 const char *p = g_strdup(i->c_str());
1460 void LadspaLoader::read_module_config(
const std::string& filename, plugdesc *p) {
1461 std::ifstream ifs(filename.c_str());
1463 gx_print_error(
"ladspaloader", ustring::compose(_(
"can't open %1"), filename));
1469 jp.current_value_int();
1471 p->shortname = jp.current_value();
1473 p->category = jp.current_value();
1475 p->master_idx = jp.current_value_int();
1477 p->master_label = jp.current_value();
1479 p->quirks = jp.current_value_int();
1481 p->add_wet_dry= jp.current_value_int();
1485 p->stereo_to_mono= jp.current_value_int();
1489 paradesc *para =
new paradesc;
1492 para->index = jp.current_value_int();
1495 para->name = jp.current_value();
1498 para->dflt = jp.current_value_float();
1500 para->low = jp.current_value_float();
1502 para->up = jp.current_value_float();
1504 para->step = jp.current_value_float();
1506 para->tp = static_cast<widget_type>(jp.current_value_int());
1508 para->newrow = jp.current_value_int();
1510 para->has_caption = jp.current_value_int();
1512 std::vector<std::string> v;
1515 v.push_back(jp.current_value());
1518 para->set_valuelist(v);
1520 p->names.push_back(para);
1527 void LadspaLoader::read_module_list(pluginarray& ml) {
1537 plugdesc *p =
new plugdesc;
1538 p->path = jp.current_value();
1540 int idx = jp.current_value_int();
1546 p->UniqueID = jp.current_value_int();
1548 p->Label = jp.current_value();
1557 if (access(fname.c_str(), F_OK) != 0) {
1559 if (access(fname.c_str(), F_OK) != 0) {
1563 if (!fname.empty()) {
1565 read_module_config(fname, p);
1567 gx_print_error(
"ladspaloader",ustring::compose(_(
"read error in file %1: %2"), s, e.
what()));
1570 if (p->quirks &
is_lv2) {
1573 p->id_str =
"ladspa_" +
to_string(p->UniqueID);