annotate osx/include/vamp/vamp.h @ 117:9ba8af959808

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