annotate host/vamp-simple-host.cpp @ 101:5c9f267c48c0

* Add optional support for FFTW through HAVE_FFTW3 flag. Off by default, and should be off in any distro packages, for licensing reasons.
author cannam
date Mon, 28 Jan 2008 12:34:39 +0000
parents fe31e6aed666
children 9830daccee4b
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@1 49 #include "system.h"
cannam@1 50
cannam@19 51 #include <cmath>
cannam@19 52
cannam@99 53 using namespace std;
cannam@16 54
cannam@99 55 using Vamp::Plugin;
cannam@99 56 using Vamp::PluginHostAdapter;
cannam@99 57 using Vamp::RealTime;
cannam@64 58 using Vamp::HostExt::PluginLoader;
cannam@64 59
cannam@64 60 #define HOST_VERSION "1.1"
cannam@40 61
cannam@95 62 enum Verbosity {
cannam@95 63 PluginIds,
cannam@95 64 PluginOutputIds,
cannam@95 65 PluginInformation
cannam@95 66 };
cannam@95 67
cannam@99 68 void printFeatures(int, int, int, Plugin::FeatureSet, ofstream *);
cannam@16 69 void transformInput(float *, size_t);
cannam@16 70 void fft(unsigned int, bool, double *, double *, double *, double *);
cannam@64 71 void printPluginPath(bool verbose);
cannam@99 72 void printPluginCategoryList();
cannam@95 73 void enumeratePlugins(Verbosity);
cannam@64 74 void listPluginsInLibrary(string soname);
cannam@64 75 int runPlugin(string myname, string soname, string id, string output,
cannam@88 76 int outputNo, string inputFile, string outfilename);
cannam@40 77
cannam@64 78 void usage(const char *name)
cannam@64 79 {
cannam@64 80 cerr << "\n"
cannam@64 81 << name << ": A simple Vamp plugin host.\n\n"
cannam@64 82 "Centre for Digital Music, Queen Mary, University of London.\n"
cannam@64 83 "Copyright 2006-2007 Chris Cannam and QMUL.\n"
cannam@64 84 "Freely redistributable; published under a BSD-style license.\n\n"
cannam@64 85 "Usage:\n\n"
cannam@95 86 " " << name << " pluginlibrary[." << PLUGIN_SUFFIX << "]:plugin[:output] file.wav [-o out.txt]\n"
cannam@95 87 " " << name << " pluginlibrary[." << PLUGIN_SUFFIX << "]:plugin file.wav [outputno] [-o out.txt]\n\n"
cannam@64 88 " -- Load plugin id \"plugin\" from \"pluginlibrary\" and run it on the\n"
cannam@73 89 " audio data in \"file.wav\", retrieving the named \"output\", or output\n"
cannam@73 90 " number \"outputno\" (the first output by default) and dumping it to\n"
cannam@95 91 " standard output, or to \"out.txt\" if the -o option is given.\n\n"
cannam@73 92 " \"pluginlibrary\" should be a library name, not a file path; the\n"
cannam@73 93 " standard Vamp library search path will be used to locate it. If\n"
cannam@73 94 " a file path is supplied, the directory part(s) will be ignored.\n\n"
cannam@64 95 " " << name << " -l\n\n"
cannam@95 96 " -- List the plugin libraries and Vamp plugins in the library search path\n"
cannam@95 97 " in a verbose human-readable format.\n\n"
cannam@95 98 " " << name << " --list-ids\n\n"
cannam@95 99 " -- List the plugins in the search path in a terse machine-readable format,\n"
cannam@95 100 " in the form vamp:soname:identifier.\n\n"
cannam@95 101 " " << name << " --list-outputs\n\n"
cannam@95 102 " -- List the outputs for plugins in the search path in a machine-readable\n"
cannam@95 103 " format, in the form vamp:soname:identifier:output.\n\n"
cannam@99 104 " " << name << " --list-by-category\n\n"
cannam@99 105 " -- List the plugins as a plugin index by category, in a machine-readable\n"
cannam@99 106 " format. The format may change in future releases.\n\n"
cannam@64 107 " " << name << " -p\n\n"
cannam@73 108 " -- Print out the Vamp library search path.\n\n"
cannam@64 109 " " << name << " -v\n\n"
cannam@95 110 " -- Display version information only.\n"
cannam@64 111 << endl;
cannam@64 112 exit(2);
cannam@64 113 }
cannam@1 114
cannam@1 115 int main(int argc, char **argv)
cannam@1 116 {
cannam@64 117 char *scooter = argv[0];
cannam@64 118 char *name = 0;
cannam@64 119 while (scooter && *scooter) {
cannam@64 120 if (*scooter == '/' || *scooter == '\\') name = ++scooter;
cannam@64 121 else ++scooter;
cannam@1 122 }
cannam@64 123 if (!name || !*name) name = argv[0];
cannam@43 124
cannam@88 125 if (argc < 2) usage(name);
cannam@64 126
cannam@88 127 if (argc == 2) {
cannam@88 128
cannam@88 129 if (!strcmp(argv[1], "-v")) {
cannam@88 130
cannam@88 131 cout << "Simple Vamp plugin host version: " << HOST_VERSION << endl
cannam@88 132 << "Vamp API version: " << VAMP_API_VERSION << endl
cannam@88 133 << "Vamp SDK version: " << VAMP_SDK_VERSION << endl;
cannam@88 134 return 0;
cannam@88 135
cannam@88 136 } else if (!strcmp(argv[1], "-l")) {
cannam@88 137
cannam@88 138 printPluginPath(true);
cannam@95 139 enumeratePlugins(PluginInformation);
cannam@88 140 return 0;
cannam@88 141
cannam@88 142 } else if (!strcmp(argv[1], "-p")) {
cannam@88 143
cannam@88 144 printPluginPath(false);
cannam@88 145 return 0;
cannam@88 146
cannam@95 147 } else if (!strcmp(argv[1], "--list-ids")) {
cannam@95 148
cannam@95 149 enumeratePlugins(PluginIds);
cannam@95 150 return 0;
cannam@95 151
cannam@95 152 } else if (!strcmp(argv[1], "--list-outputs")) {
cannam@95 153
cannam@95 154 enumeratePlugins(PluginOutputIds);
cannam@95 155 return 0;
cannam@95 156
cannam@99 157 } else if (!strcmp(argv[1], "--list-by-category")) {
cannam@99 158
cannam@99 159 printPluginCategoryList();
cannam@99 160 return 0;
cannam@99 161
cannam@88 162 } else usage(name);
cannam@64 163 }
cannam@64 164
cannam@88 165 if (argc < 3) usage(name);
cannam@88 166
cannam@88 167 string soname = argv[1];
cannam@88 168 string wavname = argv[2];
cannam@88 169 string plugid = "";
cannam@88 170 string output = "";
cannam@88 171 int outputNo = -1;
cannam@88 172 string outfilename;
cannam@88 173
cannam@88 174 if (argc >= 4) {
cannam@88 175
cannam@88 176 int idx = 3;
cannam@88 177
cannam@88 178 if (isdigit(*argv[idx])) {
cannam@88 179 outputNo = atoi(argv[idx++]);
cannam@88 180 }
cannam@88 181
cannam@88 182 if (argc == idx + 2) {
cannam@88 183 if (!strcmp(argv[idx], "-o")) {
cannam@88 184 outfilename = argv[idx+1];
cannam@88 185 } else usage(name);
cannam@88 186 } else if (argc != idx) {
cannam@88 187 (usage(name));
cannam@88 188 }
cannam@40 189 }
cannam@40 190
cannam@64 191 cerr << endl << name << ": Running..." << endl;
cannam@1 192
cannam@88 193 cerr << "Reading file: \"" << wavname << "\", writing to ";
cannam@88 194 if (outfilename == "") {
cannam@88 195 cerr << "standard output" << endl;
cannam@88 196 } else {
cannam@88 197 cerr << "\"" << outfilename << "\"" << endl;
cannam@88 198 }
cannam@16 199
cannam@64 200 string::size_type sep = soname.find(':');
cannam@64 201
cannam@64 202 if (sep != string::npos) {
cannam@49 203 plugid = soname.substr(sep + 1);
cannam@20 204 soname = soname.substr(0, sep);
cannam@1 205
cannam@64 206 sep = plugid.find(':');
cannam@64 207 if (sep != string::npos) {
cannam@64 208 output = plugid.substr(sep + 1);
cannam@64 209 plugid = plugid.substr(0, sep);
cannam@16 210 }
cannam@16 211 }
cannam@16 212
cannam@64 213 if (plugid == "") {
cannam@64 214 usage(name);
cannam@16 215 }
cannam@64 216
cannam@64 217 if (output != "" && outputNo != -1) {
cannam@64 218 usage(name);
cannam@64 219 }
cannam@64 220
cannam@84 221 if (output == "" && outputNo == -1) {
cannam@84 222 outputNo = 0;
cannam@84 223 }
cannam@84 224
cannam@88 225 return runPlugin(name, soname, plugid, output, outputNo,
cannam@88 226 wavname, outfilename);
cannam@64 227 }
cannam@64 228
cannam@64 229
cannam@64 230 int runPlugin(string myname, string soname, string id,
cannam@88 231 string output, int outputNo, string wavname,
cannam@88 232 string outfilename)
cannam@64 233 {
cannam@64 234 PluginLoader *loader = PluginLoader::getInstance();
cannam@64 235
cannam@64 236 PluginLoader::PluginKey key = loader->composePluginKey(soname, id);
cannam@16 237
cannam@16 238 SNDFILE *sndfile;
cannam@16 239 SF_INFO sfinfo;
cannam@16 240 memset(&sfinfo, 0, sizeof(SF_INFO));
cannam@16 241
cannam@16 242 sndfile = sf_open(wavname.c_str(), SFM_READ, &sfinfo);
cannam@16 243 if (!sndfile) {
cannam@64 244 cerr << myname << ": ERROR: Failed to open input file \""
cannam@64 245 << wavname << "\": " << sf_strerror(sndfile) << endl;
cannam@16 246 return 1;
cannam@16 247 }
cannam@16 248
cannam@88 249 ofstream *out = 0;
cannam@88 250 if (outfilename != "") {
cannam@88 251 out = new ofstream(outfilename.c_str(), ios::out);
cannam@88 252 if (!*out) {
cannam@88 253 cerr << myname << ": ERROR: Failed to open output file \""
cannam@88 254 << outfilename << "\" for writing" << endl;
cannam@88 255 delete out;
cannam@88 256 return 1;
cannam@88 257 }
cannam@88 258 }
cannam@88 259
cannam@99 260 Plugin *plugin = loader->loadPlugin
cannam@92 261 (key, sfinfo.samplerate, PluginLoader::ADAPT_ALL_SAFE);
cannam@64 262 if (!plugin) {
cannam@64 263 cerr << myname << ": ERROR: Failed to load plugin \"" << id
cannam@64 264 << "\" from library \"" << soname << "\"" << endl;
cannam@64 265 sf_close(sndfile);
cannam@88 266 if (out) {
cannam@88 267 out->close();
cannam@88 268 delete out;
cannam@88 269 }
cannam@64 270 return 1;
cannam@64 271 }
cannam@16 272
cannam@64 273 cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
cannam@16 274
cannam@16 275 int blockSize = plugin->getPreferredBlockSize();
cannam@16 276 int stepSize = plugin->getPreferredStepSize();
cannam@16 277
cannam@91 278 if (blockSize == 0) {
cannam@91 279 blockSize = 1024;
cannam@91 280 }
cannam@83 281 if (stepSize == 0) {
cannam@99 282 if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
cannam@83 283 stepSize = blockSize/2;
cannam@83 284 } else {
cannam@83 285 stepSize = blockSize;
cannam@83 286 }
cannam@91 287 } else if (stepSize > blockSize) {
cannam@91 288 cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
cannam@99 289 if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
cannam@91 290 blockSize = stepSize * 2;
cannam@91 291 } else {
cannam@91 292 blockSize = stepSize;
cannam@91 293 }
cannam@91 294 cerr << blockSize << endl;
cannam@83 295 }
cannam@83 296
cannam@16 297 int channels = sfinfo.channels;
cannam@16 298
cannam@16 299 float *filebuf = new float[blockSize * channels];
cannam@16 300 float **plugbuf = new float*[channels];
cannam@47 301 for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize + 2];
cannam@16 302
cannam@16 303 cerr << "Using block size = " << blockSize << ", step size = "
cannam@16 304 << stepSize << endl;
cannam@16 305
cannam@16 306 int minch = plugin->getMinChannelCount();
cannam@16 307 int maxch = plugin->getMaxChannelCount();
cannam@16 308 cerr << "Plugin accepts " << minch << " -> " << maxch << " channel(s)" << endl;
cannam@64 309 cerr << "Sound file has " << channels << " (will mix/augment if necessary)" << endl;
cannam@16 310
cannam@99 311 Plugin::OutputList outputs = plugin->getOutputDescriptors();
cannam@99 312 Plugin::OutputDescriptor od;
cannam@16 313
cannam@29 314 int returnValue = 1;
cannam@88 315 int progress = 0;
cannam@29 316
cannam@16 317 if (outputs.empty()) {
cannam@64 318 cerr << "ERROR: Plugin has no outputs!" << endl;
cannam@16 319 goto done;
cannam@16 320 }
cannam@16 321
cannam@64 322 if (outputNo < 0) {
cannam@16 323
cannam@64 324 for (size_t oi = 0; oi < outputs.size(); ++oi) {
cannam@64 325 if (outputs[oi].identifier == output) {
cannam@64 326 outputNo = oi;
cannam@64 327 break;
cannam@64 328 }
cannam@64 329 }
cannam@64 330
cannam@64 331 if (outputNo < 0) {
cannam@64 332 cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl;
cannam@64 333 goto done;
cannam@64 334 }
cannam@64 335
cannam@64 336 } else {
cannam@64 337
cannam@64 338 if (int(outputs.size()) <= outputNo) {
cannam@64 339 cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl;
cannam@64 340 goto done;
cannam@64 341 }
cannam@64 342 }
cannam@64 343
cannam@64 344 od = outputs[outputNo];
cannam@64 345 cerr << "Output is: \"" << od.identifier << "\"" << endl;
cannam@16 346
cannam@29 347 if (!plugin->initialise(channels, stepSize, blockSize)) {
cannam@29 348 cerr << "ERROR: Plugin initialise (channels = " << channels
cannam@29 349 << ", stepSize = " << stepSize << ", blockSize = "
cannam@29 350 << blockSize << ") failed." << endl;
cannam@29 351 goto done;
cannam@29 352 }
cannam@16 353
cannam@16 354 for (size_t i = 0; i < sfinfo.frames; i += stepSize) {
cannam@16 355
cannam@16 356 int count;
cannam@16 357
cannam@16 358 if (sf_seek(sndfile, i, SEEK_SET) < 0) {
cannam@16 359 cerr << "ERROR: sf_seek failed: " << sf_strerror(sndfile) << endl;
cannam@16 360 break;
cannam@16 361 }
cannam@16 362
cannam@16 363 if ((count = sf_readf_float(sndfile, filebuf, blockSize)) < 0) {
cannam@16 364 cerr << "ERROR: sf_readf_float failed: " << sf_strerror(sndfile) << endl;
cannam@16 365 break;
cannam@16 366 }
cannam@16 367
cannam@16 368 for (int c = 0; c < channels; ++c) {
cannam@64 369 int j = 0;
cannam@64 370 while (j < count) {
cannam@64 371 plugbuf[c][j] = filebuf[j * sfinfo.channels + c];
cannam@64 372 ++j;
cannam@64 373 }
cannam@64 374 while (j < blockSize) {
cannam@16 375 plugbuf[c][j] = 0.0f;
cannam@64 376 ++j;
cannam@16 377 }
cannam@16 378 }
cannam@16 379
cannam@16 380 printFeatures
cannam@64 381 (i, sfinfo.samplerate, outputNo, plugin->process
cannam@99 382 (plugbuf, RealTime::frame2RealTime(i, sfinfo.samplerate)),
cannam@88 383 out);
cannam@88 384
cannam@88 385 int pp = progress;
cannam@88 386 progress = lrintf((float(i) / sfinfo.frames) * 100.f);
cannam@88 387 if (progress != pp && out) {
cannam@88 388 cerr << "\r" << progress << "%";
cannam@88 389 }
cannam@16 390 }
cannam@88 391 if (out) cerr << "\rDone" << endl;
cannam@16 392
cannam@64 393 printFeatures(sfinfo.frames, sfinfo.samplerate, outputNo,
cannam@88 394 plugin->getRemainingFeatures(), out);
cannam@16 395
cannam@29 396 returnValue = 0;
cannam@29 397
cannam@16 398 done:
cannam@16 399 delete plugin;
cannam@88 400 if (out) {
cannam@88 401 out->close();
cannam@88 402 delete out;
cannam@88 403 }
cannam@16 404 sf_close(sndfile);
cannam@29 405 return returnValue;
cannam@1 406 }
cannam@1 407
cannam@16 408 void
cannam@99 409 printFeatures(int frame, int sr, int output,
cannam@99 410 Plugin::FeatureSet features, ofstream *out)
cannam@99 411 {
cannam@99 412 for (unsigned int i = 0; i < features[output].size(); ++i) {
cannam@99 413
cannam@99 414 RealTime rt = RealTime::frame2RealTime(frame, sr);
cannam@99 415
cannam@99 416 if (features[output][i].hasTimestamp) {
cannam@99 417 rt = features[output][i].timestamp;
cannam@99 418 }
cannam@99 419
cannam@99 420 (out ? *out : cout) << rt.toString() << ":";
cannam@99 421
cannam@99 422 for (unsigned int j = 0; j < features[output][i].values.size(); ++j) {
cannam@99 423 (out ? *out : cout) << " " << features[output][i].values[j];
cannam@99 424 }
cannam@99 425
cannam@99 426 (out ? *out : cout) << endl;
cannam@99 427 }
cannam@99 428 }
cannam@99 429
cannam@99 430 void
cannam@64 431 printPluginPath(bool verbose)
cannam@40 432 {
cannam@64 433 if (verbose) {
cannam@64 434 cout << "\nVamp plugin search path: ";
cannam@64 435 }
cannam@64 436
cannam@99 437 vector<string> path = PluginHostAdapter::getPluginPath();
cannam@40 438 for (size_t i = 0; i < path.size(); ++i) {
cannam@64 439 if (verbose) {
cannam@64 440 cout << "[" << path[i] << "]";
cannam@64 441 } else {
cannam@64 442 cout << path[i] << endl;
cannam@64 443 }
cannam@40 444 }
cannam@64 445
cannam@64 446 if (verbose) cout << endl;
cannam@40 447 }
cannam@40 448
cannam@40 449 void
cannam@95 450 enumeratePlugins(Verbosity verbosity)
cannam@40 451 {
cannam@64 452 PluginLoader *loader = PluginLoader::getInstance();
cannam@64 453
cannam@95 454 if (verbosity == PluginInformation) {
cannam@95 455 cout << "\nVamp plugin libraries found in search path:" << endl;
cannam@95 456 }
cannam@64 457
cannam@99 458 vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
cannam@99 459 typedef multimap<string, PluginLoader::PluginKey>
cannam@64 460 LibraryMap;
cannam@64 461 LibraryMap libraryMap;
cannam@64 462
cannam@64 463 for (size_t i = 0; i < plugins.size(); ++i) {
cannam@99 464 string path = loader->getLibraryPathForPlugin(plugins[i]);
cannam@64 465 libraryMap.insert(LibraryMap::value_type(path, plugins[i]));
cannam@64 466 }
cannam@64 467
cannam@99 468 string prevPath = "";
cannam@64 469 int index = 0;
cannam@64 470
cannam@64 471 for (LibraryMap::iterator i = libraryMap.begin();
cannam@64 472 i != libraryMap.end(); ++i) {
cannam@64 473
cannam@99 474 string path = i->first;
cannam@64 475 PluginLoader::PluginKey key = i->second;
cannam@64 476
cannam@64 477 if (path != prevPath) {
cannam@64 478 prevPath = path;
cannam@64 479 index = 0;
cannam@95 480 if (verbosity == PluginInformation) {
cannam@95 481 cout << "\n " << path << ":" << endl;
cannam@95 482 }
cannam@40 483 }
cannam@64 484
cannam@99 485 Plugin *plugin = loader->loadPlugin(key, 48000);
cannam@64 486 if (plugin) {
cannam@64 487
cannam@64 488 char c = char('A' + index);
cannam@64 489 if (c > 'Z') c = char('a' + (index - 26));
cannam@64 490
cannam@95 491 if (verbosity == PluginInformation) {
cannam@64 492
cannam@95 493 cout << " [" << c << "] [v"
cannam@95 494 << plugin->getVampApiVersion() << "] "
cannam@95 495 << plugin->getName() << ", \""
cannam@95 496 << plugin->getIdentifier() << "\"" << " ["
cannam@95 497 << plugin->getMaker() << "]" << endl;
cannam@95 498
cannam@95 499 PluginLoader::PluginCategoryHierarchy category =
cannam@95 500 loader->getPluginCategory(key);
cannam@95 501
cannam@95 502 if (!category.empty()) {
cannam@95 503 cout << " ";
cannam@95 504 for (size_t ci = 0; ci < category.size(); ++ci) {
cannam@95 505 cout << " > " << category[ci];
cannam@95 506 }
cannam@95 507 cout << endl;
cannam@64 508 }
cannam@95 509
cannam@95 510 if (plugin->getDescription() != "") {
cannam@95 511 cout << " - " << plugin->getDescription() << endl;
cannam@95 512 }
cannam@95 513
cannam@95 514 } else if (verbosity == PluginIds) {
cannam@95 515 cout << "vamp:" << key << endl;
cannam@47 516 }
cannam@95 517
cannam@99 518 Plugin::OutputList outputs =
cannam@64 519 plugin->getOutputDescriptors();
cannam@64 520
cannam@95 521 if (outputs.size() > 1 || verbosity == PluginOutputIds) {
cannam@64 522 for (size_t j = 0; j < outputs.size(); ++j) {
cannam@95 523 if (verbosity == PluginInformation) {
cannam@95 524 cout << " (" << j << ") "
cannam@95 525 << outputs[j].name << ", \""
cannam@95 526 << outputs[j].identifier << "\"" << endl;
cannam@95 527 if (outputs[j].description != "") {
cannam@95 528 cout << " - "
cannam@95 529 << outputs[j].description << endl;
cannam@95 530 }
cannam@95 531 } else if (verbosity == PluginOutputIds) {
cannam@95 532 cout << "vamp:" << key << ":" << outputs[j].identifier << endl;
cannam@40 533 }
cannam@40 534 }
cannam@64 535 }
cannam@64 536
cannam@64 537 ++index;
cannam@64 538
cannam@64 539 delete plugin;
cannam@40 540 }
cannam@40 541 }
cannam@64 542
cannam@95 543 if (verbosity == PluginInformation) {
cannam@95 544 cout << endl;
cannam@95 545 }
cannam@40 546 }
cannam@40 547
cannam@40 548 void
cannam@99 549 printPluginCategoryList()
cannam@16 550 {
cannam@99 551 PluginLoader *loader = PluginLoader::getInstance();
cannam@88 552
cannam@99 553 vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
cannam@88 554
cannam@99 555 set<string> printedcats;
cannam@99 556
cannam@99 557 for (size_t i = 0; i < plugins.size(); ++i) {
cannam@99 558
cannam@99 559 PluginLoader::PluginKey key = plugins[i];
cannam@99 560
cannam@99 561 PluginLoader::PluginCategoryHierarchy category =
cannam@99 562 loader->getPluginCategory(key);
cannam@99 563
cannam@99 564 Plugin *plugin = loader->loadPlugin(key, 48000);
cannam@99 565 if (!plugin) continue;
cannam@99 566
cannam@99 567 string catstr = "";
cannam@99 568
cannam@99 569 if (category.empty()) catstr = '|';
cannam@99 570 else {
cannam@99 571 for (size_t j = 0; j < category.size(); ++j) {
cannam@99 572 catstr += category[j];
cannam@99 573 catstr += '|';
cannam@99 574 if (printedcats.find(catstr) == printedcats.end()) {
cannam@99 575 std::cout << catstr << std::endl;
cannam@99 576 printedcats.insert(catstr);
cannam@99 577 }
cannam@99 578 }
cannam@16 579 }
cannam@88 580
cannam@99 581 std::cout << catstr << key << ":::" << plugin->getName() << ":::" << plugin->getMaker() << ":::" << plugin->getDescription() << std::endl;
cannam@16 582 }
cannam@16 583 }
cannam@16 584