annotate vamp-sdk/PluginBase.h @ 246:5bfed156b45d

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