annotate osx/include/vamp-sdk/PluginBase.h @ 32:0b732c03ec57

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