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);
46 const LADSPA_Descriptor *desc;
48 LADSPA_Handle instance;
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);
64 LadspaDsp(
const plugdesc *plug,
void *handle_,
const LADSPA_Descriptor *desc_,
bool mono,
bool to_mono);
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()));
78 LADSPA_Descriptor_Function ladspa_descriptor = (LADSPA_Descriptor_Function)dlsym(handle,
"ladspa_descriptor");
79 const char *dlsym_error = dlerror();
81 gx_print_error(
"ladspaloader",ustring::compose(_(
"Cannot load symbol 'ladspa_descriptor': %1"), dlsym_error));
86 const LADSPA_Descriptor *desc = ladspa_descriptor(plug->
index);
87 if (!desc || desc->UniqueID != plug->
UniqueID) {
88 for (
int i = 0; ; i++) {
89 desc = ladspa_descriptor(i);
93 if (desc->UniqueID == plug->
UniqueID) {
99 gx_print_error(
"ladspaloader",ustring::compose(_(
"Cannot load ladspa descriptor #%1 from %2"), plug->
index, plug->
path));
104 if (desc->UniqueID == 4069 || desc->UniqueID == 4070) {
112 for (
unsigned int i = 0; i < desc->PortCount; ++i) {
113 if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i])) {
114 if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[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));
144 LadspaDsp::LadspaDsp(
const plugdesc *plug,
void *handle_,
const LADSPA_Descriptor *desc_,
bool mono,
bool to_mono)
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);
177 desc->cleanup(instance);
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;
312 if (
self.desc->activate) {
313 self.desc->activate(
self.instance);
316 if (
self.desc->deactivate) {
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) {
325 if (!LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[n])) {
328 if (desc->PortDescriptors[n] & tp) {
330 desc->connect_port(instance, n, v);
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];
385 self.connect(LADSPA_PORT_INPUT, 0, input);
386 self.connect(LADSPA_PORT_OUTPUT, 0, wet_out);
387 self.desc->run(
self.instance, count);
388 self.mono_dry_wet(count, input, wet_out, output);
390 self.connect(LADSPA_PORT_INPUT, 0, input);
391 self.connect(LADSPA_PORT_OUTPUT, 0, 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);
417 self.connect(LADSPA_PORT_INPUT, 0, inputs);
418 self.connect(LADSPA_PORT_INPUT, 1, inputs1);
419 self.connect(LADSPA_PORT_INPUT, 0, outputs);
420 self.connect(LADSPA_PORT_INPUT, 1, outputs1);
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);
430 self.connect(LADSPA_PORT_INPUT, 0, inputs);
431 self.connect(LADSPA_PORT_INPUT, 1, inputs1);
432 self.connect(LADSPA_PORT_INPUT, 0, outputs);
433 self.connect(LADSPA_PORT_INPUT, 1, outputs1);
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];
455 self.connect(LADSPA_PORT_INPUT, 0, input1);
456 self.connect(LADSPA_PORT_INPUT, 1, input2);
457 self.connect(LADSPA_PORT_OUTPUT, 0, wet_out1);
458 self.connect(LADSPA_PORT_OUTPUT, 1, wet_out2);
459 self.desc->run(
self.instance, count);
460 self.stereo_dry_wet(count, input1, input2, wet_out1, wet_out2, output1, output2);
462 self.connect(LADSPA_PORT_INPUT, 0, input1);
463 self.connect(LADSPA_PORT_INPUT, 1, input2);
464 self.connect(LADSPA_PORT_OUTPUT, 0, output1);
465 self.connect(LADSPA_PORT_OUTPUT, 1, 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) {
738 static void init(
unsigned int samplingFreq,
PluginDef *plugin);
739 static void mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
740 static void to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin);
741 static void stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin);
742 static int activate(
bool start,
PluginDef *plugin);
743 static int registerparam(
const ParamReg& reg);
745 static void del_instance(
PluginDef *plugin);
748 const LilvPlugin* plugin;
750 LilvInstance* instance;
752 Glib::ustring name_str;
753 Glib::ustring dest_str;
756 void connect(
const LilvNode* tp,
int i,
float *v);
757 inline void cleanup();
758 void set_shortname();
761 inline void mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0);
762 inline void stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1);
763 inline void down_to_mono(
int count,
float *input0,
float *input1,
float *output0);
764 inline void up_to_stereo(
int count,
float *input0,
float *output0,
float *output1);
765 std::string make_id(
const paradesc& p);
774 LilvNode* plugin_uri = lilv_new_uri(loader.world, plug->
path.c_str());
775 const LilvPlugin* plugin = lilv_plugins_get_by_uri(loader.lv2_plugins, plugin_uri);
776 lilv_node_free(plugin_uri);
778 gx_print_error(
"lv2loader",ustring::compose(_(
"Cannot open LV2 plugin: %1"), plug->
path));
782 int num_inputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_InputPort, 0);
783 int num_outputs = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_AudioPort, loader.lv2_OutputPort, 0);
784 int num_controls = lilv_plugin_get_num_ports_of_class(plugin, loader.lv2_ControlPort, 0);
787 bool to_mono =
false;
788 if (num_inputs == 1 && num_outputs == 1) {
790 }
else if (num_inputs == 2 && num_outputs == 2) {
794 LilvNode *nm = lilv_plugin_get_name(plugin);
796 "lv2loader",ustring::compose(
797 _(
"cannot use LV2 plugin %1 with %2 inputs and %3 outputs"),
798 lilv_node_as_string(nm), num_inputs, num_outputs));
802 Lv2Dsp*
self =
new Lv2Dsp(plug, plugin, loader, mono, to_mono);
803 int desk_controls = 0;
804 for (std::vector<paradesc*>::const_iterator it = self->pd->names.begin(); it !=
self->pd->names.end(); ++it, ++desk_controls) ;
805 if (num_controls != desk_controls) {
806 LilvNode *nm = lilv_plugin_get_name(plugin);
808 "lv2loader",ustring::compose(
809 _(
"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"),
810 lilv_node_as_string(nm)));
818 Lv2Dsp::Lv2Dsp(
const plugdesc *plug,
const LilvPlugin* plugin_,
const LadspaLoader& loader_,
bool mono,
bool to_mono)
819 :
PluginDef(), loader(loader_), plugin(plugin_), name_node(lilv_plugin_get_name(plugin_)), instance(),
820 ports(
new LADSPA_Data[lilv_plugin_get_num_ports(plugin_)]), name_str(), dest_str(), pd(plug), is_activated(
false) {
822 id = pd->id_str.c_str();
825 dest_str += lilv_node_as_string(name_node);
826 LilvNode *nd = lilv_plugin_get_author_name(plugin);
828 nd = lilv_plugin_get_project(plugin);
832 dest_str += lilv_node_as_string(nd);
836 name = lilv_node_as_string(name_node);
851 inline void Lv2Dsp::cleanup() {
854 activate(
true,
this);
856 activate(
false,
this);
858 lilv_instance_free(instance);
867 lilv_node_free(name_node);
870 int Lv2Dsp::activate(
bool start,
PluginDef *plugin) {
872 if (start ==
self.is_activated) {
875 if (!
self.instance) {
879 self.is_activated =
start;
881 lilv_instance_activate(
self.instance);
883 lilv_instance_deactivate(
self.instance);
888 void Lv2Dsp::connect(
const LilvNode* tp,
int i,
float *v) {
889 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
890 for (
unsigned int n = 0; n < num_ports; ++n) {
891 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
892 if (!lilv_port_is_a(plugin, port, loader.lv2_AudioPort)) {
895 if (lilv_port_is_a(plugin, port, tp)) {
897 lilv_instance_connect_port(instance, n, v);
913 void Lv2Dsp::set_shortname() {
914 if (!pd->shortname.empty()) {
917 name_str = lilv_node_as_string(name_node);
918 if (name_str.size() > 15) {
925 void Lv2Dsp::init(
unsigned int samplingFreq,
PluginDef *pldef) {
928 if (samplingFreq == 0) {
931 self.instance = lilv_plugin_instantiate(
self.plugin, samplingFreq, 0);
932 if (!
self.instance) {
933 gx_print_error(
"Lv2Dsp", ustring::compose(
"cant init plugin: %1 \n uri: %2",
self.
name,
self.pd->path));
937 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
938 lilv_instance_connect_port(
self.instance, (*it)->index, &
self.ports[(*it)->index]);
942 inline void Lv2Dsp::mono_dry_wet(
int count,
float *input0,
float *input1,
float *output0)
944 double fSlow0 = (0.01 * dry_wet);
945 double fSlow1 = (1 - fSlow0);
946 for (
int i=0; i<count; i++) {
947 output0[i] = ((fSlow0 * (double)input1[i]) + (fSlow1 * (double)input0[i]));
951 void Lv2Dsp::mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
953 assert(
self.is_activated);
954 if (
self.pd->add_wet_dry) {
955 float wet_out[count];
956 self.connect(
self.loader.lv2_InputPort, 0, input);
957 self.connect(
self.loader.lv2_OutputPort, 0, wet_out);
958 lilv_instance_run(
self.instance, count);
959 self.mono_dry_wet(count, input, wet_out, output);
961 self.connect(
self.loader.lv2_InputPort, 0, input);
962 self.connect(
self.loader.lv2_OutputPort, 0, output);
963 lilv_instance_run(
self.instance, count);
967 void Lv2Dsp::up_to_stereo(
int count,
float *input0,
float *output0,
float *output1) {
968 memcpy(output0, input0, count *
sizeof(
float));
969 memcpy(output1, input0, count *
sizeof(
float));
972 void Lv2Dsp::down_to_mono(
int count,
float *input0,
float *input1,
float *output0) {
973 for (
int i=0; i<count; i++) {
974 output0[i] = 0.5 * (input0[i] + input1[i]);
978 void Lv2Dsp::to_mono_process(
int count,
float *input,
float *output,
PluginDef *plugin) {
980 assert(
self.is_activated);
981 if (
self.pd->add_wet_dry) {
982 float wet_out[count];
984 float inputs1[count];
985 float outputs[count];
986 float outputs1[count];
987 self.up_to_stereo(count,input,inputs, inputs1);
988 self.connect(
self.loader.lv2_InputPort, 0, inputs);
989 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
990 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
991 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
992 lilv_instance_run(
self.instance, count);
993 self.down_to_mono(count,outputs,outputs1,wet_out);
994 self.mono_dry_wet(count, input, wet_out, output);
997 float inputs1[count];
998 float outputs[count];
999 float outputs1[count];
1000 self.up_to_stereo(count,input,inputs, inputs1);
1001 self.connect(
self.loader.lv2_InputPort, 0, inputs);
1002 self.connect(
self.loader.lv2_InputPort, 1, inputs1);
1003 self.connect(
self.loader.lv2_OutputPort, 0, outputs);
1004 self.connect(
self.loader.lv2_OutputPort, 1, outputs1);
1005 lilv_instance_run(
self.instance, count);
1006 self.down_to_mono(count,outputs,outputs1,output);
1010 inline void Lv2Dsp::stereo_dry_wet(
int count,
float *input0,
float *input1,
float *input2,
float *input3,
float *output0,
float *output1)
1012 double fSlow0 = (0.01 * dry_wet);
1013 double fSlow1 = (1 - fSlow0);
1014 for (
int i=0; i<count; i++) {
1015 output0[i] = ((fSlow0 * (double)input2[i]) + (fSlow1 * (double)input0[i]));
1016 output1[i] = ((fSlow0 * (double)input3[i]) + (fSlow1 * (double)input1[i]));
1020 void Lv2Dsp::stereo_process(
int count,
float *input1,
float *input2,
float *output1,
float *output2,
PluginDef *plugin) {
1022 assert(
self.is_activated);
1023 if (
self.pd->add_wet_dry) {
1024 float wet_out1[count];
1025 float wet_out2[count];
1026 self.connect(
self.loader.lv2_InputPort, 0, input1);
1027 self.connect(
self.loader.lv2_InputPort, 1, input2);
1028 self.connect(
self.loader.lv2_OutputPort, 0, wet_out1);
1029 self.connect(
self.loader.lv2_OutputPort, 1, wet_out2);
1030 lilv_instance_run(
self.instance, count);
1031 self.stereo_dry_wet(count, input1, input2, wet_out1, wet_out2, output1, output2);
1033 self.connect(
self.loader.lv2_InputPort, 0, input1);
1034 self.connect(
self.loader.lv2_InputPort, 1, input2);
1035 self.connect(
self.loader.lv2_OutputPort, 0, output1);
1036 self.connect(
self.loader.lv2_OutputPort, 1, output2);
1037 lilv_instance_run(
self.instance, count);
1041 std::string Lv2Dsp::make_id(
const paradesc& p) {
1045 int Lv2Dsp::registerparam(
const ParamReg& reg) {
1050 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1051 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1052 if (n>=num_controls)
break;
1058 std::vector<paradesc*>::const_iterator it2 = it+1;
1059 while (it2 !=
self.pd->names.end() && !(*it2)->newrow) {
1068 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, d->
index);
1069 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1070 const char *nm = lilv_node_as_string(nm_node);
1071 Glib::ustring snm(d->
name);
1073 snm = TrimLabel(nm, cnt_in_row);
1081 case tp_none: tp =
"S";
break;
1082 case tp_int: tp =
"S";
break;
1088 default: assert(
false);
1090 reg.
registerVar(
self.make_id(*d).c_str(), snm.c_str(), tp, nm, &
self.ports[d->
index],
1093 lilv_node_free(nm_node);
1095 self.idd =
self.pd->id_str +
".dry_wet";
1096 reg.
registerVar(
self.idd.c_str(),
"",
"S",
"dry/wet",&
self.dry_wet, 100, 0, 100, 1);
1100 int Lv2Dsp::uiloader(
const UiBuilder& b,
int form) {
1106 if (
self.pd->master_idx >= 0) {
1108 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1109 if ((n)==
self.pd->master_idx) {
1110 switch ((*it)->tp) {
1115 const char *p =
self.pd->master_label.c_str();
1130 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1131 if ((*it)->newrow) {
1137 int num_controls = lilv_plugin_get_num_ports_of_class(
self.plugin,
self.loader.lv2_ControlPort, 0);
1138 for (std::vector<paradesc*>::const_iterator it =
self.pd->names.begin(); it !=
self.pd->names.end(); ++it, ++n) {
1139 if (n>=num_controls)
break;
1140 if ((*it)->newrow) {
1142 if ( (rows == 1) || ( rows > 1 && row > 0 )) {
1150 const LilvPort* port = lilv_plugin_get_port_by_index(
self.plugin, (*it)->index);
1151 LilvNode* nm_node = lilv_port_get_name(
self.plugin, port);
1152 const char *p1 = lilv_node_as_string(nm_node);
1153 if (!(*it)->name.empty())
1154 p1 = (*it)->name.c_str();
1155 Glib::ustring trim = TrimEffectLabel(p1, 4);
1156 const char *p = trim.c_str();
1157 std::string
id =
self.make_id(**it);
1158 if ((row == 1 && rows == 1 ) || (row >1 && rows >1 )) {
1161 switch ((*it)->tp) {
1164 if (!(*it)->has_caption) {
1170 if ((*it)->has_caption) {
1177 if (!(*it)->has_caption) {
1183 if ((*it)->has_caption) {
1190 if (!(*it)->has_caption) {
1193 if (((*it)->up - (*it)->low)<200) {
1200 if ((*it)->has_caption) {
1211 lilv_node_free(nm_node);
1213 if (
self.pd->add_wet_dry) {
1221 void Lv2Dsp::del_instance(
PluginDef *plugin) {
1222 delete static_cast<Lv2Dsp*
>(plugin);
1239 : options(options_),
1241 world(lilv_world_new()),
1243 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1244 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1245 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1246 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)) {
1247 lilv_world_load_all(world);
1248 lv2_plugins = lilv_world_get_all_plugins(world);
1253 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1256 lilv_node_free(lv2_OutputPort);
1257 lilv_node_free(lv2_InputPort);
1258 lilv_node_free(lv2_ControlPort);
1259 lilv_node_free(lv2_AudioPort);
1260 lilv_world_free(world);
1265 read_module_list(ml);
1267 gx_print_error(
"ladspaloader",ustring::compose(_(
"Exception in LADSPA list reader: %1"), e.
what()));
1274 for (pluginarray::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1277 plugins = new_plugins;
1284 plugins = new_plugins;
1288 for (pluginarray::iterator i =
begin(); i !=
end(); ++i) {
1290 if ((*i)->path == desc->
path) {
1294 if ((*i)->UniqueID == desc->
UniqueID) {
1304 static_cast<Lv2Dsp*
>(pdef)->set_plugdesc(pdesc);
1306 static_cast<LadspaDsp*
>(pdef)->set_plugdesc(pdesc);
1311 for (
value_pair *p = values; p->value_id; ++p) {
1312 g_free(const_cast<char*>(p->value_id));
1320 for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i, ++n) {
1321 const char *p = g_strdup(i->c_str());
1322 values[n].value_id = p;
1323 values[n].value_label = p;
1325 values[n].value_id = 0;
1326 values[n].value_label = 0;
1329 void LadspaLoader::read_module_config(
const std::string& filename,
plugdesc *p) {
1330 std::ifstream ifs(filename.c_str());
1332 gx_print_error(
"ladspaloader", ustring::compose(_(
"can't open %1"), filename));
1381 std::vector<std::string> v;
1389 p->
names.push_back(para);
1396 void LadspaLoader::read_module_list(
pluginarray& ml) {
1426 if (access(fname.c_str(), F_OK) != 0) {
1428 if (access(fname.c_str(), F_OK) != 0) {
1432 if (!fname.empty()) {
1434 read_module_config(fname, p);
1436 gx_print_error(
"ladspaloader",ustring::compose(_(
"read error in file %1: %2"), s, e.
what()));
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 end_array(bool nl=false)
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 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)
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)
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)
activatefunc activate_plugin
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)
pluginarray::iterator begin()
string current_value() const
void readJSON(gx_system::JsonParser &jp)
void(* set_next_flags)(int flags)
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)
float current_value_float()
token next(token expect=no_token)
void write(float v, bool nl=false)
void(* create_switch)(const char *sw_type, const char *id, const char *label)
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)
std::string encode_filename(const std::string &s)