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