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