annotate src/vamp-plugin-sdk-2.4/vamp-sdk/PluginBase.h @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
parents b7bda433d832
children
rev   line source
Chris@12 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@12 2
Chris@12 3 /*
Chris@12 4 Vamp
Chris@12 5
Chris@12 6 An API for audio analysis and feature extraction plugins.
Chris@12 7
Chris@12 8 Centre for Digital Music, Queen Mary, University of London.
Chris@12 9 Copyright 2006 Chris Cannam.
Chris@12 10
Chris@12 11 Permission is hereby granted, free of charge, to any person
Chris@12 12 obtaining a copy of this software and associated documentation
Chris@12 13 files (the "Software"), to deal in the Software without
Chris@12 14 restriction, including without limitation the rights to use, copy,
Chris@12 15 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@12 16 of the Software, and to permit persons to whom the Software is
Chris@12 17 furnished to do so, subject to the following conditions:
Chris@12 18
Chris@12 19 The above copyright notice and this permission notice shall be
Chris@12 20 included in all copies or substantial portions of the Software.
Chris@12 21
Chris@12 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@12 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@12 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@12 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@12 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@12 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@12 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@12 29
Chris@12 30 Except as contained in this notice, the names of the Centre for
Chris@12 31 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@12 32 shall not be used in advertising or otherwise to promote the sale,
Chris@12 33 use or other dealings in this Software without prior written
Chris@12 34 authorization.
Chris@12 35 */
Chris@12 36
Chris@12 37 #ifndef _VAMP_SDK_PLUGIN_BASE_H_
Chris@12 38 #define _VAMP_SDK_PLUGIN_BASE_H_
Chris@12 39
Chris@12 40 #include <string>
Chris@12 41 #include <vector>
Chris@12 42
Chris@12 43 #include "plugguard.h"
Chris@12 44 _VAMP_SDK_PLUGSPACE_BEGIN(PluginBase.h)
Chris@12 45
Chris@12 46 namespace Vamp {
Chris@12 47
Chris@12 48 /**
Chris@12 49 * A base class for plugins with optional configurable parameters,
Chris@12 50 * programs, etc. The Vamp::Plugin is derived from this, and
Chris@12 51 * individual Vamp plugins should derive from that.
Chris@12 52 *
Chris@12 53 * This class does not provide the necessary interfaces to instantiate
Chris@12 54 * or run a plugin. It only specifies an interface for retrieving
Chris@12 55 * those controls that the host may wish to show to the user for
Chris@12 56 * editing. It could meaningfully be subclassed by real-time plugins
Chris@12 57 * or other sorts of plugin as well as Vamp plugins.
Chris@12 58 */
Chris@12 59
Chris@12 60 class PluginBase
Chris@12 61 {
Chris@12 62 public:
Chris@12 63 virtual ~PluginBase() { }
Chris@12 64
Chris@12 65 /**
Chris@12 66 * Get the Vamp API compatibility level of the plugin.
Chris@12 67 */
Chris@12 68 virtual unsigned int getVampApiVersion() const { return 2; }
Chris@12 69
Chris@12 70 /**
Chris@12 71 * Get the computer-usable name of the plugin. This should be
Chris@12 72 * reasonably short and contain no whitespace or punctuation
Chris@12 73 * characters. It may only contain the characters [a-zA-Z0-9_-].
Chris@12 74 * This is the authoritative way for a program to identify a
Chris@12 75 * plugin within a given library.
Chris@12 76 *
Chris@12 77 * This text may be visible to the user, but it should not be the
Chris@12 78 * main text used to identify a plugin to the user (that will be
Chris@12 79 * the name, below).
Chris@12 80 *
Chris@12 81 * Example: "zero_crossings"
Chris@12 82 */
Chris@12 83 virtual std::string getIdentifier() const = 0;
Chris@12 84
Chris@12 85 /**
Chris@12 86 * Get a human-readable name or title of the plugin. This
Chris@12 87 * should be brief and self-contained, as it may be used to
Chris@12 88 * identify the plugin to the user in isolation (i.e. without also
Chris@12 89 * showing the plugin's "identifier").
Chris@12 90 *
Chris@12 91 * Example: "Zero Crossings"
Chris@12 92 */
Chris@12 93 virtual std::string getName() const = 0;
Chris@12 94
Chris@12 95 /**
Chris@12 96 * Get a human-readable description for the plugin, typically
Chris@12 97 * a line of text that may optionally be displayed in addition
Chris@12 98 * to the plugin's "name". May be empty if the name has said
Chris@12 99 * it all already.
Chris@12 100 *
Chris@12 101 * Example: "Detect and count zero crossing points"
Chris@12 102 */
Chris@12 103 virtual std::string getDescription() const = 0;
Chris@12 104
Chris@12 105 /**
Chris@12 106 * Get the name of the author or vendor of the plugin in
Chris@12 107 * human-readable form. This should be a short identifying text,
Chris@12 108 * as it may be used to label plugins from the same source in a
Chris@12 109 * menu or similar.
Chris@12 110 */
Chris@12 111 virtual std::string getMaker() const = 0;
Chris@12 112
Chris@12 113 /**
Chris@12 114 * Get the copyright statement or licensing summary for the
Chris@12 115 * plugin. This can be an informative text, without the same
Chris@12 116 * presentation constraints as mentioned for getMaker above.
Chris@12 117 */
Chris@12 118 virtual std::string getCopyright() const = 0;
Chris@12 119
Chris@12 120 /**
Chris@12 121 * Get the version number of the plugin.
Chris@12 122 */
Chris@12 123 virtual int getPluginVersion() const = 0;
Chris@12 124
Chris@12 125
Chris@12 126 struct ParameterDescriptor
Chris@12 127 {
Chris@12 128 /**
Chris@12 129 * The name of the parameter, in computer-usable form. Should
Chris@12 130 * be reasonably short, and may only contain the characters
Chris@12 131 * [a-zA-Z0-9_-].
Chris@12 132 */
Chris@12 133 std::string identifier;
Chris@12 134
Chris@12 135 /**
Chris@12 136 * The human-readable name of the parameter.
Chris@12 137 */
Chris@12 138 std::string name;
Chris@12 139
Chris@12 140 /**
Chris@12 141 * A human-readable short text describing the parameter. May be
Chris@12 142 * empty if the name has said it all already.
Chris@12 143 */
Chris@12 144 std::string description;
Chris@12 145
Chris@12 146 /**
Chris@12 147 * The unit of the parameter, in human-readable form.
Chris@12 148 */
Chris@12 149 std::string unit;
Chris@12 150
Chris@12 151 /**
Chris@12 152 * The minimum value of the parameter.
Chris@12 153 */
Chris@12 154 float minValue;
Chris@12 155
Chris@12 156 /**
Chris@12 157 * The maximum value of the parameter.
Chris@12 158 */
Chris@12 159 float maxValue;
Chris@12 160
Chris@12 161 /**
Chris@12 162 * The default value of the parameter. The plugin should
Chris@12 163 * ensure that parameters have this value on initialisation
Chris@12 164 * (i.e. the host is not required to explicitly set parameters
Chris@12 165 * if it wants to use their default values).
Chris@12 166 */
Chris@12 167 float defaultValue;
Chris@12 168
Chris@12 169 /**
Chris@12 170 * True if the parameter values are quantized to a particular
Chris@12 171 * resolution.
Chris@12 172 */
Chris@12 173 bool isQuantized;
Chris@12 174
Chris@12 175 /**
Chris@12 176 * Quantization resolution of the parameter values (e.g. 1.0
Chris@12 177 * if they are all integers). Undefined if isQuantized is
Chris@12 178 * false.
Chris@12 179 */
Chris@12 180 float quantizeStep;
Chris@12 181
Chris@12 182 /**
Chris@12 183 * Names for the quantized values. If isQuantized is true,
Chris@12 184 * this may either be empty or contain one string for each of
Chris@12 185 * the quantize steps from minValue up to maxValue inclusive.
Chris@12 186 * Undefined if isQuantized is false.
Chris@12 187 *
Chris@12 188 * If these names are provided, they should be shown to the
Chris@12 189 * user in preference to the values themselves. The user may
Chris@12 190 * never see the actual numeric values unless they are also
Chris@12 191 * encoded in the names.
Chris@12 192 */
Chris@12 193 std::vector<std::string> valueNames;
Chris@12 194
Chris@12 195 ParameterDescriptor() : // the defaults are invalid: you must set them
Chris@12 196 minValue(0), maxValue(0), defaultValue(0), isQuantized(false) { }
Chris@12 197 };
Chris@12 198
Chris@12 199 typedef std::vector<ParameterDescriptor> ParameterList;
Chris@12 200
Chris@12 201 /**
Chris@12 202 * Get the controllable parameters of this plugin.
Chris@12 203 */
Chris@12 204 virtual ParameterList getParameterDescriptors() const {
Chris@12 205 return ParameterList();
Chris@12 206 }
Chris@12 207
Chris@12 208 /**
Chris@12 209 * Get the value of a named parameter. The argument is the identifier
Chris@12 210 * field from that parameter's descriptor.
Chris@12 211 */
Chris@12 212 virtual float getParameter(std::string) const { return 0.0; }
Chris@12 213
Chris@12 214 /**
Chris@12 215 * Set a named parameter. The first argument is the identifier field
Chris@12 216 * from that parameter's descriptor.
Chris@12 217 */
Chris@12 218 virtual void setParameter(std::string, float) { }
Chris@12 219
Chris@12 220
Chris@12 221 typedef std::vector<std::string> ProgramList;
Chris@12 222
Chris@12 223 /**
Chris@12 224 * Get the program settings available in this plugin. A program
Chris@12 225 * is a named shorthand for a set of parameter values; changing
Chris@12 226 * the program may cause the plugin to alter the values of its
Chris@12 227 * published parameters (and/or non-public internal processing
Chris@12 228 * parameters). The host should re-read the plugin's parameter
Chris@12 229 * values after setting a new program.
Chris@12 230 *
Chris@12 231 * The programs must have unique names.
Chris@12 232 */
Chris@12 233 virtual ProgramList getPrograms() const { return ProgramList(); }
Chris@12 234
Chris@12 235 /**
Chris@12 236 * Get the current program.
Chris@12 237 */
Chris@12 238 virtual std::string getCurrentProgram() const { return ""; }
Chris@12 239
Chris@12 240 /**
Chris@12 241 * Select a program. (If the given program name is not one of the
Chris@12 242 * available programs, do nothing.)
Chris@12 243 */
Chris@12 244 virtual void selectProgram(std::string) { }
Chris@12 245
Chris@12 246 /**
Chris@12 247 * Get the type of plugin. This is to be implemented by the
Chris@12 248 * immediate subclass, not by actual plugins. Do not attempt to
Chris@12 249 * implement this in plugin code.
Chris@12 250 */
Chris@12 251 virtual std::string getType() const = 0;
Chris@12 252 };
Chris@12 253
Chris@12 254 }
Chris@12 255
Chris@12 256 _VAMP_SDK_PLUGSPACE_END(PluginBase.h)
Chris@12 257
Chris@12 258 #endif