annotate osx/include/vamp/vamp.h @ 26:213792ad6ace

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