Mercurial > hg > vamp-plugin-sdk
comparison src/vamp-hostsdk/PluginLoader.cpp @ 460:b409560a805b
Merge from branch vampipe
author | Chris Cannam |
---|---|
date | Mon, 10 Oct 2016 15:48:35 +0100 |
parents | c053e5e79b8f |
children | 5c07a86abddd |
comparison
equal
deleted
inserted
replaced
442:4101e3f80aa0 | 460:b409560a805b |
---|---|
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, |
59 public: | 59 public: |
60 Impl(); | 60 Impl(); |
61 virtual ~Impl(); | 61 virtual ~Impl(); |
62 | 62 |
63 PluginKeyList listPlugins(); | 63 PluginKeyList listPlugins(); |
64 PluginStaticDataList listPluginData(); | |
64 | 65 |
65 Plugin *loadPlugin(PluginKey key, | 66 Plugin *loadPlugin(PluginKey key, |
66 float inputSampleRate, | 67 float inputSampleRate, |
67 int adapterFlags); | 68 int adapterFlags); |
68 | 69 |
70 LoadResponse loadPlugin(LoadRequest req); | |
71 | |
72 ConfigurationResponse configurePlugin(ConfigurationRequest req); | |
73 | |
69 PluginKey composePluginKey(string libraryName, string identifier); | 74 PluginKey composePluginKey(string libraryName, string identifier); |
70 | 75 |
71 PluginCategoryHierarchy getPluginCategory(PluginKey key); | 76 PluginCategoryHierarchy getPluginCategory(PluginKey key); |
72 | 77 |
73 string getLibraryPathForPlugin(PluginKey key); | 78 string getLibraryPathForPlugin(PluginKey key); |
136 Impl::setInstanceToClean(m_instance); | 141 Impl::setInstanceToClean(m_instance); |
137 } | 142 } |
138 return m_instance; | 143 return m_instance; |
139 } | 144 } |
140 | 145 |
141 vector<PluginLoader::PluginKey> | 146 PluginLoader::PluginKeyList |
142 PluginLoader::listPlugins() | 147 PluginLoader::listPlugins() |
143 { | 148 { |
144 return m_impl->listPlugins(); | 149 return m_impl->listPlugins(); |
150 } | |
151 | |
152 PluginLoader::PluginStaticDataList | |
153 PluginLoader::listPluginData() | |
154 { | |
155 return m_impl->listPluginData(); | |
145 } | 156 } |
146 | 157 |
147 Plugin * | 158 Plugin * |
148 PluginLoader::loadPlugin(PluginKey key, | 159 PluginLoader::loadPlugin(PluginKey key, |
149 float inputSampleRate, | 160 float inputSampleRate, |
150 int adapterFlags) | 161 int adapterFlags) |
151 { | 162 { |
152 return m_impl->loadPlugin(key, inputSampleRate, adapterFlags); | 163 return m_impl->loadPlugin(key, inputSampleRate, adapterFlags); |
153 } | 164 } |
154 | 165 |
166 LoadResponse | |
167 PluginLoader::loadPlugin(LoadRequest req) | |
168 { | |
169 return m_impl->loadPlugin(req); | |
170 } | |
171 | |
172 ConfigurationResponse | |
173 PluginLoader::configurePlugin(ConfigurationRequest req) | |
174 { | |
175 return m_impl->configurePlugin(req); | |
176 } | |
177 | |
155 PluginLoader::PluginKey | 178 PluginLoader::PluginKey |
156 PluginLoader::composePluginKey(string libraryName, string identifier) | 179 PluginLoader::composePluginKey(string libraryName, string identifier) |
157 { | 180 { |
158 return m_impl->composePluginKey(libraryName, identifier); | 181 return m_impl->composePluginKey(libraryName, identifier); |
159 } | 182 } |
183 PluginLoader::Impl::setInstanceToClean(PluginLoader *instance) | 206 PluginLoader::Impl::setInstanceToClean(PluginLoader *instance) |
184 { | 207 { |
185 m_cleaner.setInstance(instance); | 208 m_cleaner.setInstance(instance); |
186 } | 209 } |
187 | 210 |
188 vector<PluginLoader::PluginKey> | 211 PluginLoader::PluginKeyList |
189 PluginLoader::Impl::listPlugins() | 212 PluginLoader::Impl::listPlugins() |
190 { | 213 { |
191 if (!m_allPluginsEnumerated) enumeratePlugins(); | 214 if (!m_allPluginsEnumerated) enumeratePlugins(); |
192 | 215 |
193 vector<PluginKey> plugins; | 216 vector<PluginKey> plugins; |
195 mi != m_pluginLibraryNameMap.end(); ++mi) { | 218 mi != m_pluginLibraryNameMap.end(); ++mi) { |
196 plugins.push_back(mi->first); | 219 plugins.push_back(mi->first); |
197 } | 220 } |
198 | 221 |
199 return plugins; | 222 return plugins; |
223 } | |
224 | |
225 PluginLoader::PluginStaticDataList | |
226 PluginLoader::Impl::listPluginData() | |
227 { | |
228 PluginKeyList keys = listPlugins(); | |
229 PluginStaticDataList dataList; | |
230 | |
231 for (PluginKeyList::const_iterator ki = keys.begin(); ki != keys.end(); ++ki) { | |
232 string key = *ki; | |
233 Plugin *p = loadPlugin(key, 44100, 0); | |
234 if (p) { | |
235 PluginCategoryHierarchy category = getPluginCategory(key); | |
236 dataList.push_back(PluginStaticData::fromPlugin(key, category, p)); | |
237 } | |
238 delete p; | |
239 } | |
240 | |
241 return dataList; | |
200 } | 242 } |
201 | 243 |
202 void | 244 void |
203 PluginLoader::Impl::enumeratePlugins(PluginKey forPlugin) | 245 PluginLoader::Impl::enumeratePlugins(PluginKey forPlugin) |
204 { | 246 { |
380 << fullPath << "\"" << endl; | 422 << fullPath << "\"" << endl; |
381 | 423 |
382 return 0; | 424 return 0; |
383 } | 425 } |
384 | 426 |
427 LoadResponse | |
428 PluginLoader::Impl::loadPlugin(LoadRequest req) | |
429 { | |
430 Plugin *plugin = loadPlugin(req.pluginKey, | |
431 req.inputSampleRate, | |
432 req.adapterFlags); | |
433 LoadResponse response; | |
434 response.plugin = plugin; | |
435 if (!plugin) return response; | |
436 | |
437 response.plugin = plugin; | |
438 response.staticData = PluginStaticData::fromPlugin | |
439 (req.pluginKey, | |
440 getPluginCategory(req.pluginKey), | |
441 plugin); | |
442 | |
443 int defaultChannels = 0; | |
444 if (plugin->getMinChannelCount() == plugin->getMaxChannelCount()) { | |
445 defaultChannels = plugin->getMinChannelCount(); | |
446 } | |
447 | |
448 response.defaultConfiguration = PluginConfiguration::fromPlugin | |
449 (plugin, | |
450 defaultChannels, | |
451 plugin->getPreferredStepSize(), | |
452 plugin->getPreferredBlockSize()); | |
453 | |
454 return response; | |
455 } | |
456 | |
457 ConfigurationResponse | |
458 PluginLoader::Impl::configurePlugin(ConfigurationRequest req) | |
459 { | |
460 for (PluginConfiguration::ParameterMap::const_iterator i = | |
461 req.configuration.parameterValues.begin(); | |
462 i != req.configuration.parameterValues.end(); ++i) { | |
463 req.plugin->setParameter(i->first, i->second); | |
464 } | |
465 | |
466 if (req.configuration.currentProgram != "") { | |
467 req.plugin->selectProgram(req.configuration.currentProgram); | |
468 } | |
469 | |
470 ConfigurationResponse response; | |
471 | |
472 if (req.plugin->initialise(req.configuration.channelCount, | |
473 req.configuration.stepSize, | |
474 req.configuration.blockSize)) { | |
475 response.outputs = req.plugin->getOutputDescriptors(); | |
476 } | |
477 | |
478 return response; | |
479 } | |
480 | |
385 void | 481 void |
386 PluginLoader::Impl::generateTaxonomy() | 482 PluginLoader::Impl::generateTaxonomy() |
387 { | 483 { |
388 // cerr << "PluginLoader::Impl::generateTaxonomy" << endl; | 484 // cerr << "PluginLoader::Impl::generateTaxonomy" << endl; |
389 | 485 |