annotate win32-mingw/include/vamp/vamp.h @ 33:879bdc878826

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