comparison plugin/FeatureExtractionPlugin.h @ 50:080ad875395a

* Pull out parameter/description query methods from FeatureExtractionPlugin into new PluginInstance base class
author Chris Cannam
date Mon, 20 Mar 2006 12:04:06 +0000
parents 39ae3dee27b9
children d397ea0a79f5
comparison
equal deleted inserted replaced
49:39ae3dee27b9 50:080ad875395a
8 */ 8 */
9 9
10 #ifndef _FEATURE_EXTRACTION_PLUGIN_H_ 10 #ifndef _FEATURE_EXTRACTION_PLUGIN_H_
11 #define _FEATURE_EXTRACTION_PLUGIN_H_ 11 #define _FEATURE_EXTRACTION_PLUGIN_H_
12 12
13 /** 13 #include "PluginInstance.h"
14 * A base class for feature extraction plugins.
15 */
16 14
17 #include <string> 15 #include <string>
18 #include <vector> 16 #include <vector>
19 #include <map> 17 #include <map>
20 18
25 * that provide feature extraction from audio or related data. 23 * that provide feature extraction from audio or related data.
26 * 24 *
27 * In most cases, the input will be audio and the output will be a 25 * In most cases, the input will be audio and the output will be a
28 * stream of derived data at a lower sampling resolution than the 26 * stream of derived data at a lower sampling resolution than the
29 * input. 27 * input.
28 *
29 * Note that this class inherits several abstract methods from
30 * PluginInstance, that must be implemented by the subclass.
30 */ 31 */
31 32
32 class FeatureExtractionPlugin 33 class FeatureExtractionPlugin : public PluginInstance
33 { 34 {
34 public: 35 public:
35 /** 36 /**
36 * Initialise a plugin to prepare it for use with the given number 37 * Initialise a plugin to prepare it for use with the given number
37 * of input channels, step size (window increment, in sample 38 * of input channels, step size (window increment, in sample
54 * must also do a reset). 55 * must also do a reset).
55 */ 56 */
56 virtual void reset() = 0; 57 virtual void reset() = 0;
57 58
58 /** 59 /**
59 * Get the computer-usable name of the plugin. This should be
60 * reasonably short and contain no whitespace or punctuation
61 * characters.
62 */
63 virtual std::string getName() const = 0;
64
65 /**
66 * Get a human-readable description of the plugin. This should be
67 * self-contained, as it may be shown to the user in isolation
68 * without also showing the plugin's "name".
69 */
70 virtual std::string getDescription() const = 0;
71
72 /**
73 * Get the name of the author or vendor of the plugin in
74 * human-readable form.
75 */
76 virtual std::string getMaker() const = 0;
77
78 /**
79 * Get the version number of the plugin.
80 */
81 virtual int getPluginVersion() const = 0;
82
83 /**
84 * Get the copyright statement or licensing summary of the plugin.
85 */
86 virtual std::string getCopyright() const = 0;
87
88 /**
89 * Get the preferred step size (window increment -- the distance 60 * Get the preferred step size (window increment -- the distance
90 * in sample frames between the start frames of consecutive blocks 61 * in sample frames between the start frames of consecutive blocks
91 * passed to the process() function) for the plugin. This should 62 * passed to the process() function) for the plugin. This should
92 * be called before initialise(). 63 * be called before initialise().
93 */ 64 */
107 78
108 /** 79 /**
109 * Get the maximum supported number of input channels. 80 * Get the maximum supported number of input channels.
110 */ 81 */
111 virtual size_t getMaxChannelCount() const { return 1; } 82 virtual size_t getMaxChannelCount() const { return 1; }
112
113 83
114 struct OutputDescriptor 84 struct OutputDescriptor
115 { 85 {
116 /** 86 /**
117 * The name of the output, in computer-usable form. Should be 87 * The name of the output, in computer-usable form. Should be
222 * Get the outputs of this plugin. An output's index in this list 192 * Get the outputs of this plugin. An output's index in this list
223 * is used as its numeric index when looking it up in the 193 * is used as its numeric index when looking it up in the
224 * FeatureSet returned from the process() call. 194 * FeatureSet returned from the process() call.
225 */ 195 */
226 virtual OutputList getOutputDescriptors() const = 0; 196 virtual OutputList getOutputDescriptors() const = 0;
227
228
229 struct ParameterDescriptor
230 {
231 /**
232 * The name of the parameter, in computer-usable form. Should
233 * be reasonably short and without whitespace or punctuation.
234 */
235 std::string name;
236
237 /**
238 * The human-readable name of the parameter.
239 */
240 std::string description;
241
242 /**
243 * The unit of the parameter, in human-readable form.
244 */
245 std::string unit;
246
247 /**
248 * The minimum value of the parameter.
249 */
250 float minValue;
251
252 /**
253 * The maximum value of the parameter.
254 */
255 float maxValue;
256
257 /**
258 * The default value of the parameter.
259 */
260 float defaultValue;
261
262 /**
263 * True if the parameter values are quantized to a particular
264 * resolution.
265 */
266 bool isQuantized;
267
268 /**
269 * Quantization resolution of the parameter values (e.g. 1.0
270 * if they are all integers). Undefined if isQuantized is
271 * false.
272 */
273 float quantizeStep;
274 };
275
276 typedef std::vector<ParameterDescriptor> ParameterList;
277
278 /**
279 * Get the controllable parameters of this plugin.
280 */
281 virtual ParameterList getParameterDescriptors() const {
282 return ParameterList();
283 }
284
285 /**
286 * Get the value of a named parameter. The argument is the name
287 * field from that parameter's descriptor.
288 */
289 virtual float getParameter(std::string) const { return 0.0; }
290
291 /**
292 * Set a named parameter. The first argument is the name field
293 * from that parameter's descriptor.
294 */
295 virtual void setParameter(std::string, float) { }
296 197
297 struct Feature 198 struct Feature
298 { 199 {
299 /** 200 /**
300 * True if an output feature has its own timestamp. This is 201 * True if an output feature has its own timestamp. This is