annotate osx/include/vamp/vamp.h @ 120:c9cf28b398fb

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