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), 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), 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) {
777 if (jp.
read_kv(
"UniqueID", UniqueID) ||
780 jp.
read_kv(
"shortname", shortname) ||
782 jp.
read_kv(
"MasterIdx", MasterIdx) ||
783 jp.
read_kv(
"MasterLabel", MasterLabel) ||
787 jp.
read_kv(
"category", category) ||
788 jp.
read_kv(
"deduced_category", deduced_category) ||
789 jp.
read_kv(
"quirks", quirks) ||
790 jp.
read_kv(
"quirks_default", quirks_default) ||
792 jp.
read_kv(
"ladspa_category", ladspa_category) ||
793 jp.
read_kv(
"active", active) ||
794 jp.
read_kv(
"active_set", active_set) ||
796 jp.
read_kv(
"add_wet_dry", add_wet_dry)) {
802 ctrl_ports.push_back(
new PortDesc(jp));
807 "ladspa::PluginDesc", Glib::ustring::compose(
"unknown key: %1", jp.
current_value()));
816 jw.
write_kv(
"UniqueID", static_cast<unsigned int>(UniqueID));
819 jw.
write_kv(
"shortname", shortname);
821 jw.
write_kv(
"MasterIdx", MasterIdx);
822 jw.
write_kv(
"MasterLabel", MasterLabel);
827 jw.
write_kv(
"deduced_category", deduced_category);
829 jw.
write_kv(
"quirks_default", quirks_default);
831 jw.
write_kv(
"ladspa_category", ladspa_category);
833 jw.
write_kv(
"active_set", active_set);
835 jw.
write_kv(
"add_wet_dry", add_wet_dry);
838 old->serializeJSON(jw);
842 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
843 (*i)->serializeJSON(jw);
851 for (
int i = 0; quirk_list[i].flag; i++) {
852 for (
int j = 0; quirk_list[i].ids[j]; j++) {
853 if (UniqueID == quirk_list[i].
ids[j]) {
854 flag |= quirk_list[i].flag;
870 category = deduced_category;
871 quirks = quirks_default;
874 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
880 assert(ctrl_ports.size() == 0);
881 for (std::vector<PortDesc*>::iterator i = p->
ctrl_ports.begin(); i != p->
ctrl_ports.end(); ++i) {
882 ctrl_ports.push_back(
new PortDesc(**i));
887 void LadspaPluginList::add_plugin(
const LADSPA_Descriptor& desc, pluginmap& d,
const std::string& path,
int index) {
888 for (
unsigned int j = 0; j <
sizeof(blacklist)/
sizeof(blacklist[0]); j++) {
889 if (desc.UniqueID == blacklist[j]) {
894 if (!LADSPA_IS_HARD_RT_CAPABLE(desc.Properties)) {
900 std::vector<PortDesc*> ctrl_ports;
902 for (
unsigned int n = 0; n < desc.PortCount; n++) {
903 LADSPA_PortDescriptor pd = desc.PortDescriptors[n];
904 if (LADSPA_IS_PORT_AUDIO(pd)) {
905 if (LADSPA_IS_PORT_INPUT(pd)) {
911 ctrl_ports.push_back(
new PortDesc(n, pos, LADSPA_IS_PORT_OUTPUT(pd), desc.PortNames[n], desc.PortRangeHints[n]));
916 if (n_in == 1 && n_out == 1) {
918 }
else if (n_in == 2 && n_out == 2) {
921 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
926 d[make_key(desc.UniqueID)] =
new PluginDesc(desc, tp, ctrl_ports, path, index);
930 void LadspaPluginList::load_defs(
const std::string& path, pluginmap& d) {
932 handle = dlopen(path.c_str(), RTLD_LOCAL|RTLD_NOW);
936 ustring::compose(_(
"Cannot open plugin: %1\n"), dlerror()));
939 LADSPA_Descriptor_Function ladspa_descriptor = (LADSPA_Descriptor_Function)dlsym(handle,
"ladspa_descriptor");
940 const char *dlsym_error = dlerror();
949 const LADSPA_Descriptor *desc = ladspa_descriptor(i);
953 add_plugin(*desc, d, path, i);
963 if (UniqueID != old->UniqueID) {
966 if (Label != old->Label) {
969 if (Name != old->Name) {
972 if (shortname != old->shortname) {
975 if (Maker != old->Maker) {
978 if (MasterIdx != old->MasterIdx) {
981 if (MasterIdx > -1 && MasterLabel != old->MasterLabel) {
984 if (add_wet_dry != old->add_wet_dry) {
990 if (path != old->path) {
993 if (index != old->index) {
996 if (category != old->category) {
999 if (deduced_category != old->deduced_category) {
1002 if (quirks != old->quirks) {
1005 if (quirks_default != old->quirks_default) {
1008 if (ladspa_category != old->ladspa_category) {
1011 for (
unsigned int i = 0; i < ctrl_ports.size(); ++i) {
1020 if (shortname != Name) {
1023 if (category != deduced_category) {
1026 if (quirks != quirks_default) {
1029 if (MasterIdx != -1) {
1032 for (
int i = 0; i < static_cast<int>(ctrl_ports.size()); ++i) {
1033 if (i != ctrl_ports[i]->
get_pos()) {
1052 if (v == active_set) {
1068 for (
unsigned int n = 0; n < ctrl_ports.size(); ++n) {
1069 bool newrow =
false;
1071 newrow = (i % 6 == 0 && i != 0);
1074 ctrl_ports[n]->fixup(newrow);
1081 for (std::vector<ustring>::const_iterator i = s.begin(); i != s.end(); ++i) {
1087 for (
const char *(*p)[2] = cat_subst; (*p)[0]; ++p) {
1088 if (*i == (*p)[0]) {
1089 category = deduced_category = (*p)[1];
1096 ladspa_category = t;
1100 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1101 if ((*p)->idx == idx) {
1102 (*p)->set_default(value, label);
1109 ustring s = shortname;
1115 if (MasterIdx >= 0) {
1116 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1118 if ((*p)->pos == MasterIdx) {
1120 if (sm == (*p)->get_name()) {
1134 jw.
write(add_wet_dry);
1136 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1151 jw.
write(uint(UniqueID));
1157 ifstream is(fname.c_str());
1159 gx_print_error(
"ladspalist", ustring::compose(_(
"can't open %1"), fname));
1164 jp.
next(JsonParser::begin_array);
1165 jp.
next(JsonParser::value_number);
1167 jp.
next(JsonParser::value_string);
1169 if (shortname.empty()) {
1172 jp.
next(JsonParser::value_string);
1174 jp.
next(JsonParser::value_number);
1176 jp.
next(JsonParser::value_string);
1178 jp.
next(JsonParser::value_number);
1184 jp.
next(JsonParser::value_number);
1186 std::vector<PortDesc*> ports;
1187 jp.
next(JsonParser::begin_array);
1189 int m_idx = MasterIdx;
1190 while (jp.
peek() != JsonParser::end_array) {
1191 jp.
next(JsonParser::begin_array);
1192 jp.
next(JsonParser::value_number);
1194 for (std::vector<PortDesc*>::iterator p = ctrl_ports.begin(); p != ctrl_ports.end(); ++p) {
1195 if ((*p)->idx == idx) {
1197 MasterIdx = (*p)->pos;
1199 (*p)->set_state(jp, version);
1200 ports.push_back((*p));
1205 jp.
next(JsonParser::end_array);
1207 jp.
next(JsonParser::end_array);
1208 assert(ctrl_ports.size() == ports.size());
1210 jp.
next(JsonParser::end_array);
1211 jp.
next(JsonParser::end_token);
1216 ustring::compose(_(
"error parsing LADSPA plugin config file %1: %2"), fname, e.
what()));
1220 check_has_settings();
1225 old->ctrl_ports.clear();
1226 old->copy_ports(
this);
1235 } ranges_1_based[] = {
1247 world(lilv_world_new()),
1249 lv2_AudioPort(lilv_new_uri(world, LV2_CORE__AudioPort)),
1250 lv2_ControlPort(lilv_new_uri(world, LV2_CORE__ControlPort)),
1251 lv2_InputPort(lilv_new_uri(world, LV2_CORE__InputPort)),
1252 lv2_OutputPort(lilv_new_uri(world, LV2_CORE__OutputPort)),
1253 lv2_connectionOptional(lilv_new_uri(world, LV2_CORE__connectionOptional)) {
1254 LilvNode* false_val = lilv_new_bool(world,
false);
1255 lilv_world_set_option(world,LILV_OPTION_DYN_MANIFEST, false_val);
1256 lilv_world_load_all(world);
1257 lv2_plugins = lilv_world_get_all_plugins(world);
1258 lilv_node_free(false_val);
1261 static bool in_1_based_range(
unsigned long uid) {
1262 for (
unsigned int i = 0; i <
sizeof(ranges_1_based)/
sizeof(ranges_1_based[0]); ++i) {
1263 if (uid >= ranges_1_based[i].
from && uid <= ranges_1_based[i].
to) {
1271 void LadspaPluginList::set_instances(
const char *uri, pluginmap& d, std::vector<ustring>& label,
1272 std::vector<unsigned long>& not_found, std::set<unsigned long>& seen) {
1273 lrdf_uris *uris = lrdf_get_instances(uri);
1275 for (
unsigned int i = 0; i < uris->count; ++i) {
1276 const char *u = uris->items[i];
1277 unsigned long uid = lrdf_get_uid(u);
1278 std::string uid_key = make_key(uid);
1279 if (d.find(uid_key) == d.end()) {
1280 not_found.push_back(uid);
1284 if (seen.find(uid) == seen.end()) {
1287 for (
unsigned int n = 0; n < pd->
ctrl_ports.size(); n++) {
1289 lrdf_defaults *sval = lrdf_get_scale_values(uid, p->
idx);
1291 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1292 lrdf_portvalue& t = sval[0].items[nn];
1295 lrdf_free_setting_values(sval);
1296 if (LADSPA_IS_HINT_INTEGER(p->
hint_desc)) {
1301 uri = lrdf_get_default_uri(uid);
1303 lrdf_defaults *sval = lrdf_get_setting_values(uri);
1305 for (
unsigned int nn = 0; nn < sval[0].count; nn++) {
1306 lrdf_portvalue& t = sval[0].items[nn];
1308 if (in_1_based_range(uid)) {
1313 lrdf_free_setting_values(sval);
1319 lrdf_free_uris(uris);
1324 void LadspaPluginList::descend(
const char *uri, pluginmap& d,
1325 std::vector<unsigned long>& not_found,
1326 std::set<unsigned long>& seen,
1327 std::vector<ustring>& base) {
1328 lrdf_uris *uris = lrdf_get_subclasses(uri);
1330 for (
unsigned int i = 0; i < uris->count; ++i) {
1331 const char *u = uris->items[i];
1332 base.push_back(lrdf_get_label(u));
1333 set_instances(u, d, base, not_found, seen);
1334 descend(u, d, not_found, seen, base);
1337 lrdf_free_uris(uris);
1342 char** LadspaPluginList::uris = NULL;
1343 size_t LadspaPluginList::n_uris = 0;
1345 LV2_URID LadspaPluginList::map_uri(LV2_URID_Map_Handle handle,
const char* uri) {
1346 for (
size_t i = 0; i < n_uris; ++i) {
1347 if (!strcmp(uris[i], uri)) {
1352 uris = (
char**)realloc(uris, ++n_uris *
sizeof(
char*));
1353 uris[n_uris - 1] =
const_cast<char*
>(uri);
1357 const char* LadspaPluginList::unmap_uri(LV2_URID_Map_Handle handle, LV2_URID urid) {
1358 if (urid > 0 && urid <= n_uris) {
1359 return uris[urid - 1];
1364 void LadspaPluginList::get_preset_values(
const char* port_symbol,
1370 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1371 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1372 const char* sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1373 if (strcmp(sym, port_symbol) ==0) {
1374 float fvalue = *(
const float*)value;
1375 Glib::ustring port_id = pdata->
sname ;
1376 pdata->
cline +=
" \"lv2_";
1377 pdata->
cline += port_id ;
1378 pdata->
cline +=
"." ;
1380 pdata->
cline +=
"\": " ;
1382 pdata->
cline +=
"\n";
1388 void LadspaPluginList::set_preset_values(Glib::ustring port_symbol,
1390 Glib::ustring value) {
1391 for (
unsigned int i=0;i< pdata->
num_ports;i++) {
1392 const LilvPort* port = lilv_plugin_get_port_by_index(pdata->
plugin, i);
1393 Glib::ustring sym = lilv_node_as_string(lilv_port_get_symbol(pdata->
plugin,port));
1394 if (sym.compare(port_symbol) ==0) {
1395 Glib::ustring port_id = pdata->
sname ;
1396 pdata->
cline +=
" \"lv2_";
1397 pdata->
cline += port_id ;
1398 pdata->
cline +=
"." ;
1400 pdata->
cline +=
"\": " ;
1401 pdata->
cline += value;
1402 pdata->
cline +=
"\n";
1408 void LadspaPluginList::get_presets(
LV2Preset *pdata) {
1409 LV2_URID_Map map = { NULL, map_uri };
1410 LV2_URID_Unmap unmap = { NULL, unmap_uri };
1411 pdata->
cline =
"[\"gx_plugin_version\", 1,\n";
1412 LilvNodes* presets = lilv_plugin_get_related(pdata->
plugin,
1413 lilv_new_uri(world,LV2_PRESETS__Preset));
1414 LILV_FOREACH(nodes, i, presets) {
1415 const LilvNode* preset = lilv_nodes_get(presets, i);
1416 lilv_world_load_resource(world, preset);
1417 LilvNodes* labels = lilv_world_find_nodes(
1418 world, preset, lilv_new_uri(world, LILV_NS_RDFS
"label"), NULL);
1420 const LilvNode* label = lilv_nodes_get_first(labels);
1422 Glib::ustring
set = lilv_node_as_string(label);
1424 LilvState* state = lilv_state_new_from_world(world, &map, preset);
1425 pdata->
cline +=
" \"" +
set +
"\"" +
" {\n";
1427 Glib::ustring stt = lilv_state_to_string(world,&map,&unmap,state,
"<>",NULL);
1428 std::istringstream stream(stt);
1430 Glib::ustring symbol =
"";
1431 Glib::ustring value =
"";
1432 while (std::getline(stream, st)) {
1433 std::size_t found = st.find(
"lv2:symbol");
1434 if(found !=Glib::ustring::npos) {
1435 std::size_t found1 = st.find(
"\"",found)+1;
1436 std::size_t found2 = st.find(
"\"",found1);
1437 if(found2 !=Glib::ustring::npos) {
1438 symbol = st.substr(found1, (found2-found1));
1443 found = st.find(
"pset:value");
1444 if(found !=Glib::ustring::npos) {
1445 std::size_t found1 = st.find(
" ",found)+1;
1446 if(found1 !=Glib::ustring::npos) {
1447 value = st.substr(found1);
1448 set_preset_values(symbol,pdata,value);
1455 lilv_state_free(state);
1456 pdata->
cline +=
" },\n";
1459 lilv_nodes_free(labels);
1461 lilv_nodes_free(presets);
1467 LilvNodes* requests = lilv_plugin_get_required_features(plugin);
1468 LILV_FOREACH(nodes, f, requests) {
1469 const char* uri = lilv_node_as_uri(lilv_nodes_get(requests, f));
1471 lilv_nodes_free(requests);
1475 lilv_nodes_free(requests);
1479 std::vector<PortDesc*> ctrl_ports;
1481 unsigned int num_ports = lilv_plugin_get_num_ports(plugin);
1482 for (
unsigned int n = 0; n < num_ports; n++) {
1483 const LilvPort* port = lilv_plugin_get_port_by_index(plugin, n);
1484 if (lilv_port_is_a(plugin, port, lv2_AudioPort)) {
1485 if (lilv_port_is_a(plugin, port, lv2_InputPort)) {
1490 }
else if (lilv_port_is_a(plugin, port, lv2_ControlPort)) {
1491 LADSPA_PortRangeHint hint;
1492 hint.HintDescriptor = 0;
1493 hint.LowerBound = hint.UpperBound = 0;
1494 LilvNode *pdflt, *pmin, *pmax;
1495 lilv_port_get_range(plugin, port, &pdflt, &pmin, &pmax);
1497 hint.LowerBound = lilv_node_as_float(pmin);
1498 hint.HintDescriptor |= LADSPA_HINT_BOUNDED_BELOW;
1499 lilv_node_free(pmin);
1502 hint.UpperBound = lilv_node_as_float(pmax);
1503 hint.HintDescriptor |= LADSPA_HINT_BOUNDED_ABOVE;
1504 lilv_node_free(pmax);
1506 LilvNode* nm = lilv_port_get_name(plugin, port);
1507 PortDesc *pdesc =
new PortDesc(n, pos, lilv_port_is_a(plugin, port, lv2_OutputPort), lilv_node_as_string(nm), hint);
1511 lilv_node_free(pdflt);
1513 LilvNode* is_int = lilv_new_uri(world, LV2_CORE__integer);
1514 if (lilv_port_has_property(plugin, port, is_int)) {
1517 lilv_node_free(is_int);
1518 LilvNode* is_tog = lilv_new_uri(world, LV2_CORE__toggled);
1519 if (lilv_port_has_property(plugin, port, is_tog)) {
1522 lilv_node_free(is_tog);
1523 LilvScalePoints* sp = lilv_port_get_scale_points(plugin, port);
1524 int num_sp = lilv_scale_points_size(sp);
1526 for (LilvIter* it = lilv_scale_points_begin(sp);
1527 !lilv_scale_points_is_end(sp, it);
1528 it = lilv_scale_points_next(sp, it)) {
1529 const LilvScalePoint* p = lilv_scale_points_get(sp, it);
1531 lilv_node_as_float(lilv_scale_point_get_value(p)),
1532 lilv_node_as_string(lilv_scale_point_get_label(p)));
1536 lilv_scale_points_free(sp);
1537 ctrl_ports.push_back(pdesc);
1540 if (!lilv_port_has_property(plugin, port, lv2_connectionOptional)) {
1547 if (n_in == 1 && n_out == 1) {
1549 }
else if (n_in == 2 && n_out == 2) {
1552 for (std::vector<PortDesc*>::iterator i = ctrl_ports.begin(); i != ctrl_ports.end(); ++i) {
1565 PluginDesc* p = d[lilv_node_as_string(lilv_plugin_get_uri(plugin))] =
new PluginDesc(world, plugin, tp, ctrl_ports);
1568 if (p->
path.size() != 0) {
1572 pdata.
plugin =
const_cast<LilvPlugin*
>(plugin);
1573 get_presets(&pdata);
1580 for (LilvIter* it = lilv_plugins_begin(lv2_plugins);
1581 !lilv_plugins_is_end(lv2_plugins, it);
1582 it = lilv_plugins_next(lv2_plugins, it)) {
1583 add_plugin(lilv_plugins_get(lv2_plugins, it), d, options);
1587 pdata.
cline +=
"]\n";
1590 pfile += pdata.
sname;
1591 ofstream os (pfile.c_str());
1602 return ustring(a->
Name) < ustring(b->
Name);
1608 pl.
add(
"/usr/lib/ladspa");
1609 pl.
add(
"/usr/local/lib/ladspa");
1610 pl.
add(
"/usr/lib64/ladspa");
1611 pl.
add(
"/usr/local/lib64/ladspa");
1615 Glib::RefPtr<Gio::File> file = *it;
1616 if (!file->query_exists()) {
1619 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1620 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1621 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1622 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1623 Glib::RefPtr<Gio::FileInfo> file_info;
1625 while ((file_info = child_enumeration->next_file())) {
1626 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/x-sharedlib") {
1627 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1628 if (lib_is_blacklisted(nm)) {
1632 load_defs(Glib::build_filename(file->get_path(), nm), d);
1638 rpl.
add(
"/usr/share/ladspa/rdf");
1639 rpl.
add(
"/usr/local/share/ladspa/rdf");
1643 Glib::RefPtr<Gio::File> file = *it;
1644 if (!file->query_exists()) {
1647 Glib::RefPtr<Gio::FileEnumerator> child_enumeration =
1648 file->enumerate_children(G_FILE_ATTRIBUTE_STANDARD_NAME
1649 "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
1650 "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
1651 Glib::RefPtr<Gio::FileInfo> file_info;
1653 while ((file_info = child_enumeration->next_file())) {
1655 if (file_info->get_attribute_string(G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) ==
"application/rdf+xml") {
1656 std::string nm = file_info->get_attribute_byte_string(G_FILE_ATTRIBUTE_STANDARD_NAME);
1657 if (lib_is_blacklisted(nm)) {
1660 lrdf_read_file((
"file://"+Glib::build_filename(file->get_path(), nm)).c_str());
1664 std::vector<unsigned long> not_found;
1665 std::set<unsigned long> seen;
1666 std::vector<ustring> base;
1667 locale_t loc = newlocale(LC_ALL,
"C", 0);
1669 descend(LADSPA_BASE
"Plugin", d, not_found, seen, base);
1670 uselocale(LC_GLOBAL_LOCALE);
1674 lv2_load(d, options);
1680 jp.
next(JsonParser::begin_array);
1681 while (jp.
peek() == JsonParser::begin_array) {
1682 jp.
next(JsonParser::begin_array);
1683 jp.
next(JsonParser::value_string);
1685 jp.
next(JsonParser::value_number);
1687 jp.
next(JsonParser::value_number);
1690 key = make_key(uid);
1692 if (d.find(key) == d.end()) {
1693 old_not_found.push_back(key);
1695 d[key]->set_active(
true);
1696 d[key]->active_set =
true;
1698 jp.
next(JsonParser::value_string);
1699 jp.
next(JsonParser::end_array);
1704 "ladspalist", ustring::compose(
1705 _(
"error loading ladspa plugin selection data from file %1"),
1710 for (pluginmap::iterator v = d.begin(); v != d.end(); ++v) {
1713 if (v->second->is_lv2) {
1719 if (access(fname.c_str(), F_OK) != 0) {
1721 if (access(fname.c_str(), F_OK) != 0) {
1725 if (!fname.empty()) {
1726 v->second->set_state(fname);
1729 for (pluginmap::iterator i = d.begin(); i != d.end(); ++i) {
1730 push_back(i->second);
1732 std::sort(begin(),
end(), cmp_plugins);
1737 std::string tfname = fname +
".tmp";
1738 ofstream tfile(tfname.c_str());
1740 jw.begin_array(
true);
1741 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1743 (*p)->output_entry(jw);
1749 std::vector<std::pair<std::string,std::string> > fl;
1750 for (std::vector<PluginDesc*>::iterator p = begin(); p !=
end(); ++p) {
1751 std::string sname = ((*p)->is_lv2 ?
1755 if ((*p)->active || (*p)->has_settings) {
1756 std::string tcname = cname +
".tmp";
1757 ofstream tcfile(tcname.c_str());
1762 fl.push_back(std::pair<std::string,std::string>(tcname, cname));
1764 fl.push_back(std::pair<std::string,std::string>(
"", cname));
1767 if (rename(tfname.c_str(), fname.c_str()) != 0) {
1769 char *p = strerror_r(errno, buf,
sizeof(buf));
1771 "ladspalist",ustring::compose(_(
"error renaming LADSPA config file '%1': %2"), fname, p));
1774 for (std::vector<std::pair<std::string,std::string> >::iterator i = fl.begin(); i != fl.end(); ++i) {
1775 if (i->first.empty()) {
1776 unlink(i->second.c_str());
1778 if (rename(i->first.c_str(), i->second.c_str()) != 0) {
1780 char *p = strerror_r(errno, buf,
sizeof(buf));
1783 ustring::compose(
"error renaming %1 to %2: %3\n", i->first, i->second, p));
1800 for (iterator i = begin(); i !=
end(); ++i) {
1801 (*i)->serializeJSON(jw);
1807 for (iterator i = begin(); i !=
end(); ++i) {
1812 lilv_node_free(lv2_AudioPort);
1813 lilv_node_free(lv2_ControlPort);
1814 lilv_node_free(lv2_InputPort);
1815 lilv_node_free(lv2_OutputPort);
1816 lilv_node_free(lv2_connectionOptional);
1817 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)
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)