Chris@423: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@423: Chris@423: /* Chris@423: Vamp Chris@423: Chris@423: An API for audio analysis and feature extraction plugins. Chris@423: Chris@423: Centre for Digital Music, Queen Mary, University of London. Chris@423: Copyright 2006-2016 Chris Cannam and QMUL. Chris@423: Chris@423: Permission is hereby granted, free of charge, to any person Chris@423: obtaining a copy of this software and associated documentation Chris@423: files (the "Software"), to deal in the Software without Chris@423: restriction, including without limitation the rights to use, copy, Chris@423: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@423: of the Software, and to permit persons to whom the Software is Chris@423: furnished to do so, subject to the following conditions: Chris@423: Chris@423: The above copyright notice and this permission notice shall be Chris@423: included in all copies or substantial portions of the Software. Chris@423: Chris@423: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@423: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@423: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@423: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR Chris@423: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@423: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@423: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@423: Chris@423: Except as contained in this notice, the names of the Centre for Chris@423: Digital Music; Queen Mary, University of London; and Chris Cannam Chris@423: shall not be used in advertising or otherwise to promote the sale, Chris@423: use or other dealings in this Software without prior written Chris@423: authorization. Chris@423: */ Chris@423: Chris@423: #ifndef VAMP_PLUGIN_CONFIGURATION_H Chris@423: #define VAMP_PLUGIN_CONFIGURATION_H Chris@423: Chris@423: #include "hostguard.h" Chris@423: Chris@428: #include "Plugin.h" Chris@428: Chris@423: #include Chris@423: #include Chris@423: Chris@423: _VAMP_SDK_HOSTSPACE_BEGIN(PluginConfiguration.h) Chris@423: Chris@423: namespace Vamp { Chris@423: Chris@423: namespace HostExt { Chris@423: Chris@423: /** Chris@423: * \class PluginConfiguration PluginConfiguration.h Chris@423: * Chris@423: * Vamp::HostExt::PluginConfiguration is a structure bundling together Chris@423: * data that affect the configuration of a plugin: parameter values, Chris@423: * programs, and initialisation settings. Although an interactive Vamp Chris@423: * plugin host may configure a plugin in stages, for example to take Chris@423: * into account that a plugin's preferred step and block size may Chris@423: * change when its parameters are changed, a batch host or a host Chris@423: * supporting store and recall of configurations may wish to keep all Chris@423: * configuration settings together. Chris@423: * Chris@423: * \note This class was introduced in version 2.7 of the Vamp plugin Chris@423: * SDK. Chris@423: */ Chris@423: struct PluginConfiguration Chris@423: { Chris@423: PluginConfiguration() : // invalid configuration by default Chris@423: channelCount(0), stepSize(0), blockSize(0) { } Chris@423: Chris@423: int channelCount; Chris@423: int stepSize; Chris@423: int blockSize; Chris@423: typedef std::map ParameterMap; Chris@423: ParameterMap parameterValues; Chris@423: std::string currentProgram; Chris@423: Chris@423: static PluginConfiguration Chris@423: fromPlugin(Plugin *p, Chris@423: int channelCount, Chris@423: int stepSize, Chris@423: int blockSize) { Chris@423: Chris@423: PluginConfiguration c; Chris@423: Chris@423: c.channelCount = channelCount; Chris@423: c.stepSize = stepSize; Chris@423: c.blockSize = blockSize; Chris@423: Chris@423: PluginBase::ParameterList params = p->getParameterDescriptors(); Chris@423: for (PluginBase::ParameterList::const_iterator i = params.begin(); Chris@423: i != params.end(); ++i) { Chris@423: std::string pid = i->identifier; Chris@423: c.parameterValues[pid] = p->getParameter(pid); Chris@423: } Chris@423: Chris@423: if (!p->getPrograms().empty()) { Chris@423: c.currentProgram = p->getCurrentProgram(); Chris@423: } Chris@423: Chris@423: return c; Chris@423: } Chris@423: }; Chris@423: Chris@428: /** Chris@428: * \class ConfigurationRequest PluginConfiguration.h Chris@428: * Chris@428: * A wrapper for a plugin pointer and PluginConfiguration, bundling up Chris@428: * the data needed to configure a plugin after it has been loaded. Chris@428: * Chris@428: * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse Chris@428: */ Chris@428: struct ConfigurationRequest Chris@428: { Chris@428: public: Chris@428: ConfigurationRequest() : // invalid request by default Chris@428: plugin(0) { } Chris@428: Chris@428: Plugin *plugin; Chris@428: PluginConfiguration configuration; Chris@428: }; Chris@428: Chris@428: /** Chris@428: * \class ConfigurationResponse PluginConfiguration.h Chris@428: * Chris@428: * The return value from a configuration request (i.e. setting the Chris@428: * parameters and initialising the plugin). If the configuration was Chris@428: * successful, the output list will contain the final Chris@428: * post-initialisation output descriptors. If configuration failed, Chris@428: * the output list will be empty. Chris@428: * Chris@428: * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse Chris@428: */ Chris@428: struct ConfigurationResponse Chris@428: { Chris@428: public: Chris@428: ConfigurationResponse() // failed by default Chris@428: { } Chris@428: Chris@428: Plugin::OutputList outputs; Chris@428: }; Chris@428: Chris@423: } Chris@423: Chris@423: } Chris@423: Chris@423: _VAMP_SDK_HOSTSPACE_END(PluginConfiguration.h) Chris@423: Chris@423: #endif