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