Mercurial > hg > vamp-plugin-sdk
diff 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 |
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginLoader.cpp Thu Apr 14 14:23:48 2016 +0100 +++ b/src/vamp-hostsdk/PluginLoader.cpp Thu May 12 12:22:02 2016 +0100 @@ -6,7 +6,7 @@ An API for audio analysis and feature extraction plugins. Centre for Digital Music, Queen Mary, University of London. - Copyright 2006-2009 Chris Cannam and QMUL. + Copyright 2006-2016 Chris Cannam and QMUL. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -66,6 +66,10 @@ float inputSampleRate, int adapterFlags); + LoadResponse loadPlugin(LoadRequest req); + + Plugin::OutputList configurePlugin(Plugin *plugin, PluginConfiguration config); + PluginKey composePluginKey(string libraryName, string identifier); PluginCategoryHierarchy getPluginCategory(PluginKey key); @@ -152,6 +156,18 @@ return m_impl->loadPlugin(key, inputSampleRate, adapterFlags); } +LoadResponse +PluginLoader::loadPlugin(LoadRequest req) +{ + return m_impl->loadPlugin(req); +} + +Plugin::OutputList +PluginLoader::configurePlugin(Plugin *plugin, PluginConfiguration config) +{ + return m_impl->configurePlugin(plugin, config); +} + PluginLoader::PluginKey PluginLoader::composePluginKey(string libraryName, string identifier) { @@ -382,6 +398,57 @@ return 0; } +LoadResponse +PluginLoader::Impl::loadPlugin(LoadRequest req) +{ + Plugin *plugin = loadPlugin(req.pluginKey, + req.inputSampleRate, + req.adapterFlags); + LoadResponse response; + if (!plugin) return response; + + response.plugin = plugin; + response.staticData = PluginStaticData::fromPlugin + (req.pluginKey, + getPluginCategory(req.pluginKey), + plugin); + + int defaultChannels = 0; + if (plugin->getMinChannelCount() == plugin->getMaxChannelCount()) { + defaultChannels = plugin->getMinChannelCount(); + } + + response.defaultConfiguration = PluginConfiguration::fromPlugin + (plugin, + defaultChannels, + plugin->getPreferredStepSize(), + plugin->getPreferredBlockSize()); + + return response; +} + +Plugin::OutputList +PluginLoader::Impl::configurePlugin(Plugin *plugin, PluginConfiguration config) +{ + for (PluginConfiguration::ParameterMap::const_iterator i = + config.parameterValues.begin(); + i != config.parameterValues.end(); ++i) { + plugin->setParameter(i->first, i->second); + } + + if (config.currentProgram != "") { + plugin->selectProgram(config.currentProgram); + } + + if (plugin->initialise(config.channelCount, + config.stepSize, + config.blockSize)) { + return plugin->getOutputDescriptors(); + } else { + return Plugin::OutputList(); + } +} + void PluginLoader::Impl::generateTaxonomy() {