1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6 An API for audio analysis and feature extraction plugins.
8 Centre for Digital Music, Queen Mary, University of London.
9 Copyright 2006 Chris Cannam.
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:
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
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.
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
37 #ifndef VAMP_HEADER_INCLUDED
38 #define VAMP_HEADER_INCLUDED
45 * Plugin API version. This is incremented when a change is made that
46 * changes the binary layout of the descriptor records. When this
47 * happens, there should be a mechanism for retaining compatibility
48 * with older hosts and/or plugins.
50 * See also the vampApiVersion field in the plugin descriptor, and the
51 * hostApiVersion argument to the vampGetPluginDescriptor function.
53 #define VAMP_API_VERSION 2
56 * C language API for Vamp plugins.
58 * This is the formal plugin API for Vamp. Plugin authors may prefer
59 * to use the C++ classes provided in the Vamp plugin SDK, instead of
60 * using this API directly. There is an adapter class provided that
61 * makes C++ plugins available using this C API with relatively little
62 * work, and the C++ headers are more thoroughly documented.
64 * IMPORTANT: The comments in this file summarise the purpose of each
65 * of the declared fields and functions, but do not provide a complete
66 * guide to their permitted values and expected usage. Please refer
67 * to the C++ headers in the Vamp plugin SDK for further details and
68 * plugin lifecycle documentation.
71 typedef struct _VampParameterDescriptor
73 /** Computer-usable name of the parameter. Must not change. [a-zA-Z0-9_] */
74 const char *identifier
;
76 /** Human-readable name of the parameter. May be translatable. */
79 /** Human-readable short text about the parameter. May be translatable. */
80 const char *description
;
82 /** Human-readable unit of the parameter. */
91 /** Default value. Plugin is responsible for setting this on initialise. */
94 /** 1 if parameter values are quantized to a particular resolution. */
97 /** Quantization resolution, if isQuantized. */
100 /** Human-readable names of the values, if isQuantized. May be NULL. */
101 const char **valueNames
;
103 } VampParameterDescriptor
;
107 /** Each process call returns results aligned with call's block start. */
108 vampOneSamplePerStep
,
110 /** Returned results are evenly spaced at samplerate specified below. */
113 /** Returned results have their own individual timestamps. */
114 vampVariableSampleRate
118 typedef struct _VampOutputDescriptor
120 /** Computer-usable name of the output. Must not change. [a-zA-Z0-9_] */
121 const char *identifier
;
123 /** Human-readable name of the output. May be translatable. */
126 /** Human-readable short text about the output. May be translatable. */
127 const char *description
;
129 /** Human-readable name of the unit of the output. */
132 /** 1 if output has equal number of values for each returned result. */
133 int hasFixedBinCount
;
135 /** Number of values per result, if hasFixedBinCount. */
136 unsigned int binCount
;
138 /** Names of returned value bins, if hasFixedBinCount. May be NULL. */
139 const char **binNames
;
141 /** 1 if each returned value falls within the same fixed min/max range. */
144 /** Minimum value for a returned result in any bin, if hasKnownExtents. */
147 /** Maximum value for a returned result in any bin, if hasKnownExtents. */
150 /** 1 if returned results are quantized to a particular resolution. */
153 /** Quantization resolution for returned results, if isQuantized. */
156 /** Time positioning method for returned results (see VampSampleType). */
157 VampSampleType sampleType
;
159 /** Sample rate of returned results, if sampleType is vampFixedSampleRate.
160 "Resolution" of result, if sampleType is vampVariableSampleRate. */
163 /** 1 if the returned results for this output are known to have a
166 This field is new in Vamp API version 2; it must not be tested
167 for plugins that report an older API version in their plugin
172 } VampOutputDescriptor
;
174 typedef struct _VampFeature
176 /** 1 if the feature has a timestamp (i.e. if vampVariableSampleRate). */
179 /** Seconds component of timestamp. */
182 /** Nanoseconds component of timestamp. */
185 /** Number of values. Must be binCount if hasFixedBinCount. */
186 unsigned int valueCount
;
188 /** Values for this returned sample. */
191 /** Label for this returned sample. May be NULL. */
196 typedef struct _VampFeatureV2
198 /** 1 if the feature has a duration. */
201 /** Seconds component of duratiion. */
204 /** Nanoseconds component of duration. */
209 typedef union _VampFeatureUnion
211 // sizeof(featureV1) >= sizeof(featureV2) for backward compatibility
217 typedef struct _VampFeatureList
219 /** Number of features in this feature list. */
220 unsigned int featureCount
;
222 /** Features in this feature list. May be NULL if featureCount is
225 If present, this array must contain featureCount feature
226 structures for a Vamp API version 1 plugin, or 2*featureCount
227 feature unions for a Vamp API version 2 plugin.
229 The features returned by an API version 2 plugin must consist
230 of the same feature structures as in API version 1 for the
231 first featureCount array elements, followed by featureCount
232 unions that contain VampFeatureV2 structures (or NULL pointers
233 if no V2 feature structures are present).
235 VampFeatureUnion
*features
;
246 typedef void *VampPluginHandle
;
248 typedef struct _VampPluginDescriptor
250 /** API version with which this descriptor is compatible. */
251 unsigned int vampApiVersion
;
253 /** Computer-usable name of the plugin. Must not change. [a-zA-Z0-9_] */
254 const char *identifier
;
256 /** Human-readable name of the plugin. May be translatable. */
259 /** Human-readable short text about the plugin. May be translatable. */
260 const char *description
;
262 /** Human-readable name of plugin's author or vendor. */
265 /** Version number of the plugin. */
268 /** Human-readable summary of copyright or licensing for plugin. */
269 const char *copyright
;
271 /** Number of parameter inputs. */
272 unsigned int parameterCount
;
274 /** Fixed descriptors for parameter inputs. */
275 const VampParameterDescriptor
**parameters
;
277 /** Number of programs. */
278 unsigned int programCount
;
280 /** Fixed names for programs. */
281 const char **programs
;
283 /** Preferred input domain for audio input (time or frequency). */
284 VampInputDomain inputDomain
;
286 /** Create and return a new instance of this plugin. */
287 VampPluginHandle (*instantiate
)(const struct _VampPluginDescriptor
*,
288 float inputSampleRate
);
290 /** Destroy an instance of this plugin. */
291 void (*cleanup
)(VampPluginHandle
);
293 /** Initialise an instance following parameter configuration. */
294 int (*initialise
)(VampPluginHandle
,
295 unsigned int inputChannels
,
296 unsigned int stepSize
,
297 unsigned int blockSize
);
299 /** Reset an instance, ready to use again on new input data. */
300 void (*reset
)(VampPluginHandle
);
302 /** Get a parameter value. */
303 float (*getParameter
)(VampPluginHandle
, int);
305 /** Set a parameter value. May only be called before initialise. */
306 void (*setParameter
)(VampPluginHandle
, int, float);
308 /** Get the current program (if programCount > 0). */
309 unsigned int (*getCurrentProgram
)(VampPluginHandle
);
311 /** Set the current program. May only be called before initialise. */
312 void (*selectProgram
)(VampPluginHandle
, unsigned int);
314 /** Get the plugin's preferred processing window increment in samples. */
315 unsigned int (*getPreferredStepSize
)(VampPluginHandle
);
317 /** Get the plugin's preferred processing window size in samples. */
318 unsigned int (*getPreferredBlockSize
)(VampPluginHandle
);
320 /** Get the minimum number of input channels this plugin can handle. */
321 unsigned int (*getMinChannelCount
)(VampPluginHandle
);
323 /** Get the maximum number of input channels this plugin can handle. */
324 unsigned int (*getMaxChannelCount
)(VampPluginHandle
);
326 /** Get the number of feature outputs (distinct sets of results). */
327 unsigned int (*getOutputCount
)(VampPluginHandle
);
329 /** Get a descriptor for a given feature output. Returned pointer
330 is valid only until next call to getOutputDescriptor for this
331 handle, or releaseOutputDescriptor for this descriptor. Host
332 must call releaseOutputDescriptor after use. */
333 VampOutputDescriptor
*(*getOutputDescriptor
)(VampPluginHandle
,
336 /** Destroy a descriptor for a feature output. */
337 void (*releaseOutputDescriptor
)(VampOutputDescriptor
*);
339 /** Process an input block and return a set of features. Returned
340 pointer is valid only until next call to process,
341 getRemainingFeatures, or cleanup for this handle, or
342 releaseFeatureSet for this feature set. Host must call
343 releaseFeatureSet after use. */
344 VampFeatureList
*(*process
)(VampPluginHandle
,
345 const float *const *inputBuffers
,
349 /** Return any remaining features at the end of processing. */
350 VampFeatureList
*(*getRemainingFeatures
)(VampPluginHandle
);
352 /** Release a feature set returned from process or getRemainingFeatures. */
353 void (*releaseFeatureSet
)(VampFeatureList
*);
355 } VampPluginDescriptor
;
358 /** Get the descriptor for a given plugin index in this library.
359 Return NULL if the index is outside the range of valid indices for
362 The hostApiVersion argument tells the library code the highest
363 Vamp API version supported by the host. The function should
364 return a plugin descriptor compatible with the highest API version
365 supported by the library that is no higher than that supported by
366 the host. Provided the descriptor has the correct vampApiVersion
367 field for its actual compatibility level, the host should be able
368 to do the right thing with it: use it if possible, discard it
371 This is the only symbol that a Vamp plugin actually needs to
372 export from its shared object; all others can be hidden. See the
373 accompanying documentation for notes on how to achieve this with
376 const VampPluginDescriptor
*vampGetPluginDescriptor
377 (unsigned int hostApiVersion
, unsigned int index
);
380 /** Function pointer type for vampGetPluginDescriptor. */
381 typedef const VampPluginDescriptor
*(*VampGetPluginDescriptorFunction
)
382 (unsigned int, unsigned int);