annotate vamp-sdk/PluginBase.h @ 21:16eeab18bf72

* tidy * build to vamp-example-plugins.so
author cannam
date Fri, 14 Apr 2006 09:37:46 +0000
parents 68b8b32a2070
children e252b1ab423f
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@2 4 Vamp
cannam@2 5
cannam@2 6 An API for audio analysis and feature extraction plugins.
cannam@2 7
cannam@0 8 Centre for Digital Music, Queen Mary, University of London.
cannam@2 9 Copyright 2006 Chris Cannam.
cannam@2 10
cannam@2 11 Permission is hereby granted, free of charge, to any person
cannam@2 12 obtaining a copy of this software and associated documentation
cannam@2 13 files (the "Software"), to deal in the Software without
cannam@2 14 restriction, including without limitation the rights to use, copy,
cannam@2 15 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@2 16 of the Software, and to permit persons to whom the Software is
cannam@2 17 furnished to do so, subject to the following conditions:
cannam@2 18
cannam@2 19 The above copyright notice and this permission notice shall be
cannam@2 20 included in all copies or substantial portions of the Software.
cannam@2 21
cannam@2 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@2 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@2 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@6 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@2 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@2 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@2 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@2 29
cannam@2 30 Except as contained in this notice, the names of the Centre for
cannam@2 31 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@2 32 shall not be used in advertising or otherwise to promote the sale,
cannam@2 33 use or other dealings in this Software without prior written
cannam@2 34 authorization.
cannam@0 35 */
cannam@0 36
cannam@0 37 #ifndef _VAMP_PLUGIN_BASE_H_
cannam@0 38 #define _VAMP_PLUGIN_BASE_H_
cannam@0 39
cannam@0 40 #include <string>
cannam@0 41 #include <vector>
cannam@0 42
cannam@0 43 namespace Vamp {
cannam@0 44
cannam@0 45 /**
cannam@0 46 * A base class for plugins with optional configurable parameters,
cannam@0 47 * programs, etc.
cannam@0 48 *
cannam@0 49 * This does not provide the necessary interfaces to instantiate or
cannam@0 50 * run a plugin -- that depends on the plugin subclass, as different
cannam@0 51 * plugin types may have quite different operating structures. This
cannam@0 52 * class just specifies the necessary interface to show editable
cannam@0 53 * controls for the plugin to the user.
cannam@0 54 */
cannam@0 55
cannam@0 56 class PluginBase
cannam@0 57 {
cannam@0 58 public:
cannam@20 59 virtual ~PluginBase() { }
cannam@20 60
cannam@0 61 /**
cannam@0 62 * Get the computer-usable name of the plugin. This should be
cannam@0 63 * reasonably short and contain no whitespace or punctuation
cannam@0 64 * characters. It may be shown to the user, but it won't be the
cannam@0 65 * main method for a user to identify a plugin (that will be the
cannam@0 66 * description, below).
cannam@0 67 */
cannam@0 68 virtual std::string getName() const = 0;
cannam@0 69
cannam@0 70 /**
cannam@0 71 * Get a human-readable description of the plugin. This should be
cannam@0 72 * self-contained, as it may be shown to the user in isolation
cannam@0 73 * without also showing the plugin's "name".
cannam@0 74 */
cannam@0 75 virtual std::string getDescription() const = 0;
cannam@0 76
cannam@0 77 /**
cannam@0 78 * Get the name of the author or vendor of the plugin in
cannam@0 79 * human-readable form.
cannam@0 80 */
cannam@0 81 virtual std::string getMaker() const = 0;
cannam@0 82
cannam@0 83 /**
cannam@0 84 * Get the version number of the plugin.
cannam@0 85 */
cannam@0 86 virtual int getPluginVersion() const = 0;
cannam@0 87
cannam@0 88 /**
cannam@0 89 * Get the copyright statement or licensing summary of the plugin.
cannam@0 90 */
cannam@0 91 virtual std::string getCopyright() const = 0;
cannam@0 92
cannam@0 93 /**
cannam@0 94 * Get the type of plugin (e.g. DSSI, etc). This is likely to be
cannam@0 95 * implemented by the immediate subclass, not by actual plugins.
cannam@0 96 */
cannam@0 97 virtual std::string getType() const = 0;
cannam@0 98
cannam@0 99
cannam@0 100 struct ParameterDescriptor
cannam@0 101 {
cannam@0 102 /**
cannam@0 103 * The name of the parameter, in computer-usable form. Should
cannam@0 104 * be reasonably short, and may only contain the characters
cannam@0 105 * [a-zA-Z0-9_].
cannam@0 106 */
cannam@0 107 std::string name;
cannam@0 108
cannam@0 109 /**
cannam@0 110 * The human-readable name of the parameter.
cannam@0 111 */
cannam@0 112 std::string description;
cannam@0 113
cannam@0 114 /**
cannam@0 115 * The unit of the parameter, in human-readable form.
cannam@0 116 */
cannam@0 117 std::string unit;
cannam@0 118
cannam@0 119 /**
cannam@0 120 * The minimum value of the parameter.
cannam@0 121 */
cannam@0 122 float minValue;
cannam@0 123
cannam@0 124 /**
cannam@0 125 * The maximum value of the parameter.
cannam@0 126 */
cannam@0 127 float maxValue;
cannam@0 128
cannam@0 129 /**
cannam@0 130 * The default value of the parameter.
cannam@0 131 */
cannam@0 132 float defaultValue;
cannam@0 133
cannam@0 134 /**
cannam@0 135 * True if the parameter values are quantized to a particular
cannam@0 136 * resolution.
cannam@0 137 */
cannam@0 138 bool isQuantized;
cannam@0 139
cannam@0 140 /**
cannam@0 141 * Quantization resolution of the parameter values (e.g. 1.0
cannam@0 142 * if they are all integers). Undefined if isQuantized is
cannam@0 143 * false.
cannam@0 144 */
cannam@0 145 float quantizeStep;
cannam@9 146
cannam@9 147 /**
cannam@9 148 * Names for the quantized values. If isQuantized is true,
cannam@9 149 * this may either be empty or contain one string for each of
cannam@9 150 * the quantize steps from minValue up to maxValue inclusive.
cannam@9 151 * Undefined if isQuantized is false.
cannam@9 152 *
cannam@9 153 * If these names are provided, they should be shown to the
cannam@9 154 * user in preference to the values themselves. The user may
cannam@9 155 * never see the actual numeric values unless they are also
cannam@9 156 * encoded in the names.
cannam@9 157 */
cannam@9 158 std::vector<std::string> valueNames;
cannam@0 159 };
cannam@0 160
cannam@0 161 typedef std::vector<ParameterDescriptor> ParameterList;
cannam@0 162
cannam@0 163 /**
cannam@0 164 * Get the controllable parameters of this plugin.
cannam@0 165 */
cannam@0 166 virtual ParameterList getParameterDescriptors() const {
cannam@0 167 return ParameterList();
cannam@0 168 }
cannam@0 169
cannam@0 170 /**
cannam@0 171 * Get the value of a named parameter. The argument is the name
cannam@0 172 * field from that parameter's descriptor.
cannam@0 173 */
cannam@0 174 virtual float getParameter(std::string) const { return 0.0; }
cannam@0 175
cannam@0 176 /**
cannam@0 177 * Set a named parameter. The first argument is the name field
cannam@0 178 * from that parameter's descriptor.
cannam@0 179 */
cannam@0 180 virtual void setParameter(std::string, float) { }
cannam@0 181
cannam@0 182
cannam@0 183 typedef std::vector<std::string> ProgramList;
cannam@0 184
cannam@0 185 /**
cannam@0 186 * Get the program settings available in this plugin.
cannam@0 187 * The programs must have unique names.
cannam@0 188 */
cannam@0 189 virtual ProgramList getPrograms() const { return ProgramList(); }
cannam@0 190
cannam@0 191 /**
cannam@0 192 * Get the current program.
cannam@0 193 */
cannam@0 194 virtual std::string getCurrentProgram() const { return ""; }
cannam@0 195
cannam@0 196 /**
cannam@0 197 * Select a program. (If the given program name is not one of the
cannam@0 198 * available programs, do nothing.)
cannam@0 199 */
cannam@0 200 virtual void selectProgram(std::string) { }
cannam@0 201 };
cannam@0 202
cannam@0 203 }
cannam@0 204
cannam@0 205 #endif