comparison src/vamp-hostsdk/PluginLoader.cpp @ 423:8c45dee08a95 vampipe

Add PluginConfiguration, PluginStaticData, and LoadRequest structures, and use them in PluginLoader
author Chris Cannam
date Thu, 12 May 2016 12:22:02 +0100
parents 06988ce35ff0
children 6b2567f365b0
comparison
equal deleted inserted replaced
422:9a2998401bbe 423:8c45dee08a95
4 Vamp 4 Vamp
5 5
6 An API for audio analysis and feature extraction plugins. 6 An API for audio analysis and feature extraction plugins.
7 7
8 Centre for Digital Music, Queen Mary, University of London. 8 Centre for Digital Music, Queen Mary, University of London.
9 Copyright 2006-2009 Chris Cannam and QMUL. 9 Copyright 2006-2016 Chris Cannam and QMUL.
10 10
11 Permission is hereby granted, free of charge, to any person 11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation 12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without 13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use, copy, 14 restriction, including without limitation the rights to use, copy,
64 64
65 Plugin *loadPlugin(PluginKey key, 65 Plugin *loadPlugin(PluginKey key,
66 float inputSampleRate, 66 float inputSampleRate,
67 int adapterFlags); 67 int adapterFlags);
68 68
69 LoadResponse loadPlugin(LoadRequest req);
70
71 Plugin::OutputList configurePlugin(Plugin *plugin, PluginConfiguration config);
72
69 PluginKey composePluginKey(string libraryName, string identifier); 73 PluginKey composePluginKey(string libraryName, string identifier);
70 74
71 PluginCategoryHierarchy getPluginCategory(PluginKey key); 75 PluginCategoryHierarchy getPluginCategory(PluginKey key);
72 76
73 string getLibraryPathForPlugin(PluginKey key); 77 string getLibraryPathForPlugin(PluginKey key);
148 PluginLoader::loadPlugin(PluginKey key, 152 PluginLoader::loadPlugin(PluginKey key,
149 float inputSampleRate, 153 float inputSampleRate,
150 int adapterFlags) 154 int adapterFlags)
151 { 155 {
152 return m_impl->loadPlugin(key, inputSampleRate, adapterFlags); 156 return m_impl->loadPlugin(key, inputSampleRate, adapterFlags);
157 }
158
159 LoadResponse
160 PluginLoader::loadPlugin(LoadRequest req)
161 {
162 return m_impl->loadPlugin(req);
163 }
164
165 Plugin::OutputList
166 PluginLoader::configurePlugin(Plugin *plugin, PluginConfiguration config)
167 {
168 return m_impl->configurePlugin(plugin, config);
153 } 169 }
154 170
155 PluginLoader::PluginKey 171 PluginLoader::PluginKey
156 PluginLoader::composePluginKey(string libraryName, string identifier) 172 PluginLoader::composePluginKey(string libraryName, string identifier)
157 { 173 {
380 << fullPath << "\"" << endl; 396 << fullPath << "\"" << endl;
381 397
382 return 0; 398 return 0;
383 } 399 }
384 400
401 LoadResponse
402 PluginLoader::Impl::loadPlugin(LoadRequest req)
403 {
404 Plugin *plugin = loadPlugin(req.pluginKey,
405 req.inputSampleRate,
406 req.adapterFlags);
407 LoadResponse response;
408 if (!plugin) return response;
409
410 response.plugin = plugin;
411 response.staticData = PluginStaticData::fromPlugin
412 (req.pluginKey,
413 getPluginCategory(req.pluginKey),
414 plugin);
415
416 int defaultChannels = 0;
417 if (plugin->getMinChannelCount() == plugin->getMaxChannelCount()) {
418 defaultChannels = plugin->getMinChannelCount();
419 }
420
421 response.defaultConfiguration = PluginConfiguration::fromPlugin
422 (plugin,
423 defaultChannels,
424 plugin->getPreferredStepSize(),
425 plugin->getPreferredBlockSize());
426
427 return response;
428 }
429
430 Plugin::OutputList
431 PluginLoader::Impl::configurePlugin(Plugin *plugin, PluginConfiguration config)
432 {
433 for (PluginConfiguration::ParameterMap::const_iterator i =
434 config.parameterValues.begin();
435 i != config.parameterValues.end(); ++i) {
436 plugin->setParameter(i->first, i->second);
437 }
438
439 if (config.currentProgram != "") {
440 plugin->selectProgram(config.currentProgram);
441 }
442
443 if (plugin->initialise(config.channelCount,
444 config.stepSize,
445 config.blockSize)) {
446 return plugin->getOutputDescriptors();
447 } else {
448 return Plugin::OutputList();
449 }
450 }
451
385 void 452 void
386 PluginLoader::Impl::generateTaxonomy() 453 PluginLoader::Impl::generateTaxonomy()
387 { 454 {
388 // cerr << "PluginLoader::Impl::generateTaxonomy" << endl; 455 // cerr << "PluginLoader::Impl::generateTaxonomy" << endl;
389 456