Chris@25: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@25: Chris@25: /* Chris@25: Vamp Chris@25: Chris@25: An API for audio analysis and feature extraction plugins. Chris@25: Chris@25: Centre for Digital Music, Queen Mary, University of London. Chris@25: Copyright 2006 Chris Cannam. Chris@25: Chris@25: Permission is hereby granted, free of charge, to any person Chris@25: obtaining a copy of this software and associated documentation Chris@25: files (the "Software"), to deal in the Software without Chris@25: restriction, including without limitation the rights to use, copy, Chris@25: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@25: of the Software, and to permit persons to whom the Software is Chris@25: furnished to do so, subject to the following conditions: Chris@25: Chris@25: The above copyright notice and this permission notice shall be Chris@25: included in all copies or substantial portions of the Software. Chris@25: Chris@25: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@25: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@25: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@25: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR Chris@25: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@25: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@25: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@25: Chris@25: Except as contained in this notice, the names of the Centre for Chris@25: Digital Music; Queen Mary, University of London; and Chris Cannam Chris@25: shall not be used in advertising or otherwise to promote the sale, Chris@25: use or other dealings in this Software without prior written Chris@25: authorization. Chris@25: */ Chris@25: Chris@25: #ifndef _VAMP_SDK_PLUGIN_BASE_H_ Chris@25: #define _VAMP_SDK_PLUGIN_BASE_H_ Chris@25: Chris@25: #include Chris@25: #include Chris@25: Chris@25: #include "plugguard.h" Chris@25: _VAMP_SDK_PLUGSPACE_BEGIN(PluginBase.h) Chris@25: Chris@25: namespace Vamp { Chris@25: Chris@25: /** Chris@25: * A base class for plugins with optional configurable parameters, Chris@25: * programs, etc. The Vamp::Plugin is derived from this, and Chris@25: * individual Vamp plugins should derive from that. Chris@25: * Chris@25: * This class does not provide the necessary interfaces to instantiate Chris@25: * or run a plugin. It only specifies an interface for retrieving Chris@25: * those controls that the host may wish to show to the user for Chris@25: * editing. It could meaningfully be subclassed by real-time plugins Chris@25: * or other sorts of plugin as well as Vamp plugins. Chris@25: */ Chris@25: Chris@25: class PluginBase Chris@25: { Chris@25: public: Chris@25: virtual ~PluginBase() { } Chris@25: Chris@25: /** Chris@25: * Get the Vamp API compatibility level of the plugin. Chris@25: */ Chris@25: virtual unsigned int getVampApiVersion() const { return 2; } Chris@25: Chris@25: /** Chris@25: * Get the computer-usable name of the plugin. This should be Chris@25: * reasonably short and contain no whitespace or punctuation Chris@25: * characters. It may only contain the characters [a-zA-Z0-9_-]. Chris@25: * This is the authoritative way for a program to identify a Chris@25: * plugin within a given library. Chris@25: * Chris@25: * This text may be visible to the user, but it should not be the Chris@25: * main text used to identify a plugin to the user (that will be Chris@25: * the name, below). Chris@25: * Chris@25: * Example: "zero_crossings" Chris@25: */ Chris@25: virtual std::string getIdentifier() const = 0; Chris@25: Chris@25: /** Chris@25: * Get a human-readable name or title of the plugin. This Chris@25: * should be brief and self-contained, as it may be used to Chris@25: * identify the plugin to the user in isolation (i.e. without also Chris@25: * showing the plugin's "identifier"). Chris@25: * Chris@25: * Example: "Zero Crossings" Chris@25: */ Chris@25: virtual std::string getName() const = 0; Chris@25: Chris@25: /** Chris@25: * Get a human-readable description for the plugin, typically Chris@25: * a line of text that may optionally be displayed in addition Chris@25: * to the plugin's "name". May be empty if the name has said Chris@25: * it all already. Chris@25: * Chris@25: * Example: "Detect and count zero crossing points" Chris@25: */ Chris@25: virtual std::string getDescription() const = 0; Chris@25: Chris@25: /** Chris@25: * Get the name of the author or vendor of the plugin in Chris@25: * human-readable form. This should be a short identifying text, Chris@25: * as it may be used to label plugins from the same source in a Chris@25: * menu or similar. Chris@25: */ Chris@25: virtual std::string getMaker() const = 0; Chris@25: Chris@25: /** Chris@25: * Get the copyright statement or licensing summary for the Chris@25: * plugin. This can be an informative text, without the same Chris@25: * presentation constraints as mentioned for getMaker above. Chris@25: */ Chris@25: virtual std::string getCopyright() const = 0; Chris@25: Chris@25: /** Chris@25: * Get the version number of the plugin. Chris@25: */ Chris@25: virtual int getPluginVersion() const = 0; Chris@25: Chris@25: Chris@25: struct ParameterDescriptor Chris@25: { Chris@25: /** Chris@25: * The name of the parameter, in computer-usable form. Should Chris@25: * be reasonably short, and may only contain the characters Chris@25: * [a-zA-Z0-9_-]. Chris@25: */ Chris@25: std::string identifier; Chris@25: Chris@25: /** Chris@25: * The human-readable name of the parameter. Chris@25: */ Chris@25: std::string name; Chris@25: Chris@25: /** Chris@25: * A human-readable short text describing the parameter. May be Chris@25: * empty if the name has said it all already. Chris@25: */ Chris@25: std::string description; Chris@25: Chris@25: /** Chris@25: * The unit of the parameter, in human-readable form. Chris@25: */ Chris@25: std::string unit; Chris@25: Chris@25: /** Chris@25: * The minimum value of the parameter. Chris@25: */ Chris@25: float minValue; Chris@25: Chris@25: /** Chris@25: * The maximum value of the parameter. Chris@25: */ Chris@25: float maxValue; Chris@25: Chris@25: /** Chris@25: * The default value of the parameter. The plugin should Chris@25: * ensure that parameters have this value on initialisation Chris@25: * (i.e. the host is not required to explicitly set parameters Chris@25: * if it wants to use their default values). Chris@25: */ Chris@25: float defaultValue; Chris@25: Chris@25: /** Chris@25: * True if the parameter values are quantized to a particular Chris@25: * resolution. Chris@25: */ Chris@25: bool isQuantized; Chris@25: Chris@25: /** Chris@25: * Quantization resolution of the parameter values (e.g. 1.0 Chris@25: * if they are all integers). Undefined if isQuantized is Chris@25: * false. Chris@25: */ Chris@25: float quantizeStep; Chris@25: Chris@25: /** Chris@25: * Names for the quantized values. If isQuantized is true, Chris@25: * this may either be empty or contain one string for each of Chris@25: * the quantize steps from minValue up to maxValue inclusive. Chris@25: * Undefined if isQuantized is false. Chris@25: * Chris@25: * If these names are provided, they should be shown to the Chris@25: * user in preference to the values themselves. The user may Chris@25: * never see the actual numeric values unless they are also Chris@25: * encoded in the names. Chris@25: */ Chris@25: std::vector valueNames; Chris@25: Chris@25: ParameterDescriptor() : // the defaults are invalid: you must set them Chris@25: minValue(0), maxValue(0), defaultValue(0), isQuantized(false) { } Chris@25: }; Chris@25: Chris@25: typedef std::vector ParameterList; Chris@25: Chris@25: /** Chris@25: * Get the controllable parameters of this plugin. Chris@25: */ Chris@25: virtual ParameterList getParameterDescriptors() const { Chris@25: return ParameterList(); Chris@25: } Chris@25: Chris@25: /** Chris@25: * Get the value of a named parameter. The argument is the identifier Chris@25: * field from that parameter's descriptor. Chris@25: */ Chris@25: virtual float getParameter(std::string) const { return 0.0; } Chris@25: Chris@25: /** Chris@25: * Set a named parameter. The first argument is the identifier field Chris@25: * from that parameter's descriptor. Chris@25: */ Chris@25: virtual void setParameter(std::string, float) { } Chris@25: Chris@25: Chris@25: typedef std::vector ProgramList; Chris@25: Chris@25: /** Chris@25: * Get the program settings available in this plugin. A program Chris@25: * is a named shorthand for a set of parameter values; changing Chris@25: * the program may cause the plugin to alter the values of its Chris@25: * published parameters (and/or non-public internal processing Chris@25: * parameters). The host should re-read the plugin's parameter Chris@25: * values after setting a new program. Chris@25: * Chris@25: * The programs must have unique names. Chris@25: */ Chris@25: virtual ProgramList getPrograms() const { return ProgramList(); } Chris@25: Chris@25: /** Chris@25: * Get the current program. Chris@25: */ Chris@25: virtual std::string getCurrentProgram() const { return ""; } Chris@25: Chris@25: /** Chris@25: * Select a program. (If the given program name is not one of the Chris@25: * available programs, do nothing.) Chris@25: */ Chris@25: virtual void selectProgram(std::string) { } Chris@25: Chris@25: /** Chris@25: * Get the type of plugin. This is to be implemented by the Chris@25: * immediate subclass, not by actual plugins. Do not attempt to Chris@25: * implement this in plugin code. Chris@25: */ Chris@25: virtual std::string getType() const = 0; Chris@25: }; Chris@25: Chris@25: } Chris@25: Chris@25: _VAMP_SDK_PLUGSPACE_END(PluginBase.h) Chris@25: Chris@25: #endif