annotate osx/include/vamp/vamp.h @ 31:642a72ce5e62

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