[SCM] calf/master: + LV2: implement some preset extension candidate
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:15 UTC 2013
The following commit has been merged in the master branch:
commit 61113298bf519b5a85811f0d1274d1d20a41c34a
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sun Feb 1 01:43:05 2009 +0000
+ LV2: implement some preset extension candidate
diff --git a/src/calf/preset.h b/src/calf/preset.h
index d2b1dcf..8b5844b 100644
--- a/src/calf/preset.h
+++ b/src/calf/preset.h
@@ -58,6 +58,8 @@ struct plugin_preset
void activate(plugin_ctl_iface *plugin);
/// "Download" preset content from the plugin
void get_from(plugin_ctl_iface *plugin);
+
+ std::string get_safe_name();
};
/// Exception thrown by preset system
diff --git a/src/calf/utils.h b/src/calf/utils.h
index 0ec7bea..efc5fdf 100644
--- a/src/calf/utils.h
+++ b/src/calf/utils.h
@@ -144,6 +144,9 @@ extern std::string i2s(int value);
/// float-to-string
extern std::string f2s(double value);
+/// float-to-string-that-doesn't-resemble-an-int
+extern std::string ff2s(double value);
+
/// Escape a string to be used in XML file
std::string xml_escape(const std::string &src);
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index 187ca6b..b69dc8e 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -498,6 +498,8 @@ void make_ttl(string path_prefix)
}
classes["SynthesizerPlugin"] = "lv2:InstrumentPlugin";
+ string plugin_uri_prefix = "http://calf.sourceforge.net/plugins/";
+
string gui_header;
#if USE_LV2_GUI
@@ -520,7 +522,7 @@ void make_ttl(string path_prefix)
for (unsigned int i = 0; i < plugins.size(); i++) {
plugin_metadata_iface *pi = plugins[i];
const ladspa_plugin_info &lpi = pi->get_plugin_info();
- string uri = string("<http://calf.sourceforge.net/plugins/") + string(lpi.label) + ">";
+ string uri = string("<" + plugin_uri_prefix) + string(lpi.label) + ">";
string ttl;
ttl = "@prefix : " + uri + " .\n" + header + gui_header;
@@ -637,6 +639,7 @@ void make_ttl(string path_prefix)
string ttl =
"@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n"
+ "@prefix lv2p: <http://lv2plug.in/ns/dev/presets#> .\n"
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
"@prefix kf: <http://foltman.com/ns/> .\n"
"\n"
@@ -646,8 +649,16 @@ void make_ttl(string path_prefix)
"kf:MIDIPlugin a rdfs:Class ; rdfs:label \"MIDI\" ; rdfs:subClassOf lv2:UtilityPlugin ; rdfs:comment \"\"\"Operations on MIDI streams (filters, transposers, mappers etc.)\"\"\" .\n"
;
+ string presets_ttl =
+ "@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n"
+ "@prefix lv2p: <http://lv2plug.in/ns/dev/presets#> .\n"
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
+ "@prefix dc: <http://dublincore.org/documents/dcmi-namespace/> .\n"
+ "\n"
+ ;
+
for (unsigned int i = 0; i < plugins.size(); i++)
- ttl += string("<http://calf.sourceforge.net/plugins/")
+ ttl += string("<" + plugin_uri_prefix)
+ string(plugins[i]->get_plugin_info().label)
+ "> a lv2:Plugin ; lv2:binary <calf.so> ; rdfs:seeAlso <" + string(plugins[i]->get_plugin_info().label) + ".ttl> .\n";
@@ -656,15 +667,50 @@ void make_ttl(string path_prefix)
+ string(lpl[i]->id)
+ "> a lv2:Plugin ; lv2:binary <calf.so> ; rdfs:seeAlso <" + string(lpl[i]->id) + ".ttl> .\n";
+ calf_plugins::get_builtin_presets().load_defaults(true);
+ calf_plugins::preset_vector &factory_presets = calf_plugins::get_builtin_presets().presets;
+
+ ttl += "\n";
+
+ for (unsigned int i = 0; i < factory_presets.size(); i++)
+ {
+ plugin_preset &pr = factory_presets[i];
+ string uri = "<http://calf.sourceforge.net/factory_presets#"
+ + pr.plugin + "_" + pr.get_safe_name()
+ + ">";
+ ttl += string(uri + " a lv2p:Preset ; rdfs:seeAlso <presets.ttl> .\n");
+
+ presets_ttl += uri +
+ " a lv2p:Preset ;\n"
+ " dc:title \"" + pr.name + "\" ;\n"
+ " lv2p:appliesTo <" + plugin_uri_prefix + pr.plugin + "> ;\n"
+ " lv2p:port \n"
+ ;
+
+ unsigned int count = min(pr.param_names.size(), pr.values.size());
+ for (unsigned int j = 0; j < count; j++)
+ {
+ presets_ttl += " [ lv2p:symbol \"" + pr.param_names[j] + "\" ; lv2p:value " + ff2s(pr.values[j]) + "] ";
+ if (j < count - 1)
+ presets_ttl += ',';
+ presets_ttl += '\n';
+ }
+ presets_ttl += ".\n\n";
+ }
FILE *f = fopen((path_prefix+"manifest.ttl").c_str(), "w");
fprintf(f, "%s\n", ttl.c_str());
fclose(f);
+ f = fopen((path_prefix+"presets.ttl").c_str(), "w");
+ fprintf(f, "%s\n", presets_ttl.c_str());
+ fclose(f);
}
+
#else
void make_ttl(string tmp)
{
fprintf(stderr, "LV2 not supported.\n");
}
+
#endif
void make_gui(string path_prefix)
diff --git a/src/preset.cpp b/src/preset.cpp
index 02fb383..919747d 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -65,6 +65,17 @@ std::string plugin_preset::to_xml()
return ss.str();
}
+string plugin_preset::get_safe_name()
+{
+ stringstream ss;
+ for (size_t i = 0; i < name.length(); i++)
+ {
+ if (isdigit(name[i]) || isalpha(name[i]))
+ ss << name[i];
+ }
+ return ss.str();
+}
+
void plugin_preset::activate(plugin_ctl_iface *plugin)
{
// First, clear everything to default values (in case some parameters or variables are missing)
diff --git a/src/utils.cpp b/src/utils.cpp
index 0a5dacf..ed3fcf6 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -97,12 +97,19 @@ std::string i2s(int value)
std::string f2s(double value)
{
- // XXXKF might not work with some locale settings
stringstream ss;
ss << value;
return ss.str();
}
+std::string ff2s(double value)
+{
+ string s = f2s(value);
+ if (s.find('.') == string::npos)
+ s += ".0";
+ return s;
+}
+
std::string indent(const std::string &src, const std::string &indent)
{
std::string dest;
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list