34 static const unsigned long blacklist[] = {
40 static bool lib_is_blacklisted(
const std::string& name) {
41 static const char *blacklist[] = {
44 for (
unsigned int i = 0; i <
sizeof(blacklist) /
sizeof(blacklist[0]); i++) {
45 if (name == blacklist[i]) {
52 static const unsigned long quirklist_no_cleanup[] = { 1912, 0 };
53 static const unsigned long quirklist_activate[] = { 1890, 1891, 1893, 1894, 1892, 1903, 1904, 0 };
56 const unsigned long *
ids;
58 {1, quirklist_no_cleanup},
59 {2, quirklist_activate},
63 #define unknown_category "External" 65 static const char *cat_subst[][2] = {
66 {
"Reverbs",
"Reverb"},
67 {
"Filters",
"Tone Control"},
68 {
"EQs",
"Tone Control"},
69 {
"Compressors",
"Guitar Effects"},
70 {
"Utilities",
"Misc"},
71 {
"Delays",
"Echo / Delay"},
72 {
"Phasers",
"Modulation"},
73 {
"Chorus",
"Modulation"},
74 {
"Flangers",
"Modulation"},
75 {
"Modulators",
"Modulation"},
76 {
"Distortions",
"Distortion"},
77 {
"Waveshapers",
"Distortion"},
78 {
"Amplifiers",
"Distortion"},
80 {
"Filter",
"Tone Control"},
81 {
"Distortion",
"Distortion"},
82 {
"Delay",
"Echo / Delay"},
83 {
"Modulator",
"Modulation"},
85 {
"Compressor",
"Guitar Effects"},
93 static inline bool float_eq(
float v1,
float v2) {
94 return std::abs(v1 - v2) <= 1e-5 * std::abs(v1);
98 if (v1.set_flags != v2.set_flags) {
119 if (v1.enumdict.size() != v2.enumdict.size()) {
122 for (std::map<int, ustring>::const_iterator i = v1.enumdict.begin(); i != v1.enumdict.end(); ++i) {
123 std::map<int, ustring>::const_iterator j = v2.enumdict.find(i->first);
124 if (j == v2.enumdict.end() || j->second != i->second) {
133 : name(), dflt(), low(), up(), tp(
tp_scale), enumdict(), newrow(), set_flags(0) {
137 if (jp.
read_kv(
"name", name) ||
142 jp.
read_kv(
"newrow", newrow) ||
143 jp.
read_kv(
"set_flags", set_flags)) {
155 "ladspa::ChangeableValues", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
170 jw.
write_kv(
"set_flags", set_flags);
173 for (std::map<int, Glib::ustring>::iterator i = enumdict.begin(); i != enumdict.end(); ++i) {
197 PortDesc::PortDesc(
int idx_,
int pos_,
bool is_output_, ustring name,
const LADSPA_PortRangeHint& hint)
198 : idx(idx_), pos(pos_), is_output(is_output_), hint_desc(hint.HintDescriptor),
199 fake_low(
false), fake_up(
false), fake_dflt(
false),
200 step(
stp_normal), use_sr(
false), has_sr(LADSPA_IS_HINT_SAMPLE_RATE(hint_desc)),
201 has_caption(
true), factory(), user() {
202 factory.set_name(name);
203 set_range_default(hint, factory);
204 set_default_value(hint, factory);
205 set_tp_default(hint, factory);
209 : idx(), pos(), is_output(), hint_desc(),
210 fake_low(false), fake_up(false), fake_dflt(false),
211 step(
stp_normal), use_sr(false), has_sr(false),
212 has_caption(true), factory(), user() {
233 "ladspa::PortDesc", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
259 if (!LADSPA_IS_HINT_HAS_DEFAULT(h.HintDescriptor)) {
261 }
else if (LADSPA_IS_HINT_DEFAULT_0(h.HintDescriptor)) {
263 }
else if (LADSPA_IS_HINT_DEFAULT_1(h.HintDescriptor)) {
265 }
else if (LADSPA_IS_HINT_DEFAULT_100(h.HintDescriptor)) {
267 }
else if (LADSPA_IS_HINT_DEFAULT_440(h.HintDescriptor)) {
269 }
else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h.HintDescriptor)) {
271 }
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h.HintDescriptor)) {
278 }
else if (LADSPA_IS_HINT_LOGARITHMIC(
hint_desc)) {
280 if (LADSPA_IS_HINT_DEFAULT_LOW(h.HintDescriptor)) {
281 store.
set_dflt(exp(log(low)*0.75 + log(up)*0.25));
282 }
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h.HintDescriptor)) {
283 store.
set_dflt(exp(log(low)*0.5 + log(up)*0.5));
284 }
else if (LADSPA_IS_HINT_DEFAULT_HIGH(h.HintDescriptor)) {
285 store.
set_dflt(exp(log(low)*0.25 + log(up)*0.75));
291 if (LADSPA_IS_HINT_DEFAULT_LOW(h.HintDescriptor)) {
292 store.
set_dflt(low * 0.75 + up * 0.25);
293 }
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h.HintDescriptor)) {
294 store.
set_dflt(low * 0.5 + up * 0.5);
295 }
else if (LADSPA_IS_HINT_DEFAULT_HIGH(h.HintDescriptor)) {
296 store.
set_dflt(low * 0.25 + up * 0.75);
303 if (LADSPA_IS_HINT_TOGGLED(h.HintDescriptor)) {
307 if (LADSPA_IS_HINT_BOUNDED_BELOW(h.HintDescriptor)) {
312 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h.HintDescriptor)) {
313 store.
set_up(h.UpperBound);
369 std::map<int, ustring>::iterator i;
422 if (LADSPA_IS_HINT_LOGARITHMIC(
hint_desc)) {
538 return pow(up/low, 1.0/50);
541 return pow(up/low, 1.0/100);
544 return pow(up/low, 1.0/500);
551 s = (up - low) / 30.0;
554 s = (up - low) / 300.0;
557 s = (up - low) / 3000.0;
562 return pow(10.0, round(log10(s)));
568 if (LADSPA_IS_HINT_TOGGLED(h.HintDescriptor)) {
570 }
else if (
get_name() ==
"latency") {
575 }
else if (LADSPA_IS_HINT_TOGGLED(h.HintDescriptor)) {
577 }
else if (LADSPA_IS_HINT_LOGARITHMIC(
hint_desc)) {
579 }
else if (LADSPA_IS_HINT_INTEGER(h.HintDescriptor)) {
625 int iup = int(round(up));
626 for (
int i =
int(round(low)); i < iup+1; ++i) {
635 jp.
next(JsonParser::begin_array);
636 jp.
next(JsonParser::value_number);
638 jp.
next(JsonParser::end_array);
639 jp.
next(JsonParser::value_string);
643 jp.
next(JsonParser::value_number);
645 jp.
next(JsonParser::value_number);
647 jp.
next(JsonParser::value_number);
649 jp.
next(JsonParser::value_number);
651 jp.
next(JsonParser::value_number);
653 jp.
next(JsonParser::value_number);
672 jp.
next(JsonParser::value_number);
677 jp.
next(JsonParser::value_number);
680 jp.
next(JsonParser::begin_array);
682 while (jp.
peek() != JsonParser::end_array) {
683 jp.
next(JsonParser::value_string);
690 jp.
next(JsonParser::end_array);
693 PluginDesc::PluginDesc(
const LADSPA_Descriptor& desc,
int tp_, std::vector<PortDesc*>& ctrl_ports_,
const std::string path_,
int index_)
694 : UniqueID(desc.UniqueID), Label(desc.Label), Name(desc.Name), shortname(desc.Name), Maker(desc.Maker),
695 MasterIdx(-1), MasterLabel(), tp(tp_), ctrl_ports(ctrl_ports_), path(path_), index(index_),
697 ladspa_category(), active(
false), active_set(
false),
has_settings(
false), add_wet_dry(0), stereo_to_mono(0), old(0) {
698 quirks = quirks_default = quirks_get();
701 PluginDesc::PluginDesc(LilvWorld *world,
const LilvPlugin* plugin,
int tp_, std::vector<PortDesc*>& ctrl_ports_)
702 : UniqueID(0), Label(), Name(), shortname(), Maker(),
703 MasterIdx(-1), MasterLabel(), tp(tp_), ctrl_ports(ctrl_ports_),
704 path(lilv_node_as_string(lilv_plugin_get_uri(plugin))), index(0),
706 ladspa_category(), active(
false), active_set(
false),
has_settings(
false), add_wet_dry(0), stereo_to_mono(0), old(0) {
707 LilvNode* nd = lilv_plugin_get_name(plugin);
708 Glib::ustring s = lilv_node_as_string(nd);
713 nd = lilv_plugin_get_author_name(plugin);
715 nd = lilv_plugin_get_project(plugin);
718 Maker = lilv_node_as_string(nd);
723 path = lilv_node_as_string(lilv_plugin_get_uri(plugin));
724 const LilvPluginClass* cls = lilv_plugin_get_class(plugin);
726 std::vector<Glib::ustring> cats;
727 const LilvPluginClasses* pclasses = lilv_world_get_plugin_classes(world);
729 const LilvNode *pn = lilv_plugin_class_get_parent_uri(cls);
733 const LilvPluginClass* pcls = lilv_plugin_classes_get_by_uri(pclasses, pn);
737 cats.insert(cats.begin(), lilv_node_as_string(lilv_plugin_class_get_label(cls)));
744 PluginDesc::~PluginDesc() {
746 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
778 if (jp.
read_kv(
"UniqueID", UniqueID) ||
781 jp.
read_kv(
"shortname", shortname) ||
783 jp.
read_kv(
"MasterIdx", MasterIdx) ||
784 jp.
read_kv(
"MasterLabel", MasterLabel) ||
788 jp.
read_kv(
"category", category) ||
789 jp.
read_kv(
"deduced_category", deduced_category) ||
790 jp.
read_kv(
"quirks", quirks) ||
791 jp.
read_kv(
"quirks_default", quirks_default) ||
793 jp.
read_kv(
"ladspa_category", ladspa_category) ||
794 jp.
read_kv(
"active", active) ||
795 jp.
read_kv(
"active_set", active_set) ||
797 jp.
read_kv(
"add_wet_dry", add_wet_dry) ||
798 jp.
read_kv(
"stereo_to_mono", stereo_to_mono)) {
804 ctrl_ports.push_back(
new PortDesc(jp));
809 "ladspa::PluginDesc", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
818 jw.
write_kv(
"UniqueID", static_cast<unsigned int>(UniqueID));
821 jw.
write_kv(
"shortname", shortname);
823 jw.
write_kv(
"MasterIdx", MasterIdx);
824 jw.
write_kv(
"MasterLabel", MasterLabel);
829 jw.
write_kv(
"deduced_category", deduced_category);
831 jw.
write_kv(
"quirks_default", quirks_default);
833 jw.
write_kv(
"ladspa_category", ladspa_category);
835 jw.
write_kv(
"active_set", active_set);
837 jw.
write_kv(
"add_wet_dry", add_wet_dry);
838 jw.
write_kv(
"stereo_to_mono", stereo_to_mono);
841 old->serializeJSON(jw);
845 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
846 (*i)->serializeJSON(jw);
854 for (
int i = 0; quirk_list[i].flag; i++) {
855 for (
int j = 0; quirk_list[i].ids[j]; j++) {
856 if (UniqueID == quirk_list[i].
ids[j]) {
857 flag |= quirk_list[i].flag;
873 category = deduced_category;
874 quirks = quirks_default;
877 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
883 assert(ctrl_ports.size() == 0);
884 for (std::vector<PortDesc*>::iterator i = p->
ctrl_ports.begin(); i != p->
ctrl_ports.end(); ++i) {
885 ctrl_ports.push_back(
new PortDesc(**i));
890 void LadspaPluginList::add_plugin(
const LADSPA_Descriptor& desc, pluginmap& d,
const std::string& path,
int index) {
891 for (
unsigned int j = 0; j <
sizeof(blacklist)/
sizeof(blacklist[0]); j++) {
892 if (desc.UniqueID == blacklist[j]) {
897 if (!LADSPA_IS_HARD_RT_CAPABLE(desc.Properties)) {
903 std::vector<PortDesc*> ctrl_ports;
905 for (
unsigned int n = 0; n < desc.PortCount; n++) {
906 LADSPA_PortDescriptor pd = desc.PortDescriptors[n];
907 if (LADSPA_IS_PORT_AUDIO(pd)) {
908 if (LADSPA_IS_PORT_INPUT(pd)) {
914 ctrl_ports.push_back(
new PortDesc(n, pos, LADSPA_IS_PORT_OUTPUT(pd), desc.PortNames[n], desc.PortRangeHints[n]));
919 if (n_in == 1 && n_out == 1) {
921 }
else if (n_in == 2 && n_out == 2) {
924 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
929 d[make_key(desc.UniqueID)] =
new PluginDesc(desc, tp, ctrl_ports, path, index);
933 void LadspaPluginList::load_defs(
const std::string& path, pluginmap& d) {
935 handle = dlopen(path.c_str(), RTLD_LOCAL|RTLD_NOW);
939 ustring::compose(_(
"Cannot open plugin: %1\n"), dlerror()));
942 LADSPA_Descriptor_Function ladspa_descriptor = (LADSPA_Descriptor_Function)dlsym(handle,
"ladspa_descriptor");
943 const char *dlsym_error = dlerror();
952 const LADSPA_Descriptor *desc = ladspa_descriptor(i);
956 add_plugin(*desc, d, path, i);
966 if (UniqueID != old->UniqueID) {
969 if (Label != old->Label) {
972 if (Name != old->Name) {
975 if (shortname != old->shortname) {
978 if (Maker != old->Maker) {
981 if (MasterIdx != old->MasterIdx) {
984 if (MasterIdx > -1 && MasterLabel != old->MasterLabel) {
987 if (add_wet_dry != old->add_wet_dry) {
990 if (stereo_to_mono != old->stereo_to_mono) {
996 if (path != old->path) {
999 if (index != old->index) {
1002 if (category != old->category) {
1005 if (deduced_category != old->deduced_category) {
1008 if (quirks != old->quirks) {
1011 if (quirks_default != old->quirks_default) {
1014 if (ladspa_category != old->ladspa_category) {
1017 for (
unsigned int i = 0; i < ctrl_ports.size(); ++i) {
1026 if (shortname != Name) {
1029 if (category != deduced_category) {
1032 if (quirks != quirks_default) {
1035 if (MasterIdx != -1) {
1038 for (
int i = 0; i < static_cast<int>(ctrl_ports.size()); ++i) {
1039 if (i != ctrl_ports[i]->
get_pos()) {
1058 if (v == active_set) {
1082 for (
unsigned int n = 0; n < ctrl_ports.size(); ++n) {
1083 bool newrow =
false;
1085 newrow = (i % 6 == 0 && i != 0);
1088 ctrl_ports[n]->fixup(newrow);
1095 for (std::vector<ustring>::const_iterator i = s.begin(); i != s.end(); ++i) {
1101 for (
const char *(*p)[2] = cat_subst; (*p)[0]; ++p) {
1102 if (*i == (*p)[0]) {
1103 category = deduced_category = (*p)[1];
1110 ladspa_category = t;
1114 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1115 if ((*p)->idx == idx) {
1116 (*p)->set_default(value, label);
1123 ustring s = shortname;
1129 if (MasterIdx >= 0) {
1130 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1132 if ((*p)->pos == MasterIdx) {
1134 if (sm == (*p)->get_name()) {
1148 jw.
write(add_wet_dry);
1149 jw.
write(stereo_to_mono);
1151 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1166 jw.
write(uint(UniqueID));
1172 ifstream is(fname.c_str());
1174 gx_print_error(
"ladspalist", ustring::compose(_(
"can't open %1"), fname));
1179 jp.
next(JsonParser::begin_array);
1180 jp.
next(JsonParser::value_number);
1182 jp.
next(JsonParser::value_string);
1184 if (shortname.empty()) {
1187 jp.
next(JsonParser::value_string);
1189 jp.
next(JsonParser::value_number);
1191 jp.
next(JsonParser::value_string);
1193 jp.
next(JsonParser::value_number);
1199 jp.
next(JsonParser::value_number);
1201 if (jp.
peek() == JsonParser::value_number) {
1202 jp.
next(JsonParser::value_number);
1205 std::vector<PortDesc*> ports;
1206 jp.
next(JsonParser::begin_array);
1208 int m_idx = MasterIdx;
1209 while (jp.
peek() != JsonParser::end_array) {
1210 jp.
next(JsonParser::begin_array);
1211 jp.
next(JsonParser::value_number);
1213 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1214 if ((*p)->idx == idx) {
1216 MasterIdx = (*p)->pos;
1218 (*p)->set_state(jp, version);
1219 ports.push_back((*p));
1224 jp.
next(JsonParser::end_array);
1226 jp.
next(JsonParser::end_array);
1227 assert(ctrl_ports.size() == ports.size());
1229 jp.
next(JsonParser::end_array);
1230 jp.
next(JsonParser::end_token);
1235 ustring::compose(_(
"error parsing LADSPA plugin config file %1: %2"), fname, e.
what()));
1239 check_has_settings();
1244 old->ctrl_ports.clear();
1245 old->copy_ports(
this);
1254 } ranges_1_based[] = {
1266 world(lilv_world_new()),
1268 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1269 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1270 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1271 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)),
1272 lv2_connectionOptional(lilv_new_uri(world, LV2_CORE__connectionOptional)) {
1273 LilvNode* false_val = lilv_new_bool(world,
false);
1274 lilv_world_set_option(world,LILV_OPTION_DYN_MANIFEST, false_val);
1275 lilv_world_load_all(world);
1276 lv2_plugins = lilv_world_get_all_plugins(world);
1277 lilv_node_free(false_val);
1280 static bool in_1_based_range(
unsigned long uid) {
1281 for (
unsigned int i = 0; i <
sizeof(ranges_1_based)/
sizeof(ranges_1_based[0]); ++i) {
1282 if (uid >= ranges_1_based[i].
from && uid <= ranges_1_based[i].
to) {
1290 void LadspaPluginList::set_instances(
const char *uri, pluginmap& d, std::vector<ustring>& label,
1291 std::vector<unsigned long>& not_found, std::set<unsigned long>& seen) {
1292 lrdf_uris *uris = lrdf_get_instances(uri);
1294 for (
unsigned int i = 0; i < uris->count; ++i) {
1295 const char *u = uris->items[i];
1296 unsigned long uid = lrdf_get_uid(u);
1297 std::string uid_key = make_key(uid);
1298 if (d.find(uid_key) == d.end()) {
1299 not_found.push_back(uid);
1303 if (seen.find(uid) == seen.end()) {
1306 for (
unsigned int n = 0; n < pd->
ctrl_ports.size(); n++) {
1308 lrdf_defaults *sval = lrdf_get_scale_values(uid, p->
idx);
1310 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1311 lrdf_portvalue& t = sval[0].items[nn];
1314 lrdf_free_setting_values(sval);
1315 if (LADSPA_IS_HINT_INTEGER(p->
hint_desc)) {
1320 uri = lrdf_get_default_uri(uid);
1322 lrdf_defaults *sval = lrdf_get_setting_values(uri);
1324 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1325 lrdf_portvalue& t = sval[0].items[nn];
1327 if (in_1_based_range(uid)) {
1332 lrdf_free_setting_values(sval);
1338 lrdf_free_uris(uris);
1343 void LadspaPluginList::descend(
const char *uri, pluginmap& d,
1344 std::vector<unsigned long>& not_found,
1345 std::set<unsigned long>& seen,
1346 std::vector<ustring>& base) {
1347 lrdf_uris *uris = lrdf_get_subclasses(uri);
1349 for (
unsigned int i = 0; i < uris->count; ++i) {
1350 const char *u = uris->items[i];
1351 base.push_back(lrdf_get_label(u));
1352 set_instances(u, d, base, not_found, seen);
1353 descend(u, d, not_found, seen, base);
1356 lrdf_free_uris(uris);
1361 char** LadspaPluginList::uris = NULL;
1362 size_t LadspaPluginList::n_uris = 0;
1364 LV2_URID LadspaPluginList::map_uri(LV2_URID_Map_Handle handle,
const char* uri) {
1365 for (
size_t i = 0; i < n_uris; ++i) {
1366 if (!strcmp(uris[i], uri)) {
1371 uris = (
char**)realloc(uris, ++n_uris *
sizeof(
char*));
1372 uris[n_uris - 1] =
const_cast<char*
>(uri);
1376 const char* LadspaPluginList::unmap_uri(LV2_URID_Map_Handle handle, LV2_URID urid) {
1377 if (urid > 0 && urid <= n_uris) {
1378 return uris[urid - 1];
1383 void LadspaPluginList::get_preset_values(
const char* port_symbol,
1389 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1390 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1391 const char* sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1392 if (strcmp(sym, port_symbol) ==0) {
1393 float fvalue = *(
const float*)value;
1394 Glib::ustring port_id = pdata->
sname ;
1395 pdata->
cline +=
" \"lv2_";
1396 pdata->
cline += port_id ;
1397 pdata->
cline +=
"." ;
1399 pdata->
cline +=
"\": " ;
1401 pdata->
cline +=
"\n";
1407 void LadspaPluginList::set_preset_values(Glib::ustring port_symbol,
1409 Glib::ustring value) {
1410 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1411 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1412 Glib::ustring sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1413 if (sym.compare(port_symbol) ==0) {
1414 Glib::ustring port_id = pdata->
sname ;
1415 pdata->
cline +=
" \"lv2_";
1416 pdata->
cline += port_id ;
1417 pdata->
cline +=
"." ;
1419 pdata->
cline +=
"\": " ;
1420 pdata->
cline += value;
1421 pdata->
cline +=
"\n";
1427 void LadspaPluginList::get_presets(
LV2Preset *pdata) {
1428 LV2_URID_Map map = { NULL, map_uri };
1429 LV2_URID_Unmap unmap = { NULL, unmap_uri };
1430 pdata->
cline =
"[\"gx_plugin_version\", 1,\n";
1431 LilvNodes* presets = lilv_plugin_get_related(pdata->
plugin,
1432 lilv_new_uri(world,LV2_PRESETS__Preset));
1433 LILV_FOREACH(nodes, i, presets) {
1434 const LilvNode* preset = lilv_nodes_get(presets, i);
1435 lilv_world_load_resource(world, preset);
1436 LilvNodes* labels = lilv_world_find_nodes(
1437 world, preset, lilv_new_uri(world, LILV_NS_RDFS
"label"), NULL);
1439 const LilvNode* label = lilv_nodes_get_first(labels);
1441 Glib::ustring
set = lilv_node_as_string(label);
1443 LilvState* state = lilv_state_new_from_world(world, &map, preset);
1444 pdata->
cline +=
" \"" +
set +
"\"" +
" {\n";
1446 Glib::ustring stt = lilv_state_to_string(world,&map,&unmap,state,
"<>",NULL);
1447 std::istringstream stream(stt);
1449 Glib::ustring symbol =
"";
1450 Glib::ustring value =
"";
1451 while (std::getline(stream, st)) {
1452 std::size_t found = st.find(
"lv2:symbol");
1453 if(found !=Glib::ustring::npos) {
1454 std::size_t found1 = st.find(
"\"",found)+1;
1455 std::size_t found2 = st.find(
"\"",found1);
1456 if(found2 !=Glib::ustring::npos) {
1457 symbol = st.substr(found1, (found2-found1));
1462 found = st.find(
"pset:value");
1463 if(found !=Glib::ustring::npos) {
1464 std::size_t found1 = st.find(
" ",found)+1;
1465 if(found1 !=Glib::ustring::npos) {
1466 value = st.substr(found1);
1467 set_preset_values(symbol,pdata,value);
1474 lilv_state_free(state);
1475 pdata->
cline +=
" },\n";
1478 lilv_nodes_free(labels);
1480 lilv_nodes_free(presets);
1486 LilvNodes* requests = lilv_plugin_get_required_features(plugin);
1487 LILV_FOREACH(nodes, f, requests) {
1488 const char* uri = lilv_node_as_uri(lilv_nodes_get(requests, f));
1490 lilv_nodes_free(requests);
1494 lilv_nodes_free(requests);
1498 std::vector<PortDesc*> ctrl_ports;
1500 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
1501 for (
unsigned int n = 0; n < num_ports; n++) {
1502 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
1503 if (lilv_port_is_a(plugin, port, lv2_AudioPort)) {
1504 if (lilv_port_is_a(plugin, port, lv2_InputPort)) {
1509 }
else if (lilv_port_is_a(plugin, port, lv2_ControlPort)) {
1510 LADSPA_PortRangeHint hint;
1511 hint.HintDescriptor = 0;
1512 hint.LowerBound = hint.UpperBound = 0;
1513 LilvNode *pdflt, *pmin, *pmax;
1514 lilv_port_get_range(plugin, port, &pdflt, &pmin, &pmax);
1516 hint.LowerBound = lilv_node_as_float(pmin);
1517 hint.HintDescriptor |= LADSPA_HINT_BOUNDED_BELOW;
1518 lilv_node_free(pmin);
1521 hint.UpperBound = lilv_node_as_float(pmax);
1522 hint.HintDescriptor |= LADSPA_HINT_BOUNDED_ABOVE;
1523 lilv_node_free(pmax);
1525 LilvNode* nm = lilv_port_get_name(plugin, port);
1526 PortDesc *pdesc =
new PortDesc(n, pos, lilv_port_is_a(plugin, port, lv2_OutputPort), lilv_node_as_string(nm), hint);
1530 lilv_node_free(pdflt);
1532 LilvNode* is_int = lilv_new_uri(world, LV2_CORE__integer);
1533 if (lilv_port_has_property(plugin, port, is_int)) {
1536 lilv_node_free(is_int);
1537 LilvNode* is_tog = lilv_new_uri(world, LV2_CORE__toggled);
1538 if (lilv_port_has_property(plugin, port, is_tog)) {
1541 lilv_node_free(is_tog);
1542 LilvScalePoints* sp = lilv_port_get_scale_points(plugin, port);
1543 int num_sp = lilv_scale_points_size(sp);
1545 for (LilvIter* it = lilv_scale_points_begin(sp);
1546 !lilv_scale_points_is_end(sp, it);
1547 it = lilv_scale_points_next(sp, it)) {
1548 const LilvScalePoint* p = lilv_scale_points_get(sp, it);
1550 lilv_node_as_float(lilv_scale_point_get_value(p)),
1551 lilv_node_as_string(lilv_scale_point_get_label(p)));
1555 lilv_scale_points_free(sp);
1556 ctrl_ports.push_back(pdesc);
1559 if (!lilv_port_has_property(plugin, port, lv2_connectionOptional)) {
1566 if (n_in == 1 && n_out == 1) {
1568 }
else if (n_in == 2 && n_out == 2) {
1571 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
1584 PluginDesc* p = d[lilv_node_as_string(lilv_plugin_get_uri(plugin))] =
new PluginDesc(world, plugin, tp, ctrl_ports);
1587 if (p->
path.size() != 0) {
1591 pdata.
plugin =
const_cast<LilvPlugin*
>(plugin);
1592 get_presets(&pdata);
1599 for (LilvIter* it = lilv_plugins_begin(lv2_plugins);
1600 !lilv_plugins_is_end(lv2_plugins, it);
1601 it = lilv_plugins_next(lv2_plugins, it)) {
1602 add_plugin(lilv_plugins_get(lv2_plugins, it), d, options);
1606 pdata.
cline +=
"]\n";
1609 pfile += pdata.
sname;
1610 ofstream os (pfile.c_str());
1621 return ustring(a->
Name) < ustring(b->
Name);
1627 pl.
add(
"/usr/lib/ladspa");
1628 pl.
add(
"/usr/local/lib/ladspa");
1629 pl.
add(
"/usr/lib64/ladspa");
1630 pl.
add(
"/usr/local/lib64/ladspa");
1634 Glib::RefPtr<Gio::File> file = *it;
1635 if (!file->query_exists()) {
1638 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1639 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1640 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1641 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1642 Glib::RefPtr<Gio::FileInfo> file_info;
1644 while ((file_info = child_enumeration->next_file())) {
1645 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/x-sharedlib") {
1646 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1647 if (lib_is_blacklisted(nm)) {
1651 load_defs(Glib::build_filename(file->get_path(), nm), d);
1657 rpl.
add(
"/usr/share/ladspa/rdf");
1658 rpl.
add(
"/usr/local/share/ladspa/rdf");
1662 Glib::RefPtr<Gio::File> file = *it;
1663 if (!file->query_exists()) {
1666 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1667 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1668 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1669 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1670 Glib::RefPtr<Gio::FileInfo> file_info;
1672 while ((file_info = child_enumeration->next_file())) {
1674 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/rdf+xml") {
1675 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1676 if (lib_is_blacklisted(nm)) {
1679 lrdf_read_file((
"file://"+Glib::build_filename(file->get_path(), nm)).c_str());
1683 std::vector<unsigned long> not_found;
1684 std::set<unsigned long> seen;
1685 std::vector<ustring> base;
1686 locale_t loc = newlocale(LC_ALL,
"C", 0);
1688 descend(LADSPA_BASE
"Plugin", d, not_found, seen, base);
1689 uselocale(LC_GLOBAL_LOCALE);
1693 lv2_load(d, options);
1699 jp.
next(JsonParser::begin_array);
1700 while (jp.
peek() == JsonParser::begin_array) {
1701 jp.
next(JsonParser::begin_array);
1702 jp.
next(JsonParser::value_string);
1704 jp.
next(JsonParser::value_number);
1706 jp.
next(JsonParser::value_number);
1709 key = make_key(uid);
1711 if (d.find(key) == d.end()) {
1712 old_not_found.push_back(key);
1714 d[key]->set_active(
true);
1715 d[key]->active_set =
true;
1717 jp.
next(JsonParser::value_string);
1718 jp.
next(JsonParser::end_array);
1723 "ladspalist", ustring::compose(
1724 _(
"error loading ladspa plugin selection data from file %1"),
1729 for (pluginmap::iterator v = d.begin(); v != d.end(); ++v) {
1732 if (v->second->is_lv2) {
1738 if (access(fname.c_str(), F_OK) != 0) {
1740 if (access(fname.c_str(), F_OK) != 0) {
1744 if (!fname.empty()) {
1745 v->second->set_state(fname);
1748 for (pluginmap::iterator i = d.begin(); i != d.end(); ++i) {
1749 push_back(i->second);
1751 std::sort(begin(),
end(), cmp_plugins);
1756 std::string tfname = fname +
".tmp";
1757 ofstream tfile(tfname.c_str());
1759 jw.begin_array(
true);
1760 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1762 (*p)->output_entry(jw);
1768 std::vector<std::pair<std::string,std::string> > fl;
1769 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1770 std::string sname = ((*p)->is_lv2 ?
1774 if ((*p)->active || (*p)->has_settings) {
1775 std::string tcname = cname +
".tmp";
1776 ofstream tcfile(tcname.c_str());
1781 fl.push_back(std::pair<std::string,std::string>(tcname, cname));
1783 fl.push_back(std::pair<std::string,std::string>(
"", cname));
1786 if (rename(tfname.c_str(), fname.c_str()) != 0) {
1788 char *p = strerror_r(errno, buf,
sizeof(buf));
1790 "ladspalist",ustring::compose(_(
"error renaming LADSPA config file '%1': %2"), fname, p));
1793 for (std::vector<std::pair<std::string,std::string> >::iterator i = fl.begin(); i != fl.end(); ++i) {
1794 if (i->first.empty()) {
1795 unlink(i->second.c_str());
1797 if (rename(i->first.c_str(), i->second.c_str()) != 0) {
1799 char *p = strerror_r(errno, buf,
sizeof(buf));
1802 ustring::compose(
"error renaming %1 to %2: %3\n", i->first, i->second, p));
1819 for (iterator i = begin(); i !=
end(); ++i) {
1820 (*i)->serializeJSON(jw);
1826 for (iterator i = begin(); i !=
end(); ++i) {
1831 lilv_node_free(lv2_AudioPort);
1832 lilv_node_free(lv2_ControlPort);
1833 lilv_node_free(lv2_InputPort);
1834 lilv_node_free(lv2_OutputPort);
1835 lilv_node_free(lv2_connectionOptional);
1836 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)
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)
void set_state(const Glib::ustring &fname)
const Glib::ustring & get_name()
void set_add_wet_dry_controller(bool v)
std::map< int, Glib::ustring >::iterator enum_end()
void serializeJSON(gx_system::JsonWriter &jw)
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)
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()
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)
void readJSON(gx_system::JsonParser &jp)
void output_entry(gx_system::JsonWriter &jw)
void save(gx_system::CmdlineOptions &options)
std::string get_plugin_filepath(const std::string &basename) const
void begin_object(bool nl=false)
LADSPA_PortRangeHintDescriptor hint_desc
void set_tp(DisplayType v)
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
void set_default(float value, Glib::ustring label)
void gx_print_warning(const char *, const std::string &)
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)
void set_state(gx_system::JsonParser &jp, int version)
string current_value() const
const std::string & get_lv2_preset_dir() const
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)
void set_tp_default(const LADSPA_PortRangeHint &h, ChangeableValues &store)
float current_value_float()
token next(token expect=no_token)
void write(float v, bool nl=false)
std::map< int, Glib::ustring >::iterator find_enum(int k)
const unsigned long * ids
void end_object(bool nl=false)
std::string encode_filename(const std::string &s)