annotate osx/include/vamp-sdk/PluginBase.h @ 112:1e14aae10620

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