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