comparison win32-mingw/include/vamp-sdk/PluginBase.h @ 99:c6e1ae789cfb

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