annotate src/vamp-plugin-sdk-2.4/vamp/vamp.h @ 169:223a55898ab9 tip default

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