annotate win32-mingw/include/vamp-sdk/PluginBase.h @ 30:553a5f65ef64

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