annotate src/vamp-plugin-sdk-2.5/vamp-sdk/PluginBase.h @ 169:223a55898ab9 tip default

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