annotate src/vamp-plugin-sdk-2.5/vamp/vamp.h @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
parents
children
rev   line source
Chris@23 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@23 2
Chris@23 3 /*
Chris@23 4 Vamp
Chris@23 5
Chris@23 6 An API for audio analysis and feature extraction plugins.
Chris@23 7
Chris@23 8 Centre for Digital Music, Queen Mary, University of London.
Chris@23 9 Copyright 2006 Chris Cannam.
Chris@23 10
Chris@23 11 Permission is hereby granted, free of charge, to any person
Chris@23 12 obtaining a copy of this software and associated documentation
Chris@23 13 files (the "Software"), to deal in the Software without
Chris@23 14 restriction, including without limitation the rights to use, copy,
Chris@23 15 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@23 16 of the Software, and to permit persons to whom the Software is
Chris@23 17 furnished to do so, subject to the following conditions:
Chris@23 18
Chris@23 19 The above copyright notice and this permission notice shall be
Chris@23 20 included in all copies or substantial portions of the Software.
Chris@23 21
Chris@23 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@23 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@23 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@23 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@23 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@23 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@23 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@23 29
Chris@23 30 Except as contained in this notice, the names of the Centre for
Chris@23 31 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@23 32 shall not be used in advertising or otherwise to promote the sale,
Chris@23 33 use or other dealings in this Software without prior written
Chris@23 34 authorization.
Chris@23 35 */
Chris@23 36
Chris@23 37 #ifndef VAMP_HEADER_INCLUDED
Chris@23 38 #define VAMP_HEADER_INCLUDED
Chris@23 39
Chris@23 40 #ifdef __cplusplus
Chris@23 41 extern "C" {
Chris@23 42 #endif
Chris@23 43
Chris@23 44 /**
Chris@23 45 * Plugin API version. This is incremented when a change is made that
Chris@23 46 * changes the binary layout of the descriptor records. When this
Chris@23 47 * happens, there should be a mechanism for retaining compatibility
Chris@23 48 * with older hosts and/or plugins.
Chris@23 49 *
Chris@23 50 * See also the vampApiVersion field in the plugin descriptor, and the
Chris@23 51 * hostApiVersion argument to the vampGetPluginDescriptor function.
Chris@23 52 */
Chris@23 53 #define VAMP_API_VERSION 2
Chris@23 54
Chris@23 55 /**
Chris@23 56 * C language API for Vamp plugins.
Chris@23 57 *
Chris@23 58 * This is the formal plugin API for Vamp. Plugin authors may prefer
Chris@23 59 * to use the C++ classes provided in the Vamp plugin SDK, instead of
Chris@23 60 * using this API directly. There is an adapter class provided that
Chris@23 61 * makes C++ plugins available using this C API with relatively little
Chris@23 62 * work, and the C++ headers are more thoroughly documented.
Chris@23 63 *
Chris@23 64 * IMPORTANT: The comments in this file summarise the purpose of each
Chris@23 65 * of the declared fields and functions, but do not provide a complete
Chris@23 66 * guide to their permitted values and expected usage. Please refer
Chris@23 67 * to the C++ headers in the Vamp plugin SDK for further details and
Chris@23 68 * plugin lifecycle documentation.
Chris@23 69 */
Chris@23 70
Chris@23 71 typedef struct _VampParameterDescriptor
Chris@23 72 {
Chris@23 73 /** Computer-usable name of the parameter. Must not change. [a-zA-Z0-9_] */
Chris@23 74 const char *identifier;
Chris@23 75
Chris@23 76 /** Human-readable name of the parameter. May be translatable. */
Chris@23 77 const char *name;
Chris@23 78
Chris@23 79 /** Human-readable short text about the parameter. May be translatable. */
Chris@23 80 const char *description;
Chris@23 81
Chris@23 82 /** Human-readable unit of the parameter. */
Chris@23 83 const char *unit;
Chris@23 84
Chris@23 85 /** Minimum value. */
Chris@23 86 float minValue;
Chris@23 87
Chris@23 88 /** Maximum value. */
Chris@23 89 float maxValue;
Chris@23 90
Chris@23 91 /** Default value. Plugin is responsible for setting this on initialise. */
Chris@23 92 float defaultValue;
Chris@23 93
Chris@23 94 /** 1 if parameter values are quantized to a particular resolution. */
Chris@23 95 int isQuantized;
Chris@23 96
Chris@23 97 /** Quantization resolution, if isQuantized. */
Chris@23 98 float quantizeStep;
Chris@23 99
Chris@23 100 /** Human-readable names of the values, if isQuantized. May be NULL. */
Chris@23 101 const char **valueNames;
Chris@23 102
Chris@23 103 } VampParameterDescriptor;
Chris@23 104
Chris@23 105 typedef enum
Chris@23 106 {
Chris@23 107 /** Each process call returns results aligned with call's block start. */
Chris@23 108 vampOneSamplePerStep,
Chris@23 109
Chris@23 110 /** Returned results are evenly spaced at samplerate specified below. */
Chris@23 111 vampFixedSampleRate,
Chris@23 112
Chris@23 113 /** Returned results have their own individual timestamps. */
Chris@23 114 vampVariableSampleRate
Chris@23 115
Chris@23 116 } VampSampleType;
Chris@23 117
Chris@23 118 typedef struct _VampOutputDescriptor
Chris@23 119 {
Chris@23 120 /** Computer-usable name of the output. Must not change. [a-zA-Z0-9_] */
Chris@23 121 const char *identifier;
Chris@23 122
Chris@23 123 /** Human-readable name of the output. May be translatable. */
Chris@23 124 const char *name;
Chris@23 125
Chris@23 126 /** Human-readable short text about the output. May be translatable. */
Chris@23 127 const char *description;
Chris@23 128
Chris@23 129 /** Human-readable name of the unit of the output. */
Chris@23 130 const char *unit;
Chris@23 131
Chris@23 132 /** 1 if output has equal number of values for each returned result. */
Chris@23 133 int hasFixedBinCount;
Chris@23 134
Chris@23 135 /** Number of values per result, if hasFixedBinCount. */
Chris@23 136 unsigned int binCount;
Chris@23 137
Chris@23 138 /** Names of returned value bins, if hasFixedBinCount. May be NULL. */
Chris@23 139 const char **binNames;
Chris@23 140
Chris@23 141 /** 1 if each returned value falls within the same fixed min/max range. */
Chris@23 142 int hasKnownExtents;
Chris@23 143
Chris@23 144 /** Minimum value for a returned result in any bin, if hasKnownExtents. */
Chris@23 145 float minValue;
Chris@23 146
Chris@23 147 /** Maximum value for a returned result in any bin, if hasKnownExtents. */
Chris@23 148 float maxValue;
Chris@23 149
Chris@23 150 /** 1 if returned results are quantized to a particular resolution. */
Chris@23 151 int isQuantized;
Chris@23 152
Chris@23 153 /** Quantization resolution for returned results, if isQuantized. */
Chris@23 154 float quantizeStep;
Chris@23 155
Chris@23 156 /** Time positioning method for returned results (see VampSampleType). */
Chris@23 157 VampSampleType sampleType;
Chris@23 158
Chris@23 159 /** Sample rate of returned results, if sampleType is vampFixedSampleRate.
Chris@23 160 "Resolution" of result, if sampleType is vampVariableSampleRate. */
Chris@23 161 float sampleRate;
Chris@23 162
Chris@23 163 /** 1 if the returned results for this output are known to have a
Chris@23 164 duration field.
Chris@23 165
Chris@23 166 This field is new in Vamp API version 2; it must not be tested
Chris@23 167 for plugins that report an older API version in their plugin
Chris@23 168 descriptor.
Chris@23 169 */
Chris@23 170 int hasDuration;
Chris@23 171
Chris@23 172 } VampOutputDescriptor;
Chris@23 173
Chris@23 174 typedef struct _VampFeature
Chris@23 175 {
Chris@23 176 /** 1 if the feature has a timestamp (i.e. if vampVariableSampleRate). */
Chris@23 177 int hasTimestamp;
Chris@23 178
Chris@23 179 /** Seconds component of timestamp. */
Chris@23 180 int sec;
Chris@23 181
Chris@23 182 /** Nanoseconds component of timestamp. */
Chris@23 183 int nsec;
Chris@23 184
Chris@23 185 /** Number of values. Must be binCount if hasFixedBinCount. */
Chris@23 186 unsigned int valueCount;
Chris@23 187
Chris@23 188 /** Values for this returned sample. */
Chris@23 189 float *values;
Chris@23 190
Chris@23 191 /** Label for this returned sample. May be NULL. */
Chris@23 192 char *label;
Chris@23 193
Chris@23 194 } VampFeature;
Chris@23 195
Chris@23 196 typedef struct _VampFeatureV2
Chris@23 197 {
Chris@23 198 /** 1 if the feature has a duration. */
Chris@23 199 int hasDuration;
Chris@23 200
Chris@23 201 /** Seconds component of duratiion. */
Chris@23 202 int durationSec;
Chris@23 203
Chris@23 204 /** Nanoseconds component of duration. */
Chris@23 205 int durationNsec;
Chris@23 206
Chris@23 207 } VampFeatureV2;
Chris@23 208
Chris@23 209 typedef union _VampFeatureUnion
Chris@23 210 {
Chris@23 211 // sizeof(featureV1) >= sizeof(featureV2) for backward compatibility
Chris@23 212 VampFeature v1;
Chris@23 213 VampFeatureV2 v2;
Chris@23 214
Chris@23 215 } VampFeatureUnion;
Chris@23 216
Chris@23 217 typedef struct _VampFeatureList
Chris@23 218 {
Chris@23 219 /** Number of features in this feature list. */
Chris@23 220 unsigned int featureCount;
Chris@23 221
Chris@23 222 /** Features in this feature list. May be NULL if featureCount is
Chris@23 223 zero.
Chris@23 224
Chris@23 225 If present, this array must contain featureCount feature
Chris@23 226 structures for a Vamp API version 1 plugin, or 2*featureCount
Chris@23 227 feature unions for a Vamp API version 2 plugin.
Chris@23 228
Chris@23 229 The features returned by an API version 2 plugin must consist
Chris@23 230 of the same feature structures as in API version 1 for the
Chris@23 231 first featureCount array elements, followed by featureCount
Chris@23 232 unions that contain VampFeatureV2 structures (or NULL pointers
Chris@23 233 if no V2 feature structures are present).
Chris@23 234 */
Chris@23 235 VampFeatureUnion *features;
Chris@23 236
Chris@23 237 } VampFeatureList;
Chris@23 238
Chris@23 239 typedef enum
Chris@23 240 {
Chris@23 241 vampTimeDomain,
Chris@23 242 vampFrequencyDomain
Chris@23 243
Chris@23 244 } VampInputDomain;
Chris@23 245
Chris@23 246 typedef void *VampPluginHandle;
Chris@23 247
Chris@23 248 typedef struct _VampPluginDescriptor
Chris@23 249 {
Chris@23 250 /** API version with which this descriptor is compatible. */
Chris@23 251 unsigned int vampApiVersion;
Chris@23 252
Chris@23 253 /** Computer-usable name of the plugin. Must not change. [a-zA-Z0-9_] */
Chris@23 254 const char *identifier;
Chris@23 255
Chris@23 256 /** Human-readable name of the plugin. May be translatable. */
Chris@23 257 const char *name;
Chris@23 258
Chris@23 259 /** Human-readable short text about the plugin. May be translatable. */
Chris@23 260 const char *description;
Chris@23 261
Chris@23 262 /** Human-readable name of plugin's author or vendor. */
Chris@23 263 const char *maker;
Chris@23 264
Chris@23 265 /** Version number of the plugin. */
Chris@23 266 int pluginVersion;
Chris@23 267
Chris@23 268 /** Human-readable summary of copyright or licensing for plugin. */
Chris@23 269 const char *copyright;
Chris@23 270
Chris@23 271 /** Number of parameter inputs. */
Chris@23 272 unsigned int parameterCount;
Chris@23 273
Chris@23 274 /** Fixed descriptors for parameter inputs. */
Chris@23 275 const VampParameterDescriptor **parameters;
Chris@23 276
Chris@23 277 /** Number of programs. */
Chris@23 278 unsigned int programCount;
Chris@23 279
Chris@23 280 /** Fixed names for programs. */
Chris@23 281 const char **programs;
Chris@23 282
Chris@23 283 /** Preferred input domain for audio input (time or frequency). */
Chris@23 284 VampInputDomain inputDomain;
Chris@23 285
Chris@23 286 /** Create and return a new instance of this plugin. */
Chris@23 287 VampPluginHandle (*instantiate)(const struct _VampPluginDescriptor *,
Chris@23 288 float inputSampleRate);
Chris@23 289
Chris@23 290 /** Destroy an instance of this plugin. */
Chris@23 291 void (*cleanup)(VampPluginHandle);
Chris@23 292
Chris@23 293 /** Initialise an instance following parameter configuration. */
Chris@23 294 int (*initialise)(VampPluginHandle,
Chris@23 295 unsigned int inputChannels,
Chris@23 296 unsigned int stepSize,
Chris@23 297 unsigned int blockSize);
Chris@23 298
Chris@23 299 /** Reset an instance, ready to use again on new input data. */
Chris@23 300 void (*reset)(VampPluginHandle);
Chris@23 301
Chris@23 302 /** Get a parameter value. */
Chris@23 303 float (*getParameter)(VampPluginHandle, int);
Chris@23 304
Chris@23 305 /** Set a parameter value. May only be called before initialise. */
Chris@23 306 void (*setParameter)(VampPluginHandle, int, float);
Chris@23 307
Chris@23 308 /** Get the current program (if programCount > 0). */
Chris@23 309 unsigned int (*getCurrentProgram)(VampPluginHandle);
Chris@23 310
Chris@23 311 /** Set the current program. May only be called before initialise. */
Chris@23 312 void (*selectProgram)(VampPluginHandle, unsigned int);
Chris@23 313
Chris@23 314 /** Get the plugin's preferred processing window increment in samples. */
Chris@23 315 unsigned int (*getPreferredStepSize)(VampPluginHandle);
Chris@23 316
Chris@23 317 /** Get the plugin's preferred processing window size in samples. */
Chris@23 318 unsigned int (*getPreferredBlockSize)(VampPluginHandle);
Chris@23 319
Chris@23 320 /** Get the minimum number of input channels this plugin can handle. */
Chris@23 321 unsigned int (*getMinChannelCount)(VampPluginHandle);
Chris@23 322
Chris@23 323 /** Get the maximum number of input channels this plugin can handle. */
Chris@23 324 unsigned int (*getMaxChannelCount)(VampPluginHandle);
Chris@23 325
Chris@23 326 /** Get the number of feature outputs (distinct sets of results). */
Chris@23 327 unsigned int (*getOutputCount)(VampPluginHandle);
Chris@23 328
Chris@23 329 /** Get a descriptor for a given feature output. Returned pointer
Chris@23 330 is valid only until next call to getOutputDescriptor for this
Chris@23 331 handle, or releaseOutputDescriptor for this descriptor. Host
Chris@23 332 must call releaseOutputDescriptor after use. */
Chris@23 333 VampOutputDescriptor *(*getOutputDescriptor)(VampPluginHandle,
Chris@23 334 unsigned int);
Chris@23 335
Chris@23 336 /** Destroy a descriptor for a feature output. */
Chris@23 337 void (*releaseOutputDescriptor)(VampOutputDescriptor *);
Chris@23 338
Chris@23 339 /** Process an input block and return a set of features. Returned
Chris@23 340 pointer is valid only until next call to process,
Chris@23 341 getRemainingFeatures, or cleanup for this handle, or
Chris@23 342 releaseFeatureSet for this feature set. Host must call
Chris@23 343 releaseFeatureSet after use. */
Chris@23 344 VampFeatureList *(*process)(VampPluginHandle,
Chris@23 345 const float *const *inputBuffers,
Chris@23 346 int sec,
Chris@23 347 int nsec);
Chris@23 348
Chris@23 349 /** Return any remaining features at the end of processing. */
Chris@23 350 VampFeatureList *(*getRemainingFeatures)(VampPluginHandle);
Chris@23 351
Chris@23 352 /** Release a feature set returned from process or getRemainingFeatures. */
Chris@23 353 void (*releaseFeatureSet)(VampFeatureList *);
Chris@23 354
Chris@23 355 } VampPluginDescriptor;
Chris@23 356
Chris@23 357
Chris@23 358 /** Get the descriptor for a given plugin index in this library.
Chris@23 359 Return NULL if the index is outside the range of valid indices for
Chris@23 360 this plugin library.
Chris@23 361
Chris@23 362 The hostApiVersion argument tells the library code the highest
Chris@23 363 Vamp API version supported by the host. The function should
Chris@23 364 return a plugin descriptor compatible with the highest API version
Chris@23 365 supported by the library that is no higher than that supported by
Chris@23 366 the host. Provided the descriptor has the correct vampApiVersion
Chris@23 367 field for its actual compatibility level, the host should be able
Chris@23 368 to do the right thing with it: use it if possible, discard it
Chris@23 369 otherwise.
Chris@23 370
Chris@23 371 This is the only symbol that a Vamp plugin actually needs to
Chris@23 372 export from its shared object; all others can be hidden. See the
Chris@23 373 accompanying documentation for notes on how to achieve this with
Chris@23 374 certain compilers.
Chris@23 375 */
Chris@23 376 const VampPluginDescriptor *vampGetPluginDescriptor
Chris@23 377 (unsigned int hostApiVersion, unsigned int index);
Chris@23 378
Chris@23 379
Chris@23 380 /** Function pointer type for vampGetPluginDescriptor. */
Chris@23 381 typedef const VampPluginDescriptor *(*VampGetPluginDescriptorFunction)
Chris@23 382 (unsigned int, unsigned int);
Chris@23 383
Chris@23 384 #ifdef __cplusplus
Chris@23 385 }
Chris@23 386 #endif
Chris@23 387
Chris@23 388 #endif