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