1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6 An API for audio analysis and feature extraction plugins.
8 Centre for Digital Music, Queen Mary, University of London.
9 Copyright 2006 Chris Cannam.
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use, copy,
15 modify, merge, publish, distribute, sublicense, and/or sell copies
16 of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 Except as contained in this notice, the names of the Centre for
31 Digital Music; Queen Mary, University of London; and Chris Cannam
32 shall not be used in advertising or otherwise to promote the sale,
33 use or other dealings in this Software without prior written
37 #ifndef _VAMP_PLUGIN_BASE_H_
38 #define _VAMP_PLUGIN_BASE_H_
43 #define VAMP_SDK_VERSION "1.1"
48 * A base class for plugins with optional configurable parameters,
49 * programs, etc. The Vamp::Plugin is derived from this, and
50 * individual Vamp plugins should derive from that.
52 * This class does not provide the necessary interfaces to instantiate
53 * or run a plugin. It only specifies an interface for retrieving
54 * those controls that the host may wish to show to the user for
55 * editing. It could meaningfully be subclassed by real-time plugins
56 * or other sorts of plugin as well as Vamp plugins.
62 virtual ~PluginBase() { }
65 * Get the Vamp API compatibility level of the plugin.
67 virtual unsigned int getVampApiVersion() const { return 1; }
70 * Get the computer-usable name of the plugin. This should be
71 * reasonably short and contain no whitespace or punctuation
72 * characters. It may only contain the characters [a-zA-Z0-9_].
73 * This is the authoritative way for a program to identify a
74 * plugin within a given library.
76 * This text may be visible to the user, but it should not be the
77 * main text used to identify a plugin to the user (that will be
80 * Example: "zero_crossings"
82 virtual std::string getIdentifier() const = 0;
85 * Get a human-readable name or title of the plugin. This
86 * should be brief and self-contained, as it may be used to
87 * identify the plugin to the user in isolation (i.e. without also
88 * showing the plugin's "identifier").
90 * Example: "Zero Crossings"
92 virtual std::string getName() const = 0;
95 * Get a human-readable description for the plugin, typically
96 * a line of text that may optionally be displayed in addition
97 * to the plugin's "name". May be empty if the name has said
100 * Example: "Detect and count zero crossing points"
102 virtual std::string getDescription() const = 0;
105 * Get the name of the author or vendor of the plugin in
106 * human-readable form. This should be a short identifying text,
107 * as it may be used to label plugins from the same source in a
110 virtual std::string getMaker() const = 0;
113 * Get the copyright statement or licensing summary for the
114 * plugin. This can be an informative text, without the same
115 * presentation constraints as mentioned for getMaker above.
117 virtual std::string getCopyright() const = 0;
120 * Get the version number of the plugin.
122 virtual int getPluginVersion() const = 0;
125 struct ParameterDescriptor
128 * The name of the parameter, in computer-usable form. Should
129 * be reasonably short, and may only contain the characters
132 std::string identifier;
135 * The human-readable name of the parameter.
140 * A human-readable short text describing the parameter. May be
141 * empty if the name has said it all already.
143 std::string description;
146 * The unit of the parameter, in human-readable form.
151 * The minimum value of the parameter.
156 * The maximum value of the parameter.
161 * The default value of the parameter. The plugin should
162 * ensure that parameters have this value on initialisation
163 * (i.e. the host is not required to explicitly set parameters
164 * if it wants to use their default values).
169 * True if the parameter values are quantized to a particular
175 * Quantization resolution of the parameter values (e.g. 1.0
176 * if they are all integers). Undefined if isQuantized is
182 * Names for the quantized values. If isQuantized is true,
183 * this may either be empty or contain one string for each of
184 * the quantize steps from minValue up to maxValue inclusive.
185 * Undefined if isQuantized is false.
187 * If these names are provided, they should be shown to the
188 * user in preference to the values themselves. The user may
189 * never see the actual numeric values unless they are also
190 * encoded in the names.
192 std::vector<std::string> valueNames;
195 typedef std::vector<ParameterDescriptor> ParameterList;
198 * Get the controllable parameters of this plugin.
200 virtual ParameterList getParameterDescriptors() const {
201 return ParameterList();
205 * Get the value of a named parameter. The argument is the identifier
206 * field from that parameter's descriptor.
208 virtual float getParameter(std::string) const { return 0.0; }
211 * Set a named parameter. The first argument is the identifier field
212 * from that parameter's descriptor.
214 virtual void setParameter(std::string, float) { }
217 typedef std::vector<std::string> ProgramList;
220 * Get the program settings available in this plugin. A program
221 * is a named shorthand for a set of parameter values; changing
222 * the program may cause the plugin to alter the values of its
223 * published parameters (and/or non-public internal processing
224 * parameters). The host should re-read the plugin's parameter
225 * values after setting a new program.
227 * The programs must have unique names.
229 virtual ProgramList getPrograms() const { return ProgramList(); }
232 * Get the current program.
234 virtual std::string getCurrentProgram() const { return ""; }
237 * Select a program. (If the given program name is not one of the
238 * available programs, do nothing.)
240 virtual void selectProgram(std::string) { }
243 * Get the type of plugin. This is to be implemented by the
244 * immediate subclass, not by actual plugins. Do not attempt to
245 * implement this in plugin code.
247 virtual std::string getType() const = 0;