cannam@138
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@138
|
2
|
cannam@231
|
3 #include <vamp-hostsdk/PluginHostAdapter.h>
|
cannam@233
|
4 #include <vamp-hostsdk/PluginChannelAdapter.h>
|
cannam@233
|
5 #include <vamp-hostsdk/PluginInputDomainAdapter.h>
|
cannam@233
|
6 #include <vamp-hostsdk/PluginLoader.h>
|
cannam@231
|
7 #include <vamp/vamp.h>
|
cannam@138
|
8
|
cannam@138
|
9 #include <iostream>
|
cannam@138
|
10 #include <fstream>
|
cannam@138
|
11 #include <sstream>
|
cannam@138
|
12
|
cannam@138
|
13 #include <cmath>
|
cannam@232
|
14 #include <cstdlib>
|
cannam@232
|
15 #include <cstring>
|
cannam@138
|
16
|
cannam@138
|
17 using std::cout;
|
cannam@138
|
18 using std::cin;
|
cannam@138
|
19 using std::cerr;
|
cannam@138
|
20 using std::getline;
|
cannam@138
|
21 using std::endl;
|
cannam@138
|
22 using std::string;
|
cannam@138
|
23 using std::vector;
|
cannam@138
|
24 using std::ofstream;
|
cannam@138
|
25 using std::ios;
|
cannam@138
|
26
|
cannam@138
|
27 using Vamp::HostExt::PluginLoader;
|
cannam@138
|
28 using Vamp::Plugin;
|
cannam@138
|
29
|
cannam@217
|
30 //???
|
cannam@138
|
31 string programURI = "http://www.vamp-plugins.org/doap.rdf#template-generator";
|
cannam@138
|
32
|
cannam@138
|
33 void usage()
|
cannam@138
|
34 {
|
cannam@217
|
35 cerr << endl;
|
cannam@217
|
36 cerr << "template-generator: Create a skeleton RDF description file describing a Vamp" << endl;
|
cannam@217
|
37 cerr << "plugin library using the Vamp ontology." << endl;
|
cannam@217
|
38 cerr << endl;
|
cannam@217
|
39 cerr << "Usage:" << endl;
|
cannam@217
|
40 cerr << " template-generator -i vamp:soname[:plugin] [vamp:soname[:plugin] ...]" << endl;
|
cannam@217
|
41 cerr << " template-generator PLUGIN_BASE_URI [ -m YOUR_URI ] [vamp:]soname[:plugin] [[vamp:]soname[:plugin] ...]" << endl;
|
cannam@217
|
42 cerr << endl;
|
cannam@217
|
43 cerr << "Example:" << endl;
|
cannam@217
|
44 cerr << " template-generator http://vamp-plugins.org/rdf/plugins/ vamp-example-plugins" << endl;
|
cannam@217
|
45 cerr << endl;
|
cannam@138
|
46 exit(2);
|
cannam@138
|
47 }
|
cannam@138
|
48
|
cannam@138
|
49 template <class T>
|
cannam@138
|
50 inline string to_string (const T& t)
|
cannam@138
|
51 {
|
cannam@138
|
52 std::stringstream ss;
|
cannam@138
|
53 ss << t;
|
cannam@138
|
54 return ss.str();
|
cannam@138
|
55 }
|
cannam@138
|
56
|
cannam@144
|
57 string describe_namespaces(string pluginBundleBaseURI, string libname)
|
cannam@138
|
58 {
|
cannam@142
|
59 string res=\
|
cannam@142
|
60 "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
|
cannam@138
|
61 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\
|
cannam@147
|
62 @prefix vamp: <http://purl.org/ontology/vamp/> .\n\
|
cannam@144
|
63 @prefix plugbase: <"+pluginBundleBaseURI+libname+"#> .\n\
|
cannam@138
|
64 @prefix owl: <http://www.w3.org/2002/07/owl#> .\n\
|
cannam@138
|
65 @prefix dc: <http://purl.org/dc/elements/1.1/> .\n\
|
cannam@138
|
66 @prefix af: <http://purl.org/ontology/af/> .\n\
|
cannam@138
|
67 @prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\
|
cannam@138
|
68 @prefix cc: <http://web.resource.org/cc/> .\n\
|
cannam@138
|
69 @prefix : <> .\n\n";
|
cannam@138
|
70
|
cannam@142
|
71 return res;
|
cannam@138
|
72 }
|
cannam@138
|
73
|
cannam@144
|
74 string describe_doc(string describerURI, string pluginBundleBaseURI,
|
cannam@144
|
75 string libname)
|
cannam@138
|
76 {
|
cannam@142
|
77 string res=\
|
cannam@217
|
78 "<> a vamp:PluginDescription ;\n";
|
cannam@217
|
79 if (describerURI != "") {
|
cannam@217
|
80 res += " foaf:maker <"+describerURI+"> ;\n";
|
cannam@217
|
81 }
|
cannam@217
|
82 res += "\
|
cannam@144
|
83 foaf:maker <"+programURI+"> ;\n\
|
cannam@144
|
84 foaf:primaryTopic <"+pluginBundleBaseURI+libname+"> .\n\n";
|
cannam@142
|
85 return res;
|
cannam@138
|
86 }
|
cannam@138
|
87
|
cannam@138
|
88
|
cannam@144
|
89 string describe_library(string libname, vector<Plugin *> plugins)
|
cannam@144
|
90 {
|
cannam@144
|
91 string res=\
|
cannam@144
|
92 ":"+libname+" a vamp:PluginLibrary ;\n\
|
cannam@144
|
93 vamp:identifier \""+libname+"\" ";
|
cannam@144
|
94
|
cannam@144
|
95 for (size_t i = 0; i < plugins.size(); ++i) {
|
cannam@218
|
96 res += " ; \n\
|
cannam@145
|
97 vamp:available_plugin plugbase:"+plugins[i]->getIdentifier();
|
cannam@144
|
98 }
|
cannam@144
|
99
|
cannam@218
|
100 res += " ; \n\
|
cannam@218
|
101 # foaf:page <Place more-information HTML page URL here and uncomment> ;\n\
|
cannam@218
|
102 .\n\n";
|
cannam@144
|
103 return res;
|
cannam@144
|
104 }
|
cannam@144
|
105
|
cannam@138
|
106 string describe_plugin(Plugin* plugin)
|
cannam@138
|
107 {
|
cannam@142
|
108 string res=\
|
cannam@142
|
109 "plugbase:"+plugin->getIdentifier()+" a vamp:Plugin ;\n\
|
cannam@138
|
110 dc:title \""+plugin->getName()+"\" ;\n\
|
cannam@139
|
111 vamp:name \""+plugin->getName()+"\" ;\n\
|
cannam@221
|
112 dc:description \"\"\""+plugin->getDescription()+"\"\"\" ;\n\
|
cannam@154
|
113 foaf:maker [ foaf:name \""+plugin->getMaker()+"\" ] ; # FIXME could give plugin author's URI here\n\
|
cannam@224
|
114 dc:rights \"\"\""+plugin->getCopyright()+"\"\"\" ;\n\
|
cannam@154
|
115 # cc:license <Place plugin license URI here and uncomment> ; \n\
|
cannam@138
|
116 vamp:identifier \""+plugin->getIdentifier()+"\" ;\n\
|
cannam@138
|
117 vamp:vamp_API_version vamp:api_version_"+to_string(plugin->getVampApiVersion())+" ;\n\
|
cannam@138
|
118 owl:versionInfo \""+to_string(plugin->getPluginVersion())+"\" ;\n";
|
cannam@142
|
119 if (plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain)
|
cannam@142
|
120 res+=" vamp:input_domain vamp:FrequencyDomain ;\n\n";
|
cannam@142
|
121 else
|
cannam@194
|
122 res+=" vamp:input_domain vamp:TimeDomain ;\n";
|
cannam@138
|
123
|
cannam@138
|
124
|
cannam@142
|
125 Plugin::ParameterList params = plugin->getParameterDescriptors();
|
cannam@194
|
126 if (!params.empty()) res+="\n";
|
cannam@142
|
127 for (Plugin::ParameterList::const_iterator i = params.begin(); i != params.end(); i++)
|
dpastor@156
|
128 res+=" vamp:parameter plugbase:"+plugin->getIdentifier()+"_param_"+(*i).identifier+" ;\n";
|
cannam@194
|
129 if (!params.empty()) res+="\n";
|
cannam@138
|
130
|
cannam@142
|
131 Plugin::OutputList outputs = plugin->getOutputDescriptors();
|
cannam@142
|
132 for (Plugin::OutputList::const_iterator i = outputs.begin(); i!= outputs.end(); i++)
|
cannam@158
|
133 res+=" vamp:output plugbase:"+plugin->getIdentifier()+"_output_"+(*i).identifier+" ;\n";
|
cannam@142
|
134 res+=" .\n";
|
cannam@138
|
135
|
cannam@142
|
136 return res;
|
cannam@138
|
137 }
|
cannam@138
|
138
|
cannam@144
|
139 string describe_param(Plugin *plugin, Plugin::ParameterDescriptor p)
|
cannam@138
|
140 {
|
cannam@148
|
141
|
cannam@148
|
142 //FIXME: dc:format and vamp:unit are the same???
|
dpastor@157
|
143 //Should be a QUantizedParameter also a Parameter??
|
cannam@148
|
144 if(p.isQuantized){
|
cannam@148
|
145 string res=\
|
dpastor@156
|
146 "plugbase:"+plugin->getIdentifier()+"_param_"+p.identifier+" a vamp:QuantizedParameter ;\n\
|
cannam@148
|
147 vamp:identifier \""+p.identifier+"\" ;\n\
|
cannam@148
|
148 dc:title \""+p.name+"\" ;\n\
|
cannam@148
|
149 dc:format \""+p.unit+"\" ;\n\
|
cannam@148
|
150 vamp:min_value "+to_string(p.minValue)+" ;\n\
|
cannam@148
|
151 vamp:max_value "+to_string(p.maxValue)+" ;\n\
|
cannam@148
|
152 vamp:unit \""+p.unit+"\" ;\n\
|
cannam@152
|
153 vamp:quantize_step "+to_string(p.quantizeStep)+" ;\n\
|
cannam@148
|
154 vamp:default_value "+to_string(p.defaultValue)+" ;\n\
|
cannam@148
|
155 vamp:value_names (";
|
cannam@148
|
156
|
cannam@148
|
157 unsigned int i;
|
cannam@148
|
158 for (i=0; i+1 < p.valueNames.size(); i++)
|
cannam@148
|
159 res+=" \""+p.valueNames[i]+"\"";
|
cannam@148
|
160 if (i < p.valueNames.size())
|
cannam@148
|
161 res+=" \""+p.valueNames[i]+"\"";
|
cannam@148
|
162 res+=");\n";
|
cannam@148
|
163
|
cannam@148
|
164 res+=" .\n";
|
cannam@148
|
165
|
cannam@148
|
166 return res;
|
cannam@148
|
167
|
cannam@148
|
168 }else{
|
cannam@142
|
169 string res=\
|
dpastor@156
|
170 "plugbase:"+plugin->getIdentifier()+"_param_"+p.identifier+" a vamp:Parameter ;\n\
|
cannam@138
|
171 vamp:identifier \""+p.identifier+"\" ;\n\
|
cannam@138
|
172 dc:title \""+p.name+"\" ;\n\
|
cannam@138
|
173 dc:format \""+p.unit+"\" ;\n\
|
cannam@139
|
174 vamp:min_value "+to_string(p.minValue)+" ;\n\
|
cannam@139
|
175 vamp:max_value "+to_string(p.maxValue)+" ;\n\
|
cannam@148
|
176 vamp:unit \""+p.unit+"\" ;\n\
|
cannam@148
|
177 vamp:default_value "+to_string(p.defaultValue)+" ;\n\
|
cannam@148
|
178 vamp:value_names (";
|
cannam@148
|
179
|
cannam@148
|
180 unsigned int i;
|
cannam@148
|
181 for (i=0; i+1 < p.valueNames.size(); i++)
|
cannam@148
|
182 res+=" \""+p.valueNames[i]+"\"";
|
cannam@148
|
183 if (i < p.valueNames.size())
|
cannam@148
|
184 res+=" \""+p.valueNames[i]+"\"";
|
cannam@148
|
185 res+=");\n";
|
cannam@148
|
186
|
cannam@148
|
187 res+=" .\n";
|
cannam@148
|
188
|
cannam@142
|
189 return res;
|
cannam@148
|
190
|
cannam@148
|
191 }
|
cannam@138
|
192 }
|
cannam@138
|
193
|
cannam@144
|
194 string describe_output(Plugin *plugin, Plugin::OutputDescriptor o)
|
cannam@138
|
195 {
|
cannam@138
|
196
|
cannam@142
|
197 //we need to distinguish here between different output types:
|
cannam@148
|
198
|
cannam@148
|
199 //Quantize or not
|
cannam@148
|
200 //KnownExtents or not
|
cannam@148
|
201 //Data output classification:
|
cannam@142
|
202 //DenseOutput
|
cannam@142
|
203 //SparseOutput
|
cannam@142
|
204 //TrackLevelOutput
|
cannam@139
|
205
|
cannam@139
|
206
|
cannam@168
|
207 // SparseOutput: variable sample rate. Events are not evenly
|
cannam@168
|
208 // spaced so we need to record the time associated with the event
|
cannam@168
|
209 // as it its not ensured that we have an event after the next one
|
cannam@168
|
210 // (but there is not time to set the duration, it has to be
|
cannam@168
|
211 // calculated as the different between 2 different events). The
|
cannam@168
|
212 // timestamp must be read.
|
cannam@139
|
213
|
cannam@142
|
214 string res;
|
cannam@139
|
215
|
cannam@168
|
216 if (o.sampleType == Plugin::OutputDescriptor::VariableSampleRate ||
|
cannam@168
|
217 !o.hasFixedBinCount)
|
cannam@142
|
218 {
|
cannam@139
|
219
|
cannam@142
|
220 res=\
|
cannam@144
|
221 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:SparseOutput ;\n\
|
cannam@139
|
222 vamp:identifier \""+o.identifier+"\" ;\n\
|
cannam@139
|
223 dc:title \""+o.name+"\" ;\n\
|
cannam@139
|
224 dc:description \""+o.description+"\" ;\n\
|
cannam@139
|
225 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\
|
cannam@139
|
226 vamp:unit \""+(o.unit)+"\" ;\n";
|
cannam@139
|
227
|
cannam@148
|
228
|
cannam@148
|
229 //another type of output
|
cannam@148
|
230 if(o.isQuantized){
|
cannam@148
|
231
|
cannam@148
|
232 res+=" a vamp:QuantizedOutput ;\n";
|
cannam@148
|
233 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
|
cannam@148
|
234 }
|
cannam@148
|
235
|
cannam@148
|
236 //and yet another type
|
cannam@148
|
237 if(o.hasKnownExtents){
|
cannam@148
|
238
|
cannam@148
|
239 res+=" a vamp:KnownExtentsOutput ;\n";
|
cannam@148
|
240 res+=" vamp:min_value "+to_string(o.minValue)+" ;\n";
|
cannam@148
|
241 res+=" vamp:max_value "+to_string(o.maxValue)+" ;\n";
|
cannam@148
|
242 }
|
cannam@139
|
243
|
cannam@142
|
244 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading...
|
cannam@142
|
245 if (o.hasFixedBinCount)
|
cannam@142
|
246 {
|
cannam@144
|
247 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n";
|
cannam@144
|
248 res+=" vamp:bin_names (";
|
cannam@138
|
249
|
cannam@142
|
250 unsigned int i;
|
cannam@142
|
251 for (i=0; i+1 < o.binNames.size(); i++)
|
cannam@142
|
252 res+=" \""+o.binNames[i]+"\"";
|
cannam@142
|
253 if (i < o.binNames.size())
|
cannam@142
|
254 res+=" \""+o.binNames[i]+"\"";
|
cannam@142
|
255 res+=");\n";
|
cannam@142
|
256 }
|
cannam@148
|
257
|
cannam@144
|
258 res+=" vamp:sample_type vamp:VariableSampleRate ;\n";
|
cannam@142
|
259 if (o.sampleRate > 0.0f)
|
cannam@144
|
260 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n";
|
cannam@142
|
261
|
cannam@142
|
262 }
|
cannam@139
|
263
|
cannam@142
|
264 //If we do not have SparseOutput, then we have DenseOutput. TrackLevelOutput can not be inferred from the plugin directly without actually
|
cannam@142
|
265 //running the plugin.
|
cannam@142
|
266 else{
|
cannam@142
|
267
|
cannam@142
|
268 res=\
|
cannam@144
|
269 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:DenseOutput ;\n\
|
cannam@139
|
270 vamp:identifier \""+o.identifier+"\" ;\n\
|
cannam@139
|
271 dc:title \""+o.name+"\" ;\n\
|
cannam@139
|
272 dc:description \""+o.description+"\" ;\n\
|
cannam@139
|
273 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\
|
cannam@139
|
274 vamp:unit \""+(o.unit)+"\" ;\n";
|
cannam@139
|
275
|
cannam@139
|
276
|
cannam@148
|
277 //another type of output
|
cannam@148
|
278 if(o.isQuantized){
|
cannam@148
|
279
|
cannam@148
|
280 res+=" a vamp:QuantizedOutput ;\n";
|
cannam@148
|
281 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
|
cannam@148
|
282 }
|
cannam@148
|
283
|
cannam@148
|
284 //and yet another type
|
cannam@148
|
285 if(o.hasKnownExtents){
|
cannam@148
|
286
|
cannam@148
|
287 res+=" a vamp:KnownExtentsOutput ;\n";
|
cannam@148
|
288 res+=" vamp:min_value "+to_string(o.minValue)+" ;\n";
|
cannam@148
|
289 res+=" vamp:max_value "+to_string(o.maxValue)+" ;\n";
|
cannam@148
|
290 }
|
cannam@139
|
291
|
cannam@142
|
292 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading...
|
cannam@142
|
293 if (o.hasFixedBinCount)
|
cannam@142
|
294 {
|
cannam@144
|
295 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n";
|
cannam@144
|
296 res+=" vamp:bin_names (";
|
cannam@139
|
297
|
cannam@142
|
298 unsigned int i;
|
cannam@142
|
299 for (i=0; i+1 < o.binNames.size(); i++)
|
cannam@142
|
300 res+=" \""+o.binNames[i]+"\"";
|
cannam@142
|
301 if (i < o.binNames.size())
|
cannam@142
|
302 res+=" \""+o.binNames[i]+"\"";
|
cannam@142
|
303 res+=");\n";
|
cannam@139
|
304 }
|
cannam@139
|
305
|
cannam@142
|
306 else if (o.sampleType == Plugin::OutputDescriptor::FixedSampleRate)
|
cannam@142
|
307 {
|
cannam@144
|
308 res+=" vamp:sample_type vamp:FixedSampleRate ;\n";
|
cannam@144
|
309 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n";
|
cannam@142
|
310 }
|
cannam@142
|
311 else if (o.sampleType == Plugin::OutputDescriptor::OneSamplePerStep)
|
cannam@144
|
312 res+=" vamp:sample_type vamp:OneSamplePerStep ;\n";
|
cannam@142
|
313 else
|
cannam@142
|
314 {
|
cannam@142
|
315 cerr<<"Incomprehensible sampleType for output descriptor "+o.identifier<<" !"<<endl;
|
cannam@142
|
316 exit(1);
|
cannam@142
|
317 }
|
cannam@142
|
318 }
|
cannam@142
|
319
|
cannam@142
|
320 //There is no way to know this in advance, but we can use the km a bit for this.
|
cannam@159
|
321 res+="# vamp:computes_event_type <Place event type URI here and uncomment> ;\n";
|
cannam@159
|
322 res+="# vamp:computes_feature <Place feature attribute URI here and uncomment> ;\n";
|
cannam@159
|
323 res+="# vamp:computes_signal_type <Place signal type URI here and uncomment> ;\n";
|
cannam@142
|
324 res+=" .\n";
|
cannam@142
|
325
|
cannam@142
|
326 return res;
|
cannam@138
|
327 }
|
cannam@139
|
328
|
cannam@144
|
329 string describe(vector<Plugin *> plugins, string pluginBundleBaseURI,
|
cannam@144
|
330 string describerURI, string libname)
|
cannam@138
|
331 {
|
cannam@144
|
332 string res = describe_namespaces(pluginBundleBaseURI, libname);
|
cannam@138
|
333
|
cannam@144
|
334 res += describe_doc(describerURI, pluginBundleBaseURI, libname);
|
cannam@138
|
335
|
cannam@144
|
336 res += describe_library(libname, plugins);
|
cannam@144
|
337
|
cannam@144
|
338 for (size_t i = 0; i < plugins.size(); ++i) {
|
cannam@144
|
339
|
cannam@144
|
340 Plugin *plugin = plugins[i];
|
cannam@144
|
341
|
cannam@144
|
342 res += describe_plugin(plugin);
|
cannam@138
|
343
|
cannam@144
|
344 Plugin::ParameterList params = plugin->getParameterDescriptors();
|
cannam@144
|
345 for (Plugin::ParameterList::const_iterator i = params.begin(); i != params.end(); i++)
|
cannam@144
|
346 res += describe_param(plugin, *i);
|
cannam@138
|
347
|
cannam@144
|
348 Plugin::OutputList outputs = plugin->getOutputDescriptors();
|
cannam@144
|
349 for (Plugin::OutputList::const_iterator i = outputs.begin(); i!= outputs.end(); i++)
|
cannam@144
|
350 res += describe_output(plugin, *i);
|
cannam@144
|
351 }
|
cannam@138
|
352
|
cannam@142
|
353 return res;
|
cannam@138
|
354 }
|
cannam@138
|
355
|
cannam@138
|
356 int main(int argc, char **argv)
|
cannam@138
|
357 {
|
cannam@144
|
358 if (argc < 3) usage();
|
cannam@138
|
359
|
cannam@144
|
360 bool interactive = false;
|
cannam@144
|
361 if (!strcmp(argv[1], "-i")) interactive = true;
|
cannam@138
|
362
|
cannam@217
|
363 if (!interactive && argc < 3) usage();
|
cannam@138
|
364
|
cannam@138
|
365 string pluginBundleBaseURI, describerURI;
|
cannam@144
|
366
|
cannam@144
|
367 int argidx = 2;
|
cannam@138
|
368
|
cannam@144
|
369 if (!interactive) {
|
cannam@138
|
370 pluginBundleBaseURI = argv[1];
|
cannam@217
|
371 if (!strcmp(argv[2], "-m")) {
|
cannam@217
|
372 if (argc < 5) usage();
|
cannam@217
|
373 describerURI = argv[3];
|
cannam@217
|
374 argidx = 4;
|
cannam@217
|
375 }
|
cannam@144
|
376 } else {
|
cannam@138
|
377 cerr << "Please enter the base URI for the plugin bundle : ";
|
cannam@138
|
378 getline(cin, pluginBundleBaseURI);
|
cannam@217
|
379 cerr << "Please enter your URI (empty to omit) : ";
|
cannam@138
|
380 getline(cin, describerURI);
|
cannam@138
|
381 }
|
cannam@144
|
382
|
cannam@144
|
383 vector<Plugin *> plugins;
|
cannam@144
|
384 string libname;
|
cannam@144
|
385
|
cannam@144
|
386 PluginLoader *loader = PluginLoader::getInstance();
|
cannam@144
|
387
|
cannam@144
|
388 while (argidx < argc) {
|
cannam@144
|
389
|
cannam@144
|
390 string pluginName = argv[argidx];
|
cannam@144
|
391
|
cannam@144
|
392 if (pluginName.substr(0, 5) == "vamp:") {
|
cannam@144
|
393 pluginName = pluginName.substr(5);
|
cannam@144
|
394 }
|
cannam@144
|
395
|
cannam@144
|
396 string mylibname = pluginName.substr(0, pluginName.find(':'));
|
cannam@144
|
397
|
cannam@144
|
398 if (libname == "") libname = mylibname;
|
cannam@144
|
399 else if (libname != mylibname) {
|
cannam@144
|
400 cerr << "ERROR: All plugins specified on command line must originate in the same library" << endl;
|
cannam@144
|
401 exit(1);
|
cannam@144
|
402 }
|
cannam@144
|
403
|
cannam@144
|
404 if (mylibname == pluginName) { // pluginName is a library, not a plugin
|
cannam@144
|
405
|
cannam@144
|
406 PluginLoader::PluginKeyList list = loader->listPlugins();
|
cannam@144
|
407 for (size_t i = 0; i < list.size(); ++i) {
|
cannam@144
|
408 string thislibname = list[i].substr(0, list[i].find(':'));
|
cannam@144
|
409 if (thislibname != mylibname) continue;
|
cannam@144
|
410 Plugin *plugin = loader->loadPlugin(list[i], 44100);
|
cannam@144
|
411 if (!plugin) {
|
cannam@144
|
412 cerr << "ERROR: Plugin \"" << list[i] << "\" could not be loaded" << endl;
|
cannam@144
|
413 exit(1);
|
cannam@144
|
414 }
|
cannam@144
|
415 plugins.push_back(plugin);
|
cannam@144
|
416 }
|
cannam@151
|
417
|
cannam@151
|
418 if (plugins.empty()) {
|
cannam@151
|
419 cerr << "ERROR: Plugin library \"" << mylibname << "\" does not exist, could not be opened, or contains no plugins" << endl;
|
cannam@151
|
420 exit(1);
|
cannam@151
|
421 }
|
cannam@151
|
422
|
cannam@144
|
423 } else { // pluginName is a plugin
|
cannam@144
|
424
|
cannam@144
|
425 Plugin *plugin = loader->loadPlugin(pluginName, size_t(44100));
|
cannam@144
|
426 if (!plugin) {
|
cannam@144
|
427 cerr << "ERROR: Plugin \"" << pluginName << "\" could not be loaded" << endl;
|
cannam@144
|
428 exit(1);
|
cannam@144
|
429 }
|
cannam@144
|
430 plugins.push_back(plugin);
|
cannam@144
|
431 }
|
cannam@144
|
432
|
cannam@144
|
433 ++argidx;
|
cannam@144
|
434 }
|
cannam@138
|
435
|
cannam@144
|
436 cout << describe(plugins, pluginBundleBaseURI, describerURI, libname) << endl;
|
cannam@138
|
437
|
cannam@138
|
438 return 0;
|
cannam@138
|
439 }
|
cannam@138
|
440
|
cannam@138
|
441
|