c@97: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@97: c@97: /* c@97: Piper C++ c@97: c@97: An API for audio analysis and feature extraction plugins. c@97: c@97: Centre for Digital Music, Queen Mary, University of London. c@97: Copyright 2006-2016 Chris Cannam and QMUL. c@97: c@97: Permission is hereby granted, free of charge, to any person c@97: obtaining a copy of this software and associated documentation c@97: files (the "Software"), to deal in the Software without c@97: restriction, including without limitation the rights to use, copy, c@97: modify, merge, publish, distribute, sublicense, and/or sell copies c@97: of the Software, and to permit persons to whom the Software is c@97: furnished to do so, subject to the following conditions: c@97: c@97: The above copyright notice and this permission notice shall be c@97: included in all copies or substantial portions of the Software. c@97: c@97: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@97: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@97: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@97: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR c@97: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@97: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@97: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@97: c@97: Except as contained in this notice, the names of the Centre for c@97: Digital Music; Queen Mary, University of London; and Chris Cannam c@97: shall not be used in advertising or otherwise to promote the sale, c@97: use or other dealings in this Software without prior written c@97: authorization. c@97: */ c@97: c@97: #ifndef PIPER_REQUEST_RESPONSE_H c@97: #define PIPER_REQUEST_RESPONSE_H c@97: c@97: #include "PluginStaticData.h" c@97: #include "PluginConfiguration.h" c@97: c@97: #include c@97: #include c@97: c@97: namespace piper_vamp { c@97: c@97: /** c@97: * \class ListRequest c@97: * c@97: * ListRequest is a structure containing the information needed to c@97: * list plugins. Currently empty. c@97: * c@97: * \see ListResponse c@97: */ c@97: struct ListRequest c@97: { c@97: }; c@97: c@97: /** c@97: * \class ListResponse c@97: * c@97: * ListResponse is a structure containing the information returned by c@97: * PluginLoader when asked to list static information about the c@97: * available plugins. c@97: * c@97: * \see PluginStaticData c@97: */ c@97: struct ListResponse c@97: { c@97: ListResponse() { } // empty by default c@97: c@97: std::vector available; c@97: }; c@97: c@97: /** c@97: * \class LoadRequest c@97: * c@97: * LoadRequest is a structure containing the information necessary to c@97: * load a plugin. When a request is made to load a plugin using a c@97: * LoadRequest, the response is typically returned in a LoadResponse c@97: * structure. c@97: * c@97: * \see LoadResponse c@97: */ c@97: struct LoadRequest c@97: { c@97: LoadRequest() : // invalid request by default c@97: inputSampleRate(0.f), c@97: adapterFlags(0) { } c@97: c@97: /** c@97: * PluginKey is a string type that is used to identify a plugin c@97: * uniquely within the scope of "the current system". For further c@97: * details \see Vamp::PluginLoader::PluginKey. c@97: */ c@97: typedef std::string PluginKey; c@97: c@97: /** c@97: * The identifying key for the plugin to be loaded. c@97: */ c@97: PluginKey pluginKey; c@97: c@97: /** c@97: * Sample rate to be passed to the plugin's constructor. c@97: */ c@97: float inputSampleRate; c@97: c@97: /** c@97: * A bitwise OR of the values in the PluginLoader::AdapterFlags c@97: * enumeration, indicating under which circumstances an adapter c@97: * should be used to wrap the original plugin. If adapterFlags is c@97: * 0, no optional adapters will be used. c@97: * c@97: * \see Vamp::PluginLoader::AdapterFlags c@97: */ c@97: int adapterFlags; c@97: }; c@97: c@97: /** c@97: * \class LoadResponse c@97: * c@97: * LoadResponse is a structure containing the information returned by c@97: * PluginLoader when asked to load a plugin using a LoadRequest. c@97: * c@97: * If the plugin could not be loaded, the plugin field will be 0. c@97: * c@97: * The caller takes ownership of the plugin contained here, which c@97: * should be deleted (using the standard C++ delete keyword) after c@97: * use. c@97: * c@97: * \see LoadRequest c@97: */ c@97: struct LoadResponse c@97: { c@97: LoadResponse() : // invalid (failed) response by default c@97: plugin(0) { } c@97: c@97: /** c@97: * A pointer to the loaded plugin, or 0 if loading failed. Caller c@97: * takes ownership of the plugin and must delete it after use. c@97: */ c@97: Vamp::Plugin *plugin; c@97: c@97: /** c@97: * The static data associated with the loaded plugin, that is, all c@97: * information about it that does not depend on its configuration c@97: * (parameters, programs, initialisation parameters). The contents c@97: * of this structure are only valid if plugin is non-0. c@97: * c@97: * Much of the data in here is duplicated with the plugin itself. c@97: */ c@97: PluginStaticData staticData; c@97: c@97: /** c@97: * The default configuration for this plugin, that is, default c@97: * values for parameters etc. The contents of this structure are c@97: * only valid if plugin is non-0. c@97: */ c@97: PluginConfiguration defaultConfiguration; c@97: }; c@97: c@97: /** c@97: * \class ConfigurationRequest c@97: * c@97: * A wrapper for a plugin pointer and PluginConfiguration, bundling up c@97: * the data needed to configure a plugin after it has been loaded. c@97: * c@97: * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse c@97: */ c@97: struct ConfigurationRequest c@97: { c@97: public: c@97: ConfigurationRequest() : // invalid request by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: PluginConfiguration configuration; c@97: }; c@97: c@97: /** c@97: * \class ConfigurationResponse c@97: * c@97: * The return value from a configuration request (i.e. setting the c@97: * parameters and initialising the plugin). If the configuration was c@97: * successful, the output list will contain the final c@97: * post-initialisation output descriptors. If configuration failed, c@97: * the output list will be empty. c@97: * c@97: * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse c@97: */ c@97: struct ConfigurationResponse c@97: { c@97: public: c@97: ConfigurationResponse() : // failed by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: Vamp::Plugin::OutputList outputs; c@97: }; c@97: c@97: /** c@97: * \class ProcessRequest c@97: * c@97: * A structure that bundles the necessary data for making a process c@97: * call: plugin, input buffers, and timestamp. Caller retains c@97: * ownership of the plugin, but the buffers are passed "by value" to c@97: * avoid ownership concerns. c@97: * c@97: * \see Vamp::Plugin::process() c@97: */ c@97: struct ProcessRequest c@97: { c@97: public: c@97: ProcessRequest() : // invalid by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: std::vector > inputBuffers; c@97: Vamp::RealTime timestamp; c@97: }; c@97: c@97: /** c@97: * \class ProcessResponse c@97: * c@97: * A structure that bundles the data returned by a process call. This c@97: * is simply a FeatureSet wrapper that happens to reference the plugin c@97: * as well. c@97: * c@97: * \see FinishResponse, Vamp::Plugin::process() c@97: */ c@97: struct ProcessResponse c@97: { c@97: public: c@97: ProcessResponse() : // invalid by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: Vamp::Plugin::FeatureSet features; c@97: }; c@97: c@97: /** c@97: * \class FinishRequest c@97: * c@97: * A structure that bundles the necessary data for finishing c@97: * processing, i.e. calling getRemainingFeatures(). This consists only c@97: * of the plugin pointer. Caller retains ownership of the plugin. c@97: * c@97: * \see Vamp::Plugin::getRemainingFeatures() c@97: */ c@97: struct FinishRequest c@97: { c@97: public: c@97: FinishRequest() : // invalid by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: }; c@97: c@97: c@97: /** c@97: * \class FinishResponse c@97: * c@97: * A structure that bundles the data returned by a c@97: * getRemainingFeatures() call. This is identical to ProcessResponse. c@97: * c@97: * \see ProcessResponse, Vamp::Plugin::getRemainingFeatures() c@97: */ c@97: struct FinishResponse c@97: { c@97: public: c@97: FinishResponse() : // invalid by default c@97: plugin(0) { } c@97: c@97: Vamp::Plugin *plugin; c@97: Vamp::Plugin::FeatureSet features; c@97: }; c@97: c@97: } c@97: c@97: #endif