35 static const unsigned long blacklist[] = {
41 static bool lib_is_blacklisted(
const std::string& name) {
42 static const char *blacklist[] = {
45 for (
unsigned int i = 0; i <
sizeof(blacklist) /
sizeof(blacklist[0]); i++) {
46 if (name == blacklist[i]) {
53 static const unsigned long quirklist_no_cleanup[] = { 1912, 0 };
54 static const unsigned long quirklist_activate[] = { 1890, 1891, 1893, 1894, 1892, 1903, 1904, 0 };
57 const unsigned long *
ids;
59 {1, quirklist_no_cleanup},
60 {2, quirklist_activate},
64 #define unknown_category "External" 66 static const char *cat_subst[][2] = {
67 {
"Reverbs",
"Reverb"},
68 {
"Filters",
"Tone Control"},
69 {
"EQs",
"Tone Control"},
70 {
"Compressors",
"Guitar Effects"},
71 {
"Utilities",
"Misc"},
72 {
"Delays",
"Echo / Delay"},
73 {
"Phasers",
"Modulation"},
74 {
"Chorus",
"Modulation"},
75 {
"Flangers",
"Modulation"},
76 {
"Modulators",
"Modulation"},
77 {
"Distortions",
"Distortion"},
78 {
"Waveshapers",
"Distortion"},
79 {
"Amplifiers",
"Distortion"},
81 {
"Filter",
"Tone Control"},
82 {
"Distortion",
"Distortion"},
83 {
"Delay",
"Echo / Delay"},
84 {
"Modulator",
"Modulation"},
86 {
"Compressor",
"Guitar Effects"},
94 static inline bool float_eq(
float v1,
float v2) {
95 return std::abs(v1 - v2) <= 1e-5 * std::abs(v1);
99 if (v1.set_flags != v2.set_flags) {
120 if (v1.enumdict.size() != v2.enumdict.size()) {
123 for (std::map<int, ustring>::const_iterator i = v1.enumdict.begin(); i != v1.enumdict.end(); ++i) {
124 std::map<int, ustring>::const_iterator j = v2.enumdict.find(i->first);
125 if (j == v2.enumdict.end() || j->second != i->second) {
134 : name(), dflt(), low(), up(), tp(
tp_scale), enumdict(), newrow(), set_flags(0) {
138 if (jp.
read_kv(
"name", name) ||
143 jp.
read_kv(
"newrow", newrow) ||
144 jp.
read_kv(
"set_flags", set_flags)) {
156 "ladspa::ChangeableValues", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
171 jw.
write_kv(
"set_flags", set_flags);
174 for (std::map<int, Glib::ustring>::iterator i = enumdict.begin(); i != enumdict.end(); ++i) {
199 : idx(idx_), pos(pos_), is_output(is_output_), hint_desc(hint.
HintDescriptor),
200 fake_low(
false), fake_up(
false), fake_dflt(
false),
202 has_caption(
true), factory(), user() {
203 factory.set_name(name);
204 set_range_default(hint, factory);
205 set_default_value(hint, factory);
206 set_tp_default(hint, factory);
210 : idx(), pos(), is_output(), hint_desc(),
211 fake_low(false), fake_up(false), fake_dflt(false),
212 step(
stp_normal), use_sr(false), has_sr(false),
213 has_caption(true), factory(), user() {
234 "ladspa::PortDesc", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
282 store.
set_dflt(exp(log(low)*0.75 + log(up)*0.25));
284 store.
set_dflt(exp(log(low)*0.5 + log(up)*0.5));
286 store.
set_dflt(exp(log(low)*0.25 + log(up)*0.75));
293 store.
set_dflt(low * 0.75 + up * 0.25);
295 store.
set_dflt(low * 0.5 + up * 0.5);
297 store.
set_dflt(low * 0.25 + up * 0.75);
370 std::map<int, ustring>::iterator i;
539 return pow(up/low, 1.0/50);
542 return pow(up/low, 1.0/100);
545 return pow(up/low, 1.0/500);
552 s = (up - low) / 30.0;
555 s = (up - low) / 300.0;
558 s = (up - low) / 3000.0;
563 return pow(10.0, round(log10(s)));
571 }
else if (
get_name() ==
"latency") {
626 int iup = int(round(up));
627 for (
int i =
int(round(low)); i < iup+1; ++i) {
636 jp.
next(JsonParser::begin_array);
637 jp.
next(JsonParser::value_number);
639 jp.
next(JsonParser::end_array);
640 jp.
next(JsonParser::value_string);
644 jp.
next(JsonParser::value_number);
646 jp.
next(JsonParser::value_number);
648 jp.
next(JsonParser::value_number);
650 jp.
next(JsonParser::value_number);
652 jp.
next(JsonParser::value_number);
654 jp.
next(JsonParser::value_number);
673 jp.
next(JsonParser::value_number);
678 jp.
next(JsonParser::value_number);
681 jp.
next(JsonParser::begin_array);
683 while (jp.
peek() != JsonParser::end_array) {
684 jp.
next(JsonParser::value_string);
691 jp.
next(JsonParser::end_array);
694 PluginDesc::PluginDesc(
const LADSPA_Descriptor& desc,
int tp_, std::vector<PortDesc*>& ctrl_ports_,
const std::string path_,
int index_)
696 MasterIdx(-1), MasterLabel(), tp(tp_), ctrl_ports(ctrl_ports_), path(path_), index(index_),
698 ladspa_category(), active(
false), active_set(
false),
has_settings(
false), add_wet_dry(0), stereo_to_mono(0), old(0) {
699 quirks = quirks_default = quirks_get();
702 PluginDesc::PluginDesc(LilvWorld *world,
const LilvPlugin* plugin,
int tp_, std::vector<PortDesc*>& ctrl_ports_)
703 : UniqueID(0), Label(), Name(), shortname(), Maker(),
704 MasterIdx(-1), MasterLabel(), tp(tp_), ctrl_ports(ctrl_ports_),
705 path(lilv_node_as_string(lilv_plugin_get_uri(plugin))), index(0),
707 ladspa_category(), active(
false), active_set(
false),
has_settings(
false), add_wet_dry(0), stereo_to_mono(0), old(0) {
708 LilvNode* nd = lilv_plugin_get_name(plugin);
709 Glib::ustring s = lilv_node_as_string(nd);
714 nd = lilv_plugin_get_author_name(plugin);
716 nd = lilv_plugin_get_project(plugin);
719 Maker = lilv_node_as_string(nd);
724 path = lilv_node_as_string(lilv_plugin_get_uri(plugin));
725 const LilvPluginClass* cls = lilv_plugin_get_class(plugin);
727 std::vector<Glib::ustring> cats;
728 const LilvPluginClasses* pclasses = lilv_world_get_plugin_classes(world);
730 const LilvNode *pn = lilv_plugin_class_get_parent_uri(cls);
734 const LilvPluginClass* pcls = lilv_plugin_classes_get_by_uri(pclasses, pn);
738 cats.insert(cats.begin(), lilv_node_as_string(lilv_plugin_class_get_label(cls)));
745 PluginDesc::~PluginDesc() {
747 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
779 if (jp.
read_kv(
"UniqueID", UniqueID) ||
782 jp.
read_kv(
"shortname", shortname) ||
784 jp.
read_kv(
"MasterIdx", MasterIdx) ||
785 jp.
read_kv(
"MasterLabel", MasterLabel) ||
789 jp.
read_kv(
"category", category) ||
790 jp.
read_kv(
"deduced_category", deduced_category) ||
791 jp.
read_kv(
"quirks", quirks) ||
792 jp.
read_kv(
"quirks_default", quirks_default) ||
794 jp.
read_kv(
"ladspa_category", ladspa_category) ||
795 jp.
read_kv(
"active", active) ||
796 jp.
read_kv(
"active_set", active_set) ||
798 jp.
read_kv(
"add_wet_dry", add_wet_dry) ||
799 jp.
read_kv(
"stereo_to_mono", stereo_to_mono)) {
805 ctrl_ports.push_back(
new PortDesc(jp));
810 "ladspa::PluginDesc", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
819 jw.
write_kv(
"UniqueID", static_cast<unsigned int>(UniqueID));
822 jw.
write_kv(
"shortname", shortname);
824 jw.
write_kv(
"MasterIdx", MasterIdx);
825 jw.
write_kv(
"MasterLabel", MasterLabel);
830 jw.
write_kv(
"deduced_category", deduced_category);
832 jw.
write_kv(
"quirks_default", quirks_default);
834 jw.
write_kv(
"ladspa_category", ladspa_category);
836 jw.
write_kv(
"active_set", active_set);
838 jw.
write_kv(
"add_wet_dry", add_wet_dry);
839 jw.
write_kv(
"stereo_to_mono", stereo_to_mono);
842 old->serializeJSON(jw);
846 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
847 (*i)->serializeJSON(jw);
855 for (
int i = 0; quirk_list[i].flag; i++) {
856 for (
int j = 0; quirk_list[i].ids[j]; j++) {
857 if (UniqueID == quirk_list[i].
ids[j]) {
858 flag |= quirk_list[i].flag;
874 category = deduced_category;
875 quirks = quirks_default;
878 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
884 assert(ctrl_ports.size() == 0);
885 for (std::vector<PortDesc*>::iterator i = p->
ctrl_ports.begin(); i != p->
ctrl_ports.end(); ++i) {
886 ctrl_ports.push_back(
new PortDesc(**i));
891 void LadspaPluginList::add_plugin(
const LADSPA_Descriptor& desc, pluginmap& d,
const std::string& path,
int index) {
892 for (
unsigned int j = 0; j <
sizeof(blacklist)/
sizeof(blacklist[0]); j++) {
893 if (desc.
UniqueID == blacklist[j]) {
904 std::vector<PortDesc*> ctrl_ports;
906 for (
unsigned int n = 0; n < desc.
PortCount; n++) {
920 if (n_in == 1 && n_out == 1) {
922 }
else if (n_in == 2 && n_out == 2) {
925 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
934 void LadspaPluginList::load_defs(
const std::string& path, pluginmap& d) {
936 handle = dlopen(path.c_str(), RTLD_LOCAL|RTLD_NOW);
940 ustring::compose(_(
"Cannot open plugin: %1\n"), dlerror()));
944 const char *dlsym_error = dlerror();
957 add_plugin(*desc, d, path, i);
967 if (UniqueID != old->UniqueID) {
970 if (Label != old->Label) {
973 if (Name != old->Name) {
976 if (shortname != old->shortname) {
979 if (Maker != old->Maker) {
982 if (MasterIdx != old->MasterIdx) {
985 if (MasterIdx > -1 && MasterLabel != old->MasterLabel) {
988 if (add_wet_dry != old->add_wet_dry) {
991 if (stereo_to_mono != old->stereo_to_mono) {
997 if (path != old->path) {
1000 if (index != old->index) {
1003 if (category != old->category) {
1006 if (deduced_category != old->deduced_category) {
1009 if (quirks != old->quirks) {
1012 if (quirks_default != old->quirks_default) {
1015 if (ladspa_category != old->ladspa_category) {
1018 for (
unsigned int i = 0; i < ctrl_ports.size(); ++i) {
1027 if (shortname != Name) {
1030 if (category != deduced_category) {
1033 if (quirks != quirks_default) {
1036 if (MasterIdx != -1) {
1039 for (
int i = 0; i < static_cast<int>(ctrl_ports.size()); ++i) {
1040 if (i != ctrl_ports[i]->
get_pos()) {
1059 if (v == active_set) {
1083 for (
unsigned int n = 0; n < ctrl_ports.size(); ++n) {
1084 bool newrow =
false;
1086 newrow = (i % 6 == 0 && i != 0);
1089 ctrl_ports[n]->fixup(newrow);
1096 for (std::vector<ustring>::const_iterator i = s.begin(); i != s.end(); ++i) {
1102 for (
const char *(*p)[2] = cat_subst; (*p)[0]; ++p) {
1103 if (*i == (*p)[0]) {
1104 category = deduced_category = (*p)[1];
1111 ladspa_category = t;
1115 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1116 if ((*p)->idx == idx) {
1117 (*p)->set_default(value, label);
1124 ustring s = shortname;
1130 if (MasterIdx >= 0) {
1131 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1133 if ((*p)->pos == MasterIdx) {
1135 if (sm == (*p)->get_name()) {
1149 jw.
write(add_wet_dry);
1150 jw.
write(stereo_to_mono);
1152 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1167 jw.
write(uint(UniqueID));
1173 ifstream is(fname.c_str());
1175 gx_print_error(
"ladspalist", ustring::compose(_(
"can't open %1"), fname));
1180 jp.
next(JsonParser::begin_array);
1181 jp.
next(JsonParser::value_number);
1183 jp.
next(JsonParser::value_string);
1185 if (shortname.empty()) {
1188 jp.
next(JsonParser::value_string);
1190 jp.
next(JsonParser::value_number);
1192 jp.
next(JsonParser::value_string);
1194 jp.
next(JsonParser::value_number);
1200 jp.
next(JsonParser::value_number);
1202 if (jp.
peek() == JsonParser::value_number) {
1203 jp.
next(JsonParser::value_number);
1206 std::vector<PortDesc*> ports;
1207 jp.
next(JsonParser::begin_array);
1209 int m_idx = MasterIdx;
1210 while (jp.
peek() != JsonParser::end_array) {
1211 jp.
next(JsonParser::begin_array);
1212 jp.
next(JsonParser::value_number);
1214 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1215 if ((*p)->idx == idx) {
1217 MasterIdx = (*p)->pos;
1219 (*p)->set_state(jp, version);
1220 ports.push_back((*p));
1225 jp.
next(JsonParser::end_array);
1227 jp.
next(JsonParser::end_array);
1228 if (ctrl_ports.size() == ports.size()) ctrl_ports = ports;
1231 jp.
next(JsonParser::end_array);
1232 jp.
next(JsonParser::end_token);
1237 ustring::compose(_(
"error parsing LADSPA plugin config file %1: %2"), fname, e.
what()));
1241 check_has_settings();
1246 old->ctrl_ports.clear();
1247 old->copy_ports(
this);
1257 } ranges_1_based[] = {
1269 world(lilv_world_new()),
1271 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1272 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1273 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1274 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)),
1275 lv2_connectionOptional(lilv_new_uri(world, LV2_CORE__connectionOptional)) {
1276 LilvNode* false_val = lilv_new_bool(world,
false);
1277 lilv_world_set_option(world,LILV_OPTION_DYN_MANIFEST, false_val);
1278 lilv_world_load_all(world);
1279 lv2_plugins = lilv_world_get_all_plugins(world);
1280 lilv_node_free(false_val);
1283 static bool in_1_based_range(
unsigned long uid) {
1284 for (
unsigned int i = 0; i <
sizeof(ranges_1_based)/
sizeof(ranges_1_based[0]); ++i) {
1285 if (uid >= ranges_1_based[i].
from && uid <= ranges_1_based[i].
to) {
1293 void LadspaPluginList::set_instances(
const char *uri, pluginmap& d, std::vector<ustring>& label,
1294 std::vector<unsigned long>& not_found, std::set<unsigned long>& seen) {
1295 lrdf_uris *uris = lrdf_get_instances(uri);
1297 for (
unsigned int i = 0; i < uris->count; ++i) {
1298 const char *u = uris->items[i];
1299 unsigned long uid = lrdf_get_uid(u);
1300 std::string uid_key = make_key(uid);
1301 if (d.find(uid_key) == d.end()) {
1302 not_found.push_back(uid);
1306 if (seen.find(uid) == seen.end()) {
1309 for (
unsigned int n = 0; n < pd->
ctrl_ports.size(); n++) {
1311 lrdf_defaults *sval = lrdf_get_scale_values(uid, p->
idx);
1313 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1314 lrdf_portvalue& t = sval[0].items[nn];
1317 lrdf_free_setting_values(sval);
1323 uri = lrdf_get_default_uri(uid);
1325 lrdf_defaults *sval = lrdf_get_setting_values(uri);
1327 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1328 lrdf_portvalue& t = sval[0].items[nn];
1330 if (in_1_based_range(uid)) {
1335 lrdf_free_setting_values(sval);
1341 lrdf_free_uris(uris);
1346 void LadspaPluginList::descend(
const char *uri, pluginmap& d,
1347 std::vector<unsigned long>& not_found,
1348 std::set<unsigned long>& seen,
1349 std::vector<ustring>& base) {
1350 lrdf_uris *uris = lrdf_get_subclasses(uri);
1352 for (
unsigned int i = 0; i < uris->count; ++i) {
1353 const char *u = uris->items[i];
1354 base.push_back(lrdf_get_label(u));
1355 set_instances(u, d, base, not_found, seen);
1356 descend(u, d, not_found, seen, base);
1359 lrdf_free_uris(uris);
1363 void LadspaPluginList::get_preset_values(
const char* port_symbol,
1369 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1370 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1371 const char* sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1372 if (strcmp(sym, port_symbol) ==0) {
1373 float fvalue = *(
const float*)value;
1374 Glib::ustring port_id = pdata->
sname ;
1375 pdata->
cline +=
" \"lv2_";
1376 pdata->
cline += port_id ;
1377 pdata->
cline +=
"." ;
1379 pdata->
cline +=
"\": " ;
1381 pdata->
cline +=
"\n";
1387 void LadspaPluginList::set_preset_values(Glib::ustring port_symbol,
1389 Glib::ustring value) {
1390 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1391 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1392 Glib::ustring sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1393 if (sym.compare(port_symbol) ==0) {
1394 Glib::ustring port_id = pdata->
sname ;
1395 pdata->
cline +=
" \"lv2_";
1396 pdata->
cline += port_id ;
1397 pdata->
cline +=
"." ;
1399 pdata->
cline +=
"\": " ;
1400 pdata->
cline += value;
1401 pdata->
cline +=
"\n";
1407 void LadspaPluginList::get_presets(
LV2Preset *pdata) {
1408 pdata->
cline =
"[\"gx_plugin_version\", 1,\n";
1409 LilvNodes* presets = lilv_plugin_get_related(pdata->
plugin,
1410 lilv_new_uri(world,LV2_PRESETS__Preset));
1411 LILV_FOREACH(nodes, i, presets) {
1412 const LilvNode* preset = lilv_nodes_get(presets, i);
1413 lilv_world_load_resource(world, preset);
1414 LilvNodes* labels = lilv_world_find_nodes(
1415 world, preset, lilv_new_uri(world, LILV_NS_RDFS
"label"), NULL);
1417 const LilvNode* label = lilv_nodes_get_first(labels);
1419 Glib::ustring
set = lilv_node_as_string(label);
1422 pdata->
cline +=
" \"" +
set +
"\"" +
" {\n";
1425 std::istringstream stream(stt);
1427 Glib::ustring symbol =
"";
1428 Glib::ustring value =
"";
1429 while (std::getline(stream, st)) {
1430 std::size_t found = st.find(
"lv2:symbol");
1431 if(found !=Glib::ustring::npos) {
1432 std::size_t found1 = st.find(
"\"",found)+1;
1433 std::size_t found2 = st.find(
"\"",found1);
1434 if(found2 !=Glib::ustring::npos) {
1435 symbol = st.substr(found1, (found2-found1));
1440 found = st.find(
"pset:value");
1441 if(found !=Glib::ustring::npos) {
1442 std::size_t found1 = st.find(
" ",found)+1;
1443 if(found1 !=Glib::ustring::npos) {
1444 value = st.substr(found1);
1445 set_preset_values(symbol,pdata,value);
1452 lilv_state_free(state);
1453 pdata->
cline +=
" },\n";
1456 lilv_nodes_free(labels);
1458 lilv_nodes_free(presets);
1461 bool LadspaPluginList::feature_is_supported(
const char* uri)
1463 if (!strcmp(uri,
"http://lv2plug.in/ns/lv2core#isLive")) {
1467 if (!strcmp(uri, (*f)->URI)) {
1477 LilvNodes* requests = lilv_plugin_get_required_features(plugin);
1478 LILV_FOREACH(nodes, f, requests) {
1479 const char* uri = lilv_node_as_uri(lilv_nodes_get(requests, f));
1480 if (!feature_is_supported(uri)) {
1483 lilv_nodes_free(requests);
1487 lilv_nodes_free(requests);
1491 std::vector<PortDesc*> ctrl_ports;
1493 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
1494 for (
unsigned int n = 0; n < num_ports; n++) {
1495 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
1496 if (lilv_port_is_a(plugin, port, lv2_AudioPort)) {
1497 if (lilv_port_is_a(plugin, port, lv2_InputPort)) {
1502 }
else if (lilv_port_is_a(plugin, port, lv2_ControlPort)) {
1506 LilvNode *pdflt, *pmin, *pmax;
1507 lilv_port_get_range(plugin, port, &pdflt, &pmin, &pmax);
1511 lilv_node_free(pmin);
1516 lilv_node_free(pmax);
1518 LilvNode* nm = lilv_port_get_name(plugin, port);
1519 PortDesc *pdesc =
new PortDesc(n, pos, lilv_port_is_a(plugin, port, lv2_OutputPort), lilv_node_as_string(nm), hint);
1523 lilv_node_free(pdflt);
1525 LilvNode* is_int = lilv_new_uri(world, LV2_CORE__integer);
1526 if (lilv_port_has_property(plugin, port, is_int)) {
1529 lilv_node_free(is_int);
1530 LilvNode* is_tog = lilv_new_uri(world, LV2_CORE__toggled);
1531 if (lilv_port_has_property(plugin, port, is_tog)) {
1534 lilv_node_free(is_tog);
1535 LilvScalePoints* sp = lilv_port_get_scale_points(plugin, port);
1536 int num_sp = lilv_scale_points_size(sp);
1538 for (LilvIter* it = lilv_scale_points_begin(sp);
1539 !lilv_scale_points_is_end(sp, it);
1540 it = lilv_scale_points_next(sp, it)) {
1541 const LilvScalePoint* p = lilv_scale_points_get(sp, it);
1543 lilv_node_as_float(lilv_scale_point_get_value(p)),
1544 lilv_node_as_string(lilv_scale_point_get_label(p)));
1548 lilv_scale_points_free(sp);
1549 ctrl_ports.push_back(pdesc);
1552 if (!lilv_port_has_property(plugin, port, lv2_connectionOptional)) {
1559 if (n_in == 1 && n_out == 1) {
1561 }
else if (n_in == 2 && n_out == 2) {
1564 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
1577 PluginDesc* p = d[lilv_node_as_string(lilv_plugin_get_uri(plugin))] =
new PluginDesc(world, plugin, tp, ctrl_ports);
1580 if (p->
path.size() != 0) {
1584 pdata.
plugin =
const_cast<LilvPlugin*
>(plugin);
1585 get_presets(&pdata);
1592 for (LilvIter* it = lilv_plugins_begin(lv2_plugins);
1593 !lilv_plugins_is_end(lv2_plugins, it);
1594 it = lilv_plugins_next(lv2_plugins, it)) {
1595 add_plugin(lilv_plugins_get(lv2_plugins, it), d, options);
1599 pdata.
cline +=
"]\n";
1602 pfile += pdata.
sname;
1603 ofstream os (pfile.c_str());
1614 return ustring(a->
Name) < ustring(b->
Name);
1620 pl.
add(
"/usr/lib/ladspa");
1621 pl.
add(
"/usr/local/lib/ladspa");
1622 pl.
add(
"/usr/lib64/ladspa");
1623 pl.
add(
"/usr/local/lib64/ladspa");
1627 Glib::RefPtr<Gio::File> file = *it;
1628 if (!file->query_exists()) {
1631 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1632 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1633 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1634 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1635 Glib::RefPtr<Gio::FileInfo> file_info;
1637 while ((file_info = child_enumeration->next_file())) {
1638 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/x-sharedlib") {
1639 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1640 if (lib_is_blacklisted(nm)) {
1644 load_defs(Glib::build_filename(file->get_path(), nm), d);
1650 rpl.
add(
"/usr/share/ladspa/rdf");
1651 rpl.
add(
"/usr/local/share/ladspa/rdf");
1655 Glib::RefPtr<Gio::File> file = *it;
1656 if (!file->query_exists()) {
1659 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1660 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1661 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1662 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1663 Glib::RefPtr<Gio::FileInfo> file_info;
1665 while ((file_info = child_enumeration->next_file())) {
1667 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/rdf+xml") {
1668 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1669 if (lib_is_blacklisted(nm)) {
1672 lrdf_read_file((
"file://"+Glib::build_filename(file->get_path(), nm)).c_str());
1676 std::vector<unsigned long> not_found;
1677 std::set<unsigned long> seen;
1678 std::vector<ustring> base;
1679 locale_t loc = newlocale(LC_ALL,
"C", 0);
1681 descend(LADSPA_BASE
"Plugin", d, not_found, seen, base);
1682 uselocale(LC_GLOBAL_LOCALE);
1686 lv2_load(d, options);
1692 jp.
next(JsonParser::begin_array);
1693 while (jp.
peek() == JsonParser::begin_array) {
1694 jp.
next(JsonParser::begin_array);
1695 jp.
next(JsonParser::value_string);
1697 jp.
next(JsonParser::value_number);
1699 jp.
next(JsonParser::value_number);
1702 key = make_key(uid);
1704 if (d.find(key) == d.end()) {
1705 old_not_found.push_back(key);
1707 d[key]->set_active(
true);
1708 d[key]->active_set =
true;
1710 jp.
next(JsonParser::value_string);
1711 jp.
next(JsonParser::end_array);
1716 "ladspalist", ustring::compose(
1717 _(
"error loading ladspa plugin selection data from file %1"),
1722 for (pluginmap::iterator v = d.begin(); v != d.end(); ++v) {
1725 if (v->second->is_lv2) {
1731 if (access(fname.c_str(), F_OK) != 0) {
1733 if (access(fname.c_str(), F_OK) != 0) {
1737 if (!fname.empty()) {
1738 v->second->set_state(fname);
1741 for (pluginmap::iterator i = d.begin(); i != d.end(); ++i) {
1742 push_back(i->second);
1744 std::sort(begin(),
end(), cmp_plugins);
1749 std::string tfname = fname +
".tmp";
1750 ofstream tfile(tfname.c_str());
1752 jw.begin_array(
true);
1753 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1755 (*p)->output_entry(jw);
1761 std::vector<std::pair<std::string,std::string> > fl;
1762 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1763 std::string sname = ((*p)->is_lv2 ?
1767 if ((*p)->active || (*p)->has_settings) {
1768 std::string tcname = cname +
".tmp";
1769 ofstream tcfile(tcname.c_str());
1774 fl.push_back(std::pair<std::string,std::string>(tcname, cname));
1776 fl.push_back(std::pair<std::string,std::string>(
"", cname));
1779 if (rename(tfname.c_str(), fname.c_str()) != 0) {
1781 strerror_r(errno, buf,
sizeof(buf));
1783 "ladspalist",ustring::compose(_(
"error renaming LADSPA config file '%1': %2"), fname, buf));
1786 for (std::vector<std::pair<std::string,std::string> >::iterator i = fl.begin(); i != fl.end(); ++i) {
1787 if (i->first.empty()) {
1788 unlink(i->second.c_str());
1790 if (rename(i->first.c_str(), i->second.c_str()) != 0) {
1792 strerror_r(errno, buf,
sizeof(buf));
1795 ustring::compose(
"error renaming %1 to %2: %3\n", i->first, i->second, buf));
1812 for (iterator i = begin(); i !=
end(); ++i) {
1813 (*i)->serializeJSON(jw);
1819 for (iterator i = begin(); i !=
end(); ++i) {
1822 lilv_node_free(lv2_AudioPort);
1823 lilv_node_free(lv2_ControlPort);
1824 lilv_node_free(lv2_InputPort);
1825 lilv_node_free(lv2_OutputPort);
1826 lilv_node_free(lv2_connectionOptional);
1827 lilv_world_free(world);
CmdConnection::msg_type end
bool check_changed(const PortDesc &vp) const
void write_kv(const char *key, float v)
void set_enumvalue(int k, const Glib::ustring &v)
void begin_array(bool nl=false)
#define LADSPA_IS_HINT_DEFAULT_LOW(x)
void writeJSON(gx_system::JsonWriter &jw)
std::list< Glib::RefPtr< Gio::File > >::const_iterator iterator
std::string get_factory_filepath(const std::string &basename) const
unsigned int current_value_uint()
void end_array(bool nl=false)
#define LADSPA_IS_HINT_TOGGLED(x)
#define LADSPA_IS_HINT_INTEGER(x)
void set_state(const Glib::ustring &fname)
const Glib::ustring & get_name()
LADSPA_Properties Properties
void set_add_wet_dry_controller(bool v)
const LADSPA_PortRangeHint * PortRangeHints
int LADSPA_PortDescriptor
#define LADSPA_IS_HINT_DEFAULT_100(x)
#define LADSPA_IS_HINT_BOUNDED_BELOW(x)
std::map< int, Glib::ustring >::iterator enum_end()
void serializeJSON(gx_system::JsonWriter &jw)
#define LADSPA_IS_HINT_DEFAULT_HIGH(x)
void load(gx_system::CmdlineOptions &options, std::vector< std::string > &old_not_found)
void output(gx_system::JsonWriter &jw)
int get_excl_flags(DisplayType tp) const
void set_tp(DisplayType v)
void set_range_default(const LADSPA_PortRangeHint &h, ChangeableValues &store)
void write_key(const char *p, bool nl=false)
#define LADSPA_IS_HINT_SAMPLE_RATE(x)
void copy_ports(PluginDesc *p)
void set_default_value(const LADSPA_PortRangeHint &h, ChangeableValues &store)
std::vector< PortDesc * > ctrl_ports
void add(const std::string &d)
bool operator!=(const ChangeableValues &v1, const ChangeableValues &v2)
const Glib::ustring & get_name()
LADSPA_PortRangeHintDescriptor HintDescriptor
void set_default(int idx, float value, const Glib::ustring &label)
void gx_print_error(const char *, const std::string &)
bool read_kv(const char *key, float &v)
bool _i_check_has_settings()
std::vector< PortDesc * > ctrl_ports
bool has_settings(DisplayType tp) const
void check_has_settings()
void serializeJSON(gx_system::JsonWriter &jw)
#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x)
#define LADSPA_IS_HINT_DEFAULT_0(x)
void readJSON(gx_system::JsonParser &jp)
void output_entry(gx_system::JsonWriter &jw)
void save(gx_system::CmdlineOptions &options)
#define LADSPA_IS_HINT_DEFAULT_440(x)
std::string get_plugin_filepath(const std::string &basename) const
void begin_object(bool nl=false)
const char *const * PortNames
LADSPA_PortRangeHintDescriptor hint_desc
#define LADSPA_IS_HARD_RT_CAPABLE(x)
void set_tp(DisplayType v)
#define LADSPA_HINT_BOUNDED_ABOVE
std::string to_string(const T &t)
virtual const char * what() const
void output(gx_system::JsonWriter &jw)
std::string get_ladspa_config_filename() const
#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x)
void set_default(float value, Glib::ustring label)
void gx_print_warning(const char *, const std::string &)
#define LADSPA_IS_PORT_AUDIO(x)
void set_category(const std::vector< Glib::ustring > &s)
void set_name(const Glib::ustring &nm)
PortDesc(int idx_, int pos_, bool is_output_, Glib::ustring name, const LADSPA_PortRangeHint &hint)
static LV2Features & getInstance()
#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x)
#define LADSPA_IS_PORT_INPUT(x)
void set_state(gx_system::JsonParser &jp, int version)
string current_value() const
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x)
const std::string & get_lv2_preset_dir() const
#define LADSPA_IS_HINT_LOGARITHMIC(x)
friend bool cmp_ctrl_ports(const PortDesc *a, const PortDesc *b)
Glib::ustring get_enum(int idx)
void set_stereo_to_mono(bool v)
static std::string get_ladspa_filename(unsigned long uid)
const LADSPA_Descriptor *(* LADSPA_Descriptor_Function)(unsigned long Index)
void set_tp_default(const LADSPA_PortRangeHint &h, ChangeableValues &store)
float current_value_float()
#define LADSPA_IS_PORT_OUTPUT(x)
#define LADSPA_HINT_BOUNDED_BELOW
#define LADSPA_IS_HINT_HAS_DEFAULT(x)
token next(token expect=no_token)
void write(float v, bool nl=false)
const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index)
std::map< int, Glib::ustring >::iterator find_enum(int k)
#define LADSPA_IS_HINT_DEFAULT_1(x)
const unsigned long * ids
void end_object(bool nl=false)
const LADSPA_PortDescriptor * PortDescriptors
std::string encode_filename(const std::string &s)