annotate host/vamp-simple-host.cpp @ 168:006a775133b1

* Re-do the way the v2 structure (with durations) is returned. I bungled backward compatibility -- I failed to spot the contiguous array returned from process()... duh. Also bump library versions.
author cannam
date Thu, 24 Jul 2008 16:50:11 +0000
parents 31eda4b11f2b
children 1982246a3902
rev   line source
cannam@1 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@1 2
cannam@1 3 /*
cannam@1 4 Vamp
cannam@1 5
cannam@1 6 An API for audio analysis and feature extraction plugins.
cannam@1 7
cannam@1 8 Centre for Digital Music, Queen Mary, University of London.
cannam@1 9 Copyright 2006 Chris Cannam.
cannam@16 10 FFT code from Don Cross's public domain FFT implementation.
cannam@1 11
cannam@1 12 Permission is hereby granted, free of charge, to any person
cannam@1 13 obtaining a copy of this software and associated documentation
cannam@1 14 files (the "Software"), to deal in the Software without
cannam@1 15 restriction, including without limitation the rights to use, copy,
cannam@1 16 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@1 17 of the Software, and to permit persons to whom the Software is
cannam@1 18 furnished to do so, subject to the following conditions:
cannam@1 19
cannam@1 20 The above copyright notice and this permission notice shall be
cannam@1 21 included in all copies or substantial portions of the Software.
cannam@1 22
cannam@1 23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@1 24 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@1 25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@6 26 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@1 27 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@1 28 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@1 29 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@1 30
cannam@1 31 Except as contained in this notice, the names of the Centre for
cannam@1 32 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@1 33 shall not be used in advertising or otherwise to promote the sale,
cannam@1 34 use or other dealings in this Software without prior written
cannam@1 35 authorization.
cannam@1 36 */
cannam@1 37
cannam@64 38 #include "vamp-sdk/PluginHostAdapter.h"
cannam@64 39 #include "vamp-sdk/hostext/PluginChannelAdapter.h"
cannam@64 40 #include "vamp-sdk/hostext/PluginInputDomainAdapter.h"
cannam@64 41 #include "vamp-sdk/hostext/PluginLoader.h"
cannam@64 42 #include "vamp/vamp.h"
cannam@1 43
cannam@16 44 #include <iostream>
cannam@88 45 #include <fstream>
cannam@99 46 #include <set>
cannam@16 47 #include <sndfile.h>
cannam@1 48
cannam@130 49 #include <cstring>
cannam@130 50 #include <cstdlib>
cannam@130 51
cannam@1 52 #include "system.h"
cannam@1 53
cannam@19 54 #include <cmath>
cannam@19 55
cannam@99 56 using namespace std;
cannam@16 57
cannam@99 58 using Vamp::Plugin;
cannam@99 59 using Vamp::PluginHostAdapter;
cannam@99 60 using Vamp::RealTime;
cannam@64 61 using Vamp::HostExt::PluginLoader;
cannam@64 62
cannam@64 63 #define HOST_VERSION "1.1"
cannam@40 64
cannam@95 65 enum Verbosity {
cannam@95 66 PluginIds,
cannam@95 67 PluginOutputIds,
cannam@95 68 PluginInformation
cannam@95 69 };
cannam@95 70
cannam@109 71 void printFeatures(int, int, int, Plugin::FeatureSet, ofstream *, bool frames);
cannam@16 72 void transformInput(float *, size_t);
cannam@16 73 void fft(unsigned int, bool, double *, double *, double *, double *);
cannam@64 74 void printPluginPath(bool verbose);
cannam@99 75 void printPluginCategoryList();
cannam@95 76 void enumeratePlugins(Verbosity);
cannam@64 77 void listPluginsInLibrary(string soname);
cannam@64 78 int runPlugin(string myname, string soname, string id, string output,
cannam@109 79 int outputNo, string inputFile, string outfilename, bool frames);
cannam@40 80
cannam@64 81 void usage(const char *name)
cannam@64 82 {
cannam@64 83 cerr << "\n"
cannam@64 84 << name << ": A simple Vamp plugin host.\n\n"
cannam@64 85 "Centre for Digital Music, Queen Mary, University of London.\n"
cannam@64 86 "Copyright 2006-2007 Chris Cannam and QMUL.\n"
cannam@64 87 "Freely redistributable; published under a BSD-style license.\n\n"
cannam@64 88 "Usage:\n\n"
cannam@109 89 " " << name << " [-s] pluginlibrary[." << PLUGIN_SUFFIX << "]:plugin[:output] file.wav [-o out.txt]\n"
cannam@109 90 " " << name << " [-s] pluginlibrary[." << PLUGIN_SUFFIX << "]:plugin file.wav [outputno] [-o out.txt]\n\n"
cannam@64 91 " -- Load plugin id \"plugin\" from \"pluginlibrary\" and run it on the\n"
cannam@73 92 " audio data in \"file.wav\", retrieving the named \"output\", or output\n"
cannam@73 93 " number \"outputno\" (the first output by default) and dumping it to\n"
cannam@95 94 " standard output, or to \"out.txt\" if the -o option is given.\n\n"
cannam@73 95 " \"pluginlibrary\" should be a library name, not a file path; the\n"
cannam@73 96 " standard Vamp library search path will be used to locate it. If\n"
cannam@73 97 " a file path is supplied, the directory part(s) will be ignored.\n\n"
cannam@109 98 " If the -s option is given, results will be labelled with the audio\n"
cannam@109 99 " sample frame at which they occur. Otherwise, they will be labelled\n"
cannam@109 100 " with time in seconds.\n\n"
cannam@64 101 " " << name << " -l\n\n"
cannam@95 102 " -- List the plugin libraries and Vamp plugins in the library search path\n"
cannam@95 103 " in a verbose human-readable format.\n\n"
cannam@95 104 " " << name << " --list-ids\n\n"
cannam@95 105 " -- List the plugins in the search path in a terse machine-readable format,\n"
cannam@95 106 " in the form vamp:soname:identifier.\n\n"
cannam@95 107 " " << name << " --list-outputs\n\n"
cannam@95 108 " -- List the outputs for plugins in the search path in a machine-readable\n"
cannam@95 109 " format, in the form vamp:soname:identifier:output.\n\n"
cannam@99 110 " " << name << " --list-by-category\n\n"
cannam@99 111 " -- List the plugins as a plugin index by category, in a machine-readable\n"
cannam@99 112 " format. The format may change in future releases.\n\n"
cannam@64 113 " " << name << " -p\n\n"
cannam@73 114 " -- Print out the Vamp library search path.\n\n"
cannam@64 115 " " << name << " -v\n\n"
cannam@95 116 " -- Display version information only.\n"
cannam@64 117 << endl;
cannam@64 118 exit(2);
cannam@64 119 }
cannam@1 120
cannam@1 121 int main(int argc, char **argv)
cannam@1 122 {
cannam@64 123 char *scooter = argv[0];
cannam@64 124 char *name = 0;
cannam@64 125 while (scooter && *scooter) {
cannam@64 126 if (*scooter == '/' || *scooter == '\\') name = ++scooter;
cannam@64 127 else ++scooter;
cannam@1 128 }
cannam@64 129 if (!name || !*name) name = argv[0];
cannam@43 130
cannam@88 131 if (argc < 2) usage(name);
cannam@64 132
cannam@88 133 if (argc == 2) {
cannam@88 134
cannam@88 135 if (!strcmp(argv[1], "-v")) {
cannam@88 136
cannam@88 137 cout << "Simple Vamp plugin host version: " << HOST_VERSION << endl
cannam@88 138 << "Vamp API version: " << VAMP_API_VERSION << endl
cannam@88 139 << "Vamp SDK version: " << VAMP_SDK_VERSION << endl;
cannam@88 140 return 0;
cannam@88 141
cannam@88 142 } else if (!strcmp(argv[1], "-l")) {
cannam@88 143
cannam@88 144 printPluginPath(true);
cannam@95 145 enumeratePlugins(PluginInformation);
cannam@88 146 return 0;
cannam@88 147
cannam@88 148 } else if (!strcmp(argv[1], "-p")) {
cannam@88 149
cannam@88 150 printPluginPath(false);
cannam@88 151 return 0;
cannam@88 152
cannam@95 153 } else if (!strcmp(argv[1], "--list-ids")) {
cannam@95 154
cannam@95 155 enumeratePlugins(PluginIds);
cannam@95 156 return 0;
cannam@95 157
cannam@95 158 } else if (!strcmp(argv[1], "--list-outputs")) {
cannam@95 159
cannam@95 160 enumeratePlugins(PluginOutputIds);
cannam@95 161 return 0;
cannam@95 162
cannam@99 163 } else if (!strcmp(argv[1], "--list-by-category")) {
cannam@99 164
cannam@99 165 printPluginCategoryList();
cannam@99 166 return 0;
cannam@99 167
cannam@88 168 } else usage(name);
cannam@64 169 }
cannam@64 170
cannam@88 171 if (argc < 3) usage(name);
cannam@88 172
cannam@109 173 bool useFrames = false;
cannam@109 174
cannam@109 175 int base = 1;
cannam@109 176 if (!strcmp(argv[1], "-s")) {
cannam@109 177 useFrames = true;
cannam@109 178 base = 2;
cannam@109 179 }
cannam@109 180
cannam@109 181 string soname = argv[base];
cannam@109 182 string wavname = argv[base+1];
cannam@88 183 string plugid = "";
cannam@88 184 string output = "";
cannam@88 185 int outputNo = -1;
cannam@88 186 string outfilename;
cannam@88 187
cannam@109 188 if (argc >= base+3) {
cannam@88 189
cannam@109 190 int idx = base+2;
cannam@88 191
cannam@88 192 if (isdigit(*argv[idx])) {
cannam@88 193 outputNo = atoi(argv[idx++]);
cannam@88 194 }
cannam@88 195
cannam@88 196 if (argc == idx + 2) {
cannam@88 197 if (!strcmp(argv[idx], "-o")) {
cannam@88 198 outfilename = argv[idx+1];
cannam@88 199 } else usage(name);
cannam@88 200 } else if (argc != idx) {
cannam@88 201 (usage(name));
cannam@88 202 }
cannam@40 203 }
cannam@40 204
cannam@64 205 cerr << endl << name << ": Running..." << endl;
cannam@1 206
cannam@88 207 cerr << "Reading file: \"" << wavname << "\", writing to ";
cannam@88 208 if (outfilename == "") {
cannam@88 209 cerr << "standard output" << endl;
cannam@88 210 } else {
cannam@88 211 cerr << "\"" << outfilename << "\"" << endl;
cannam@88 212 }
cannam@16 213
cannam@64 214 string::size_type sep = soname.find(':');
cannam@64 215
cannam@64 216 if (sep != string::npos) {
cannam@49 217 plugid = soname.substr(sep + 1);
cannam@20 218 soname = soname.substr(0, sep);
cannam@1 219
cannam@64 220 sep = plugid.find(':');
cannam@64 221 if (sep != string::npos) {
cannam@64 222 output = plugid.substr(sep + 1);
cannam@64 223 plugid = plugid.substr(0, sep);
cannam@16 224 }
cannam@16 225 }
cannam@16 226
cannam@64 227 if (plugid == "") {
cannam@64 228 usage(name);
cannam@16 229 }
cannam@64 230
cannam@64 231 if (output != "" && outputNo != -1) {
cannam@64 232 usage(name);
cannam@64 233 }
cannam@64 234
cannam@84 235 if (output == "" && outputNo == -1) {
cannam@84 236 outputNo = 0;
cannam@84 237 }
cannam@84 238
cannam@88 239 return runPlugin(name, soname, plugid, output, outputNo,
cannam@109 240 wavname, outfilename, useFrames);
cannam@64 241 }
cannam@64 242
cannam@64 243
cannam@64 244 int runPlugin(string myname, string soname, string id,
cannam@88 245 string output, int outputNo, string wavname,
cannam@109 246 string outfilename, bool useFrames)
cannam@64 247 {
cannam@64 248 PluginLoader *loader = PluginLoader::getInstance();
cannam@64 249
cannam@64 250 PluginLoader::PluginKey key = loader->composePluginKey(soname, id);
cannam@16 251
cannam@16 252 SNDFILE *sndfile;
cannam@16 253 SF_INFO sfinfo;
cannam@16 254 memset(&sfinfo, 0, sizeof(SF_INFO));
cannam@16 255
cannam@16 256 sndfile = sf_open(wavname.c_str(), SFM_READ, &sfinfo);
cannam@16 257 if (!sndfile) {
cannam@64 258 cerr << myname << ": ERROR: Failed to open input file \""
cannam@64 259 << wavname << "\": " << sf_strerror(sndfile) << endl;
cannam@16 260 return 1;
cannam@16 261 }
cannam@16 262
cannam@88 263 ofstream *out = 0;
cannam@88 264 if (outfilename != "") {
cannam@88 265 out = new ofstream(outfilename.c_str(), ios::out);
cannam@88 266 if (!*out) {
cannam@88 267 cerr << myname << ": ERROR: Failed to open output file \""
cannam@88 268 << outfilename << "\" for writing" << endl;
cannam@88 269 delete out;
cannam@88 270 return 1;
cannam@88 271 }
cannam@88 272 }
cannam@88 273
cannam@99 274 Plugin *plugin = loader->loadPlugin
cannam@92 275 (key, sfinfo.samplerate, PluginLoader::ADAPT_ALL_SAFE);
cannam@64 276 if (!plugin) {
cannam@64 277 cerr << myname << ": ERROR: Failed to load plugin \"" << id
cannam@64 278 << "\" from library \"" << soname << "\"" << endl;
cannam@64 279 sf_close(sndfile);
cannam@88 280 if (out) {
cannam@88 281 out->close();
cannam@88 282 delete out;
cannam@88 283 }
cannam@64 284 return 1;
cannam@64 285 }
cannam@16 286
cannam@64 287 cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
cannam@16 288
cannam@16 289 int blockSize = plugin->getPreferredBlockSize();
cannam@16 290 int stepSize = plugin->getPreferredStepSize();
cannam@16 291
cannam@91 292 if (blockSize == 0) {
cannam@91 293 blockSize = 1024;
cannam@91 294 }
cannam@83 295 if (stepSize == 0) {
cannam@99 296 if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
cannam@83 297 stepSize = blockSize/2;
cannam@83 298 } else {
cannam@83 299 stepSize = blockSize;
cannam@83 300 }
cannam@91 301 } else if (stepSize > blockSize) {
cannam@91 302 cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
cannam@99 303 if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
cannam@91 304 blockSize = stepSize * 2;
cannam@91 305 } else {
cannam@91 306 blockSize = stepSize;
cannam@91 307 }
cannam@91 308 cerr << blockSize << endl;
cannam@83 309 }
cannam@83 310
cannam@16 311 int channels = sfinfo.channels;
cannam@16 312
cannam@16 313 float *filebuf = new float[blockSize * channels];
cannam@16 314 float **plugbuf = new float*[channels];
cannam@47 315 for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize + 2];
cannam@16 316
cannam@16 317 cerr << "Using block size = " << blockSize << ", step size = "
cannam@16 318 << stepSize << endl;
cannam@16 319
cannam@16 320 int minch = plugin->getMinChannelCount();
cannam@16 321 int maxch = plugin->getMaxChannelCount();
cannam@16 322 cerr << "Plugin accepts " << minch << " -> " << maxch << " channel(s)" << endl;
cannam@64 323 cerr << "Sound file has " << channels << " (will mix/augment if necessary)" << endl;
cannam@16 324
cannam@99 325 Plugin::OutputList outputs = plugin->getOutputDescriptors();
cannam@99 326 Plugin::OutputDescriptor od;
cannam@16 327
cannam@29 328 int returnValue = 1;
cannam@88 329 int progress = 0;
cannam@29 330
cannam@16 331 if (outputs.empty()) {
cannam@64 332 cerr << "ERROR: Plugin has no outputs!" << endl;
cannam@16 333 goto done;
cannam@16 334 }
cannam@16 335
cannam@64 336 if (outputNo < 0) {
cannam@16 337
cannam@64 338 for (size_t oi = 0; oi < outputs.size(); ++oi) {
cannam@64 339 if (outputs[oi].identifier == output) {
cannam@64 340 outputNo = oi;
cannam@64 341 break;
cannam@64 342 }
cannam@64 343 }
cannam@64 344
cannam@64 345 if (outputNo < 0) {
cannam@64 346 cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl;
cannam@64 347 goto done;
cannam@64 348 }
cannam@64 349
cannam@64 350 } else {
cannam@64 351
cannam@64 352 if (int(outputs.size()) <= outputNo) {
cannam@64 353 cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl;
cannam@64 354 goto done;
cannam@64 355 }
cannam@64 356 }
cannam@64 357
cannam@64 358 od = outputs[outputNo];
cannam@64 359 cerr << "Output is: \"" << od.identifier << "\"" << endl;
cannam@16 360
cannam@29 361 if (!plugin->initialise(channels, stepSize, blockSize)) {
cannam@29 362 cerr << "ERROR: Plugin initialise (channels = " << channels
cannam@29 363 << ", stepSize = " << stepSize << ", blockSize = "
cannam@29 364 << blockSize << ") failed." << endl;
cannam@29 365 goto done;
cannam@29 366 }
cannam@16 367
cannam@16 368 for (size_t i = 0; i < sfinfo.frames; i += stepSize) {
cannam@16 369
cannam@16 370 int count;
cannam@16 371
cannam@16 372 if (sf_seek(sndfile, i, SEEK_SET) < 0) {
cannam@16 373 cerr << "ERROR: sf_seek failed: " << sf_strerror(sndfile) << endl;
cannam@16 374 break;
cannam@16 375 }
cannam@16 376
cannam@16 377 if ((count = sf_readf_float(sndfile, filebuf, blockSize)) < 0) {
cannam@16 378 cerr << "ERROR: sf_readf_float failed: " << sf_strerror(sndfile) << endl;
cannam@16 379 break;
cannam@16 380 }
cannam@16 381
cannam@16 382 for (int c = 0; c < channels; ++c) {
cannam@64 383 int j = 0;
cannam@64 384 while (j < count) {
cannam@64 385 plugbuf[c][j] = filebuf[j * sfinfo.channels + c];
cannam@64 386 ++j;
cannam@64 387 }
cannam@64 388 while (j < blockSize) {
cannam@16 389 plugbuf[c][j] = 0.0f;
cannam@64 390 ++j;
cannam@16 391 }
cannam@16 392 }
cannam@16 393
cannam@16 394 printFeatures
cannam@64 395 (i, sfinfo.samplerate, outputNo, plugin->process
cannam@99 396 (plugbuf, RealTime::frame2RealTime(i, sfinfo.samplerate)),
cannam@109 397 out, useFrames);
cannam@88 398
cannam@88 399 int pp = progress;
cannam@88 400 progress = lrintf((float(i) / sfinfo.frames) * 100.f);
cannam@88 401 if (progress != pp && out) {
cannam@88 402 cerr << "\r" << progress << "%";
cannam@88 403 }
cannam@16 404 }
cannam@88 405 if (out) cerr << "\rDone" << endl;
cannam@16 406
cannam@64 407 printFeatures(sfinfo.frames, sfinfo.samplerate, outputNo,
cannam@109 408 plugin->getRemainingFeatures(), out, useFrames);
cannam@16 409
cannam@29 410 returnValue = 0;
cannam@29 411
cannam@16 412 done:
cannam@16 413 delete plugin;
cannam@88 414 if (out) {
cannam@88 415 out->close();
cannam@88 416 delete out;
cannam@88 417 }
cannam@16 418 sf_close(sndfile);
cannam@29 419 return returnValue;
cannam@1 420 }
cannam@1 421
cannam@16 422 void
cannam@99 423 printFeatures(int frame, int sr, int output,
cannam@109 424 Plugin::FeatureSet features, ofstream *out, bool useFrames)
cannam@99 425 {
cannam@99 426 for (unsigned int i = 0; i < features[output].size(); ++i) {
cannam@99 427
cannam@109 428 if (useFrames) {
cannam@99 429
cannam@109 430 int displayFrame = frame;
cannam@109 431
cannam@109 432 if (features[output][i].hasTimestamp) {
cannam@109 433 displayFrame = RealTime::realTime2Frame
cannam@109 434 (features[output][i].timestamp, sr);
cannam@109 435 }
cannam@109 436
cannam@167 437 (out ? *out : cout) << displayFrame;
cannam@167 438
cannam@167 439 if (features[output][i].hasDuration) {
cannam@167 440 displayFrame = RealTime::realTime2Frame
cannam@167 441 (features[output][i].duration, sr);
cannam@167 442 (out ? *out : cout) << "," << displayFrame;
cannam@167 443 }
cannam@167 444
cannam@167 445 (out ? *out : cout) << ":";
cannam@109 446
cannam@109 447 } else {
cannam@109 448
cannam@109 449 RealTime rt = RealTime::frame2RealTime(frame, sr);
cannam@109 450
cannam@109 451 if (features[output][i].hasTimestamp) {
cannam@109 452 rt = features[output][i].timestamp;
cannam@109 453 }
cannam@109 454
cannam@167 455 (out ? *out : cout) << rt.toString();
cannam@167 456
cannam@167 457 if (features[output][i].hasDuration) {
cannam@167 458 rt = features[output][i].duration;
cannam@167 459 (out ? *out : cout) << "," << rt.toString();
cannam@167 460 }
cannam@167 461
cannam@167 462 (out ? *out : cout) << ":";
cannam@99 463 }
cannam@99 464
cannam@99 465 for (unsigned int j = 0; j < features[output][i].values.size(); ++j) {
cannam@99 466 (out ? *out : cout) << " " << features[output][i].values[j];
cannam@99 467 }
cannam@99 468
cannam@99 469 (out ? *out : cout) << endl;
cannam@99 470 }
cannam@99 471 }
cannam@99 472
cannam@99 473 void
cannam@64 474 printPluginPath(bool verbose)
cannam@40 475 {
cannam@64 476 if (verbose) {
cannam@64 477 cout << "\nVamp plugin search path: ";
cannam@64 478 }
cannam@64 479
cannam@99 480 vector<string> path = PluginHostAdapter::getPluginPath();
cannam@40 481 for (size_t i = 0; i < path.size(); ++i) {
cannam@64 482 if (verbose) {
cannam@64 483 cout << "[" << path[i] << "]";
cannam@64 484 } else {
cannam@64 485 cout << path[i] << endl;
cannam@64 486 }
cannam@40 487 }
cannam@64 488
cannam@64 489 if (verbose) cout << endl;
cannam@40 490 }
cannam@40 491
cannam@40 492 void
cannam@95 493 enumeratePlugins(Verbosity verbosity)
cannam@40 494 {
cannam@64 495 PluginLoader *loader = PluginLoader::getInstance();
cannam@64 496
cannam@95 497 if (verbosity == PluginInformation) {
cannam@95 498 cout << "\nVamp plugin libraries found in search path:" << endl;
cannam@95 499 }
cannam@64 500
cannam@99 501 vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
cannam@99 502 typedef multimap<string, PluginLoader::PluginKey>
cannam@64 503 LibraryMap;
cannam@64 504 LibraryMap libraryMap;
cannam@64 505
cannam@64 506 for (size_t i = 0; i < plugins.size(); ++i) {
cannam@99 507 string path = loader->getLibraryPathForPlugin(plugins[i]);
cannam@64 508 libraryMap.insert(LibraryMap::value_type(path, plugins[i]));
cannam@64 509 }
cannam@64 510
cannam@99 511 string prevPath = "";
cannam@64 512 int index = 0;
cannam@64 513
cannam@64 514 for (LibraryMap::iterator i = libraryMap.begin();
cannam@64 515 i != libraryMap.end(); ++i) {
cannam@64 516
cannam@99 517 string path = i->first;
cannam@64 518 PluginLoader::PluginKey key = i->second;
cannam@64 519
cannam@64 520 if (path != prevPath) {
cannam@64 521 prevPath = path;
cannam@64 522 index = 0;
cannam@95 523 if (verbosity == PluginInformation) {
cannam@95 524 cout << "\n " << path << ":" << endl;
cannam@95 525 }
cannam@40 526 }
cannam@64 527
cannam@99 528 Plugin *plugin = loader->loadPlugin(key, 48000);
cannam@64 529 if (plugin) {
cannam@64 530
cannam@64 531 char c = char('A' + index);
cannam@64 532 if (c > 'Z') c = char('a' + (index - 26));
cannam@64 533
cannam@95 534 if (verbosity == PluginInformation) {
cannam@64 535
cannam@95 536 cout << " [" << c << "] [v"
cannam@95 537 << plugin->getVampApiVersion() << "] "
cannam@95 538 << plugin->getName() << ", \""
cannam@95 539 << plugin->getIdentifier() << "\"" << " ["
cannam@95 540 << plugin->getMaker() << "]" << endl;
cannam@95 541
cannam@95 542 PluginLoader::PluginCategoryHierarchy category =
cannam@95 543 loader->getPluginCategory(key);
cannam@95 544
cannam@95 545 if (!category.empty()) {
cannam@95 546 cout << " ";
cannam@95 547 for (size_t ci = 0; ci < category.size(); ++ci) {
cannam@95 548 cout << " > " << category[ci];
cannam@95 549 }
cannam@95 550 cout << endl;
cannam@64 551 }
cannam@95 552
cannam@95 553 if (plugin->getDescription() != "") {
cannam@95 554 cout << " - " << plugin->getDescription() << endl;
cannam@95 555 }
cannam@95 556
cannam@95 557 } else if (verbosity == PluginIds) {
cannam@95 558 cout << "vamp:" << key << endl;
cannam@47 559 }
cannam@95 560
cannam@99 561 Plugin::OutputList outputs =
cannam@64 562 plugin->getOutputDescriptors();
cannam@64 563
cannam@95 564 if (outputs.size() > 1 || verbosity == PluginOutputIds) {
cannam@64 565 for (size_t j = 0; j < outputs.size(); ++j) {
cannam@95 566 if (verbosity == PluginInformation) {
cannam@95 567 cout << " (" << j << ") "
cannam@95 568 << outputs[j].name << ", \""
cannam@95 569 << outputs[j].identifier << "\"" << endl;
cannam@95 570 if (outputs[j].description != "") {
cannam@95 571 cout << " - "
cannam@95 572 << outputs[j].description << endl;
cannam@95 573 }
cannam@95 574 } else if (verbosity == PluginOutputIds) {
cannam@95 575 cout << "vamp:" << key << ":" << outputs[j].identifier << endl;
cannam@40 576 }
cannam@40 577 }
cannam@64 578 }
cannam@64 579
cannam@64 580 ++index;
cannam@64 581
cannam@64 582 delete plugin;
cannam@40 583 }
cannam@40 584 }
cannam@64 585
cannam@95 586 if (verbosity == PluginInformation) {
cannam@95 587 cout << endl;
cannam@95 588 }
cannam@40 589 }
cannam@40 590
cannam@40 591 void
cannam@99 592 printPluginCategoryList()
cannam@16 593 {
cannam@99 594 PluginLoader *loader = PluginLoader::getInstance();
cannam@88 595
cannam@99 596 vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
cannam@88 597
cannam@99 598 set<string> printedcats;
cannam@99 599
cannam@99 600 for (size_t i = 0; i < plugins.size(); ++i) {
cannam@99 601
cannam@99 602 PluginLoader::PluginKey key = plugins[i];
cannam@99 603
cannam@99 604 PluginLoader::PluginCategoryHierarchy category =
cannam@99 605 loader->getPluginCategory(key);
cannam@99 606
cannam@99 607 Plugin *plugin = loader->loadPlugin(key, 48000);
cannam@99 608 if (!plugin) continue;
cannam@99 609
cannam@99 610 string catstr = "";
cannam@99 611
cannam@99 612 if (category.empty()) catstr = '|';
cannam@99 613 else {
cannam@99 614 for (size_t j = 0; j < category.size(); ++j) {
cannam@99 615 catstr += category[j];
cannam@99 616 catstr += '|';
cannam@99 617 if (printedcats.find(catstr) == printedcats.end()) {
cannam@99 618 std::cout << catstr << std::endl;
cannam@99 619 printedcats.insert(catstr);
cannam@99 620 }
cannam@99 621 }
cannam@16 622 }
cannam@88 623
cannam@99 624 std::cout << catstr << key << ":::" << plugin->getName() << ":::" << plugin->getMaker() << ":::" << plugin->getDescription() << std::endl;
cannam@16 625 }
cannam@16 626 }
cannam@16 627