annotate src/vamp-plugin-sdk-2.5/vamp-sdk/PluginBase.h @ 83:ae30d91d2ffe

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