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));
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);
187 if (jp.
read_kv(
"index", index) ||
194 jp.
read_kv(
"newrow", newrow) ||
195 jp.
read_kv(
"has_caption", has_caption)) {
197 std::vector<std::string> v;
222 jw.
write_kv(
"has_caption", has_caption);
228 jw.
write(p->value_id);
229 jw.
write(p->value_label);
241 if (jp.
read_kv(
"path", path) ||
243 jp.
read_kv(
"UniqueID", UniqueID) ||
247 jp.
read_kv(
"quirks", quirks) ||
248 jp.
read_kv(
"add_wet_dry", add_wet_dry) ||
249 jp.
read_kv(
"stereo_to_mono", stereo_to_mono) ||
250 jp.
read_kv(
"master_idx", master_idx) ||
251 jp.
read_kv(
"master_label", master_label) ||
252 jp.
read_kv(
"id_str", id_str)) {
272 jw.
write_kv(
"UniqueID", static_cast<unsigned int>(UniqueID));
277 jw.
write_kv(
"add_wet_dry", add_wet_dry);
278 jw.
write_kv(
"stereo_to_mono", stereo_to_mono);
279 jw.
write_kv(
"master_idx", master_idx);
280 jw.
write_kv(
"master_label", master_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() {
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) {
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) {
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) {
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) {
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) {
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);
581 snm = TrimLabel(nm, cnt_in_row);
590 case tp_int: tp =
"S";
break;
596 default: assert(
false);
598 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(), tp, nm, &
self.ports[d->
index],
602 self.idd =
self.pd->id_str +
".dry_wet";
603 reg.
registerVar(
self.idd.c_str(),
"",
"S",
"dry/wet",&
self.dry_wet, 100, 0, 100, 1);
607 int LadspaDsp::uiloader(
const UiBuilder& b,
int form) {
615 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
616 if ((n)==
self.pd->master_idx) {
622 const char *p =
self.pd->master_label.c_str();
634 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
648 for (std::vector<paradesc*>::const_iterator it =
self.pd->
names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
651 if ( (rows == 1) || ( rows > 1 && row > 0 )) {
659 const char *p1 =
self.desc->PortNames[(*it)->index];
660 if (!(*it)->name.empty())
661 p1 = (*it)->name.c_str();
662 Glib::ustring trim = TrimEffectLabel(p1, 4);
663 const char *p = trim.c_str();
664 std::string
id =
self.make_id(**it);
665 if ((row == 1 && rows == 1 ) || (row >1 && rows >1 )) {
671 if (!(*it)->has_caption) {
677 if ((*it)->has_caption) {
684 if (!(*it)->has_caption) {
690 if ((*it)->has_caption) {
697 if (!(*it)->has_caption) {
700 if (((*it)->up - (*it)->low)<200) {
707 if ((*it)->has_caption) {
727 void LadspaDsp::del_instance(
PluginDef *plugin) {
736 static const int32_t min_block_length = 1;
737 static const int32_t max_block_length = 8192;
740 static std::vector<std::string> gx_uri_mapping = {
745 LV2_BUF_SIZE__maxBlockLength,
746 LV2_BUF_SIZE__minBlockLength,
750 LV2_Options_Option LV2Features::gx_options[2] = {
751 { LV2_OPTIONS_INSTANCE, 0, lv2_urid_map(NULL,LV2_BUF_SIZE__minBlockLength),
752 sizeof(int32_t), lv2_urid_map(NULL,LV2_ATOM__Int), &min_block_length },
753 { LV2_OPTIONS_INSTANCE, 0, lv2_urid_map(NULL,LV2_BUF_SIZE__maxBlockLength),
754 sizeof(int32_t), lv2_urid_map(NULL,LV2_ATOM__Int), &max_block_length },
757 LV2_Feature LV2Features::gx_options_feature = {
758 LV2_OPTIONS__options, gx_options
761 LV2_URID LV2Features::lv2_urid_map(LV2_URID_Map_Handle,
const char*
const uri_) {
762 if (uri_ ==
nullptr || uri_[0] ==
'\0') {
766 const std::string uri(uri_);
769 for (
const std::string& uri2 : gx_uri_mapping)
778 gx_uri_mapping.push_back(uri);
786 LV2_Feature LV2Features::gx_urid_map_feature = {
787 LV2_URID__map, &gx_urid_map
790 uint32_t LV2Features::lv2_uri_to_id(LV2_URI_Map_Callback_Data handle,
const char*,
const char* uri) {
791 return lv2_urid_map(handle, uri);
794 LV2_URI_Map_Feature LV2Features::gx_uri_map = {
798 LV2_Feature LV2Features::gx_uri_map_feature = {
799 LV2_URI_MAP_URI, &gx_uri_map
802 const char* LV2Features::lv2_urid_unmap(LV2_URID_Unmap_Handle,
const LV2_URID urid) {
803 if (urid == 0 || urid >= gx_uri_mapping.size())
806 return gx_uri_mapping[urid-1].c_str();
813 LV2_Feature LV2Features::gx_urid_unmap_feature = {
814 LV2_URID__unmap, &gx_urid_unmap
818 &gx_urid_map_feature,
820 &gx_urid_unmap_feature,
831 static void init(
unsigned int samplingFreq,
PluginDef *plugin);
832 static void mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
833 static void to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
834 static void stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin);
835 static int activate(
bool start,
PluginDef *plugin);
836 static int registerparam(
const ParamReg& reg);
838 static void del_instance(
PluginDef *plugin);
841 const LilvPlugin* plugin;
843 LilvInstance* instance;
845 Glib::ustring name_str;
846 Glib::ustring dest_str;
849 void connect(
const LilvNode* tp,
int i,
float *v);
850 inline void cleanup();
851 void set_shortname();
854 inline void mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0);
855 inline void stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1);
856 inline void down_to_mono(
int count,
float *input0,
float *input1,
float *output0);
857 inline void up_to_stereo(
int count,
float *input0,
float *output0,
float *output1);
858 std::string make_id(
const paradesc& p);
867 LilvNode* plugin_uri = lilv_new_uri(loader.world, plug->
path.c_str());
868 const LilvPlugin* plugin = lilv_plugins_get_by_uri(loader.lv2_plugins, plugin_uri);
869 lilv_node_free(plugin_uri);
871 gx_print_error(
"lv2loader",ustring::compose(_(
"Cannot open LV2 plugin: %1"), plug->
path));
875 int num_inputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_InputPort, 0);
876 int num_outputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_OutputPort, 0);
877 int num_controls = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_ControlPort, 0);
880 bool to_mono =
false;
881 if (num_inputs == 1 && num_outputs == 1) {
883 }
else if (num_inputs == 2 && num_outputs == 2) {
887 LilvNode *nm = lilv_plugin_get_name(plugin);
889 "lv2loader",ustring::compose(
890 _(
"cannot use LV2 plugin %1 with %2 inputs and %3 outputs"),
891 lilv_node_as_string(nm), num_inputs, num_outputs));
895 Lv2Dsp*
self =
new Lv2Dsp(plug, plugin, loader, mono, to_mono);
896 int desk_controls = 0;
897 for (std::vector<paradesc*>::const_iterator it = self->pd->names.begin(); it !=
self->pd->names.end(); ++it, ++desk_controls) ;
898 if (num_controls != desk_controls) {
899 LilvNode *nm = lilv_plugin_get_name(plugin);
901 "lv2loader",ustring::compose(
902 _(
"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"),
903 lilv_node_as_string(nm)));
911 Lv2Dsp::Lv2Dsp(
const plugdesc *plug,
const LilvPlugin* plugin_,
const LadspaLoader& loader_,
bool mono,
bool to_mono)
912 :
PluginDef(), loader(loader_), plugin(plugin_), name_node(lilv_plugin_get_name(plugin_)), instance(),
913 ports(
new LADSPA_Data[lilv_plugin_get_num_ports(plugin_)]), name_str(), dest_str(), pd(plug), is_activated(
false) {
915 id = pd->id_str.c_str();
918 dest_str += lilv_node_as_string(name_node);
919 LilvNode *nd = lilv_plugin_get_author_name(plugin);
921 nd = lilv_plugin_get_project(plugin);
925 dest_str += lilv_node_as_string(nd);
929 name = lilv_node_as_string(name_node);
944 inline void Lv2Dsp::cleanup() {
947 activate(
true,
this);
949 activate(
false,
this);
951 lilv_instance_free(instance);
960 lilv_node_free(name_node);
963 int Lv2Dsp::activate(
bool start,
PluginDef *plugin) {
965 if (start ==
self.is_activated) {
968 if (!
self.instance) {
972 self.is_activated =
start;
974 lilv_instance_activate(
self.instance);
976 lilv_instance_deactivate(
self.instance);
981 void Lv2Dsp::connect(
const LilvNode* tp,
int i,
float *v) {
982 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
983 for (
unsigned int n = 0; n < num_ports; ++n) {
984 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
985 if (!lilv_port_is_a(plugin, port, loader.lv2_AudioPort)) {
988 if (lilv_port_is_a(plugin, port, tp)) {
990 lilv_instance_connect_port(instance, n, v);
1006 void Lv2Dsp::set_shortname() {
1007 if (!pd->shortname.empty()) {
1010 name_str = lilv_node_as_string(name_node);
1011 if (name_str.size() > 15) {
1019 void Lv2Dsp::init(
unsigned int samplingFreq,
PluginDef *pldef) {
1022 if (samplingFreq == 0) {
1026 if (!
self.instance) {
1027 gx_print_error(
"Lv2Dsp", ustring::compose(
"cant init plugin: %1 \n uri: %2",
self.
name,
self.pd->path));
1031 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1032 lilv_instance_connect_port(
self.instance, (*it)->index, &
self.ports[(*it)->index]);
1036 inline void Lv2Dsp::mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0)
1038 double fSlow0 = (0.01 * dry_wet);
1039 double fSlow1 = (1 - fSlow0);
1040 for (
int i=0; i<count; i++) {
1041 output0[i] = ((fSlow0 * (double)input1[i]) + (fSlow1 * (double)input0[i]));
1045 void Lv2Dsp::mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
1047 assert(
self.is_activated);
1048 if (
self.pd->add_wet_dry) {
1049 float wet_out[count];
1050 self.connect(
self.loader.lv2_InputPort, 0, input);
1051 self.connect(
self.loader.lv2_OutputPort, 0, wet_out);
1052 lilv_instance_run(
self.instance, count);
1053 self.mono_dry_wet(count, input, wet_out, output);
1055 self.connect(
self.loader.lv2_InputPort, 0, input);
1056 self.connect(
self.loader.lv2_OutputPort, 0, output);
1057 lilv_instance_run(
self.instance, count);
1061 void Lv2Dsp::up_to_stereo(
int count,
float *input0,
float *output0,
float *output1) {
1062 memcpy(output0, input0, count *
sizeof(
float));
1063 memcpy(output1, input0, count *
sizeof(
float));
1066 void Lv2Dsp::down_to_mono(
int count,
float *input0,
float *input1,
float *output0) {
1067 for (
int i=0; i<count; i++) {
1068 output0[i] = 0.5 * (input0[i] + input1[i]);
1072 void Lv2Dsp::to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
1074 assert(
self.is_activated);
1075 if (
self.pd->add_wet_dry) {
1076 float wet_out[count];
1077 float inputs[count];
1078 float inputs1[count];
1079 float outputs[count];
1080 float outputs1[count];
1081 self.up_to_stereo(count,input,inputs, inputs1);
1082 self.connect(
self.loader.lv2_InputPort, 0, inputs);
1083 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
1084 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
1085 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
1086 lilv_instance_run(
self.instance, count);
1087 self.down_to_mono(count,outputs,outputs1,wet_out);
1088 self.mono_dry_wet(count, input, wet_out, output);
1090 float inputs[count];
1091 float inputs1[count];
1092 float outputs[count];
1093 float outputs1[count];
1094 self.up_to_stereo(count,input,inputs, inputs1);
1095 self.connect(
self.loader.lv2_InputPort, 0, inputs);
1096 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
1097 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
1098 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
1099 lilv_instance_run(
self.instance, count);
1100 self.down_to_mono(count,outputs,outputs1,output);
1104 inline void Lv2Dsp::stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1)
1106 double fSlow0 = (0.01 * dry_wet);
1107 double fSlow1 = (1 - fSlow0);
1108 for (
int i=0; i<count; i++) {
1109 output0[i] = ((fSlow0 * (double)input2[i]) + (fSlow1 * (double)input0[i]));
1110 output1[i] = ((fSlow0 * (double)input3[i]) + (fSlow1 * (double)input1[i]));
1114 void Lv2Dsp::stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin) {
1116 assert(
self.is_activated);
1117 if (
self.pd->add_wet_dry) {
1118 float wet_out1[count];
1119 float wet_out2[count];
1120 self.connect(
self.loader.lv2_InputPort, 0, input1);
1121 self.connect(
self.loader.lv2_InputPort, 1, input2);
1122 self.connect(
self.loader.lv2_OutputPort, 0, wet_out1);
1123 self.connect(
self.loader.lv2_OutputPort, 1, wet_out2);
1124 lilv_instance_run(
self.instance, count);
1125 self.stereo_dry_wet(count, input1, input2, wet_out1, wet_out2, output1, output2);
1127 self.connect(
self.loader.lv2_InputPort, 0, input1);
1128 self.connect(
self.loader.lv2_InputPort, 1, input2);
1129 self.connect(
self.loader.lv2_OutputPort, 0, output1);
1130 self.connect(
self.loader.lv2_OutputPort, 1, output2);
1131 lilv_instance_run(
self.instance, count);
1135 std::string Lv2Dsp::make_id(
const paradesc& p) {
1139 int Lv2Dsp::registerparam(
const ParamReg& reg) {
1144 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1145 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1146 if (n>=num_controls)
break;
1152 std::vector<paradesc*>::const_iterator it2 = it+1;
1153 while (it2 !=
self.pd->names.end() && !(*it2)->newrow) {
1162 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, d->
index);
1163 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1164 const char *nm = lilv_node_as_string(nm_node);
1165 Glib::ustring snm(d->
name);
1167 snm = TrimLabel(nm, cnt_in_row);
1175 case tp_none: tp =
"S";
break;
1176 case tp_int: tp =
"S";
break;
1182 default: assert(
false);
1184 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(), tp, nm, &
self.ports[d->
index],
1187 lilv_node_free(nm_node);
1189 self.idd =
self.pd->id_str +
".dry_wet";
1190 reg.
registerVar(
self.idd.c_str(),
"",
"S",
"dry/wet",&
self.dry_wet, 100, 0, 100, 1);
1194 int Lv2Dsp::uiloader(
const UiBuilder& b,
int form) {
1200 if (
self.pd->master_idx >= 0) {
1202 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1203 if ((n)==
self.pd->master_idx) {
1204 switch ((*it)->tp) {
1209 const char *p =
self.pd->master_label.c_str();
1224 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1225 if ((*it)->newrow) {
1231 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1232 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1233 if (n>=num_controls)
break;
1234 if ((*it)->newrow) {
1236 if ( (rows == 1) || ( rows > 1 && row > 0 )) {
1244 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, (*it)->index);
1245 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1246 const char *p1 = lilv_node_as_string(nm_node);
1247 if (!(*it)->name.empty())
1248 p1 = (*it)->name.c_str();
1249 Glib::ustring trim = TrimEffectLabel(p1, 4);
1250 const char *p = trim.c_str();
1251 std::string
id =
self.make_id(**it);
1252 if (num_controls<30) {
1253 if ((row == 1 && rows == 1 ) || (row >1 && rows >1 )) {
1256 }
else if (num_controls<35) {
1257 if ((row == 2 && rows == 2 ) || (row >2 && rows >2 )) {
1261 if ((row == 3 && rows == 3 ) || (row >3 && rows >3 )) {
1265 switch ((*it)->tp) {
1268 if (!(*it)->has_caption) {
1274 if ((*it)->has_caption) {
1281 if (!(*it)->has_caption) {
1287 if ((*it)->has_caption) {
1294 if (!(*it)->has_caption) {
1297 if (((*it)->up - (*it)->low)<200) {
1304 if ((*it)->has_caption) {
1315 lilv_node_free(nm_node);
1317 if (
self.pd->add_wet_dry) {
1325 void Lv2Dsp::del_instance(
PluginDef *plugin) {
1326 delete static_cast<Lv2Dsp*
>(plugin);
1343 : options(options_),
1345 world(lilv_world_new()),
1347 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1348 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1349 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1350 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)) {
1351 lilv_world_load_all(world);
1352 lv2_plugins = lilv_world_get_all_plugins(world);
1357 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1360 lilv_node_free(lv2_OutputPort);
1361 lilv_node_free(lv2_InputPort);
1362 lilv_node_free(lv2_ControlPort);
1363 lilv_node_free(lv2_AudioPort);
1364 lilv_world_free(world);
1369 read_module_list(ml);
1371 gx_print_error(
"ladspaloader",ustring::compose(_(
"Exception in LADSPA list reader: %1"), e.
what()));
1378 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1381 plugins = new_plugins;
1388 plugins = new_plugins;
1392 for (pluginarray::iterator i =
begin(); i !=
end(); ++i) {
1394 if ((*i)->path == desc->
path) {
1398 if ((*i)->UniqueID == desc->
UniqueID) {
1408 static_cast<Lv2Dsp*
>(pdef)->set_plugdesc(pdesc);
1410 static_cast<LadspaDsp*
>(pdef)->set_plugdesc(pdesc);
1415 for (
value_pair *p = values; p->value_id; ++p) {
1416 g_free(const_cast<char*>(p->value_id));
1424 for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i, ++n) {
1425 const char *p = g_strdup(i->c_str());
1426 values[n].value_id = p;
1427 values[n].value_label = p;
1429 values[n].value_id = 0;
1430 values[n].value_label = 0;
1433 void LadspaLoader::read_module_config(
const std::string& filename,
plugdesc *p) {
1434 std::ifstream ifs(filename.c_str());
1436 gx_print_error(
"ladspaloader", ustring::compose(_(
"can't open %1"), filename));
1485 std::vector<std::string> v;
1493 p->
names.push_back(para);
1500 void LadspaLoader::read_module_list(
pluginarray& ml) {
1530 if (access(fname.c_str(), F_OK) != 0) {
1532 if (access(fname.c_str(), F_OK) != 0) {
1536 if (!fname.empty()) {
1538 read_module_config(fname, p);
1540 gx_print_error(
"ladspaloader",ustring::compose(_(
"read error in file %1: %2"), s, e.
what()));
static LV2_URID_Unmap gx_urid_unmap
void write_kv(const char *key, float v)
CmdConnection::msg_type start
void begin_array(bool nl=false)
pluginarray::iterator end()
std::string get_factory_filepath(const std::string &basename) const
void(* cleanup)(LADSPA_Handle Instance)
void end_array(bool nl=false)
#define LADSPA_PORT_INPUT
void writeJSON(gx_system::JsonWriter &jw)
int(* uiloader)(const UiBuilder &builder, int format)
void set_plugins(pluginarray &new_plugins)
void set_plugdesc(const plugdesc *pd_)
LadspaLoader(const gx_system::CmdlineOptions &options)
std::vector< plugdesc * > pluginarray
void(* deactivate)(LADSPA_Handle Instance)
void set_plugdesc(const plugdesc *pd_)
float *(* registerVar)(const char *id, const char *name, const char *tp, const char *tooltip, float *var, float val, float low, float up, float step)
void(* create_switch_no_caption)(const char *sw_type, const char *id)
void(* registerEnumVar)(const char *id, const char *name, const char *tp, const char *tooltip, const value_pair *values, float *var, float val, float low, float up, float step)
pluginarray::iterator find(plugdesc *desc)
void write_key(const char *p, bool nl=false)
bool load(pluginarray &p)
void readJSON(gx_system::JsonParser &jp)
void(* activate)(LADSPA_Handle Instance)
deletefunc delete_instance
static LadspaDsp * create(const plugdesc *plug)
static Lv2Dsp * create(const plugdesc *plug, const LadspaLoader &loader)
void gx_print_error(const char *, const std::string &)
bool read_kv(const char *key, float &v)
void(* create_selector)(const char *id, const char *label)
PluginDef * create(unsigned int idx)
#define PLUGINDEF_VERSION
void(* openHorizontalBox)(const char *label)
registerfunc register_params
void(* create_port_display)(const char *id, const char *label)
std::string get_plugin_filepath(const std::string &basename) const
void begin_object(bool nl=false)
void(* create_small_rackknobr)(const char *id, const char *label)
static LV2_URID_Map gx_urid_map
Glib::ustring master_label
std::string to_string(const T &t)
virtual const char * what() const
void(* create_small_rackknob)(const char *id, const char *label)
std::vector< paradesc * > names
void gx_print_warning(const char *, const std::string &)
void(* openHorizontalhideBox)(const char *label)
#define LADSPA_IS_PORT_AUDIO(x)
activatefunc activate_plugin
static LV2Features & getInstance()
void(* create_spin_value)(const char *id, const char *label)
process_stereo_audio stereo_audio
std::string get_user_filepath(const std::string &basename) const
void update_instance(PluginDef *pdef, plugdesc *pdesc)
#define LADSPA_IS_PORT_INPUT(x)
pluginarray::iterator begin()
string current_value() const
void readJSON(gx_system::JsonParser &jp)
void(* set_next_flags)(int flags)
#define LADSPA_PORT_OUTPUT
void writeJSON(gx_system::JsonWriter &jw)
process_mono_audio mono_audio
void set_valuelist(const std::vector< std::string > &v)
static std::string get_ladspa_filename(unsigned long uid)
const LADSPA_Descriptor *(* LADSPA_Descriptor_Function)(unsigned long Index)
float current_value_float()
token next(token expect=no_token)
void write(float v, bool nl=false)
const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index)
void(* create_switch)(const char *sw_type, const char *id, const char *label)
void(* connect_port)(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data *DataLocation)
static LV2_Feature * gx_features[]
void change_plugins(pluginarray &new_plugins)
void(* create_master_slider)(const char *id, const char *label)
void end_object(bool nl=false)
void(* create_selector_no_caption)(const char *id)
void(* openVerticalBox)(const char *label)
const LADSPA_PortDescriptor * PortDescriptors
std::string encode_filename(const std::string &s)