annotate osx/include/vamp-sdk/PluginBase.h @ 36:55ece8862b6d

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