VampPluginSDK  2.1
vamp.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Vamp
00005 
00006     An API for audio analysis and feature extraction plugins.
00007 
00008     Centre for Digital Music, Queen Mary, University of London.
00009     Copyright 2006 Chris Cannam.
00010   
00011     Permission is hereby granted, free of charge, to any person
00012     obtaining a copy of this software and associated documentation
00013     files (the "Software"), to deal in the Software without
00014     restriction, including without limitation the rights to use, copy,
00015     modify, merge, publish, distribute, sublicense, and/or sell copies
00016     of the Software, and to permit persons to whom the Software is
00017     furnished to do so, subject to the following conditions:
00018 
00019     The above copyright notice and this permission notice shall be
00020     included in all copies or substantial portions of the Software.
00021 
00022     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00025     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
00026     ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00027     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00028     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00029 
00030     Except as contained in this notice, the names of the Centre for
00031     Digital Music; Queen Mary, University of London; and Chris Cannam
00032     shall not be used in advertising or otherwise to promote the sale,
00033     use or other dealings in this Software without prior written
00034     authorization.
00035 */
00036 
00037 #ifndef VAMP_HEADER_INCLUDED
00038 #define VAMP_HEADER_INCLUDED
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00053 #define VAMP_API_VERSION 2
00054 
00071 typedef struct _VampParameterDescriptor
00072 {
00074     const char *identifier;
00075 
00077     const char *name;
00078 
00080     const char *description;
00081 
00083     const char *unit;
00084 
00086     float minValue;
00087 
00089     float maxValue;
00090 
00092     float defaultValue;
00093 
00095     int isQuantized;
00096 
00098     float quantizeStep;
00099 
00101     const char **valueNames;
00102 
00103 } VampParameterDescriptor;
00104 
00105 typedef enum
00106 {
00108     vampOneSamplePerStep,
00109 
00111     vampFixedSampleRate,
00112 
00114     vampVariableSampleRate
00115 
00116 } VampSampleType;
00117 
00118 typedef struct _VampOutputDescriptor
00119 {
00121     const char *identifier;
00122 
00124     const char *name;
00125 
00127     const char *description;
00128 
00130     const char *unit;
00131 
00133     int hasFixedBinCount;
00134 
00136     unsigned int binCount;
00137 
00139     const char **binNames;
00140 
00142     int hasKnownExtents;
00143     
00145     float minValue;
00146 
00148     float maxValue;
00149 
00151     int isQuantized;
00152 
00154     float quantizeStep;
00155 
00157     VampSampleType sampleType;
00158 
00161     float sampleRate;
00162 
00170     int hasDuration;
00171 
00172 } VampOutputDescriptor;
00173 
00174 typedef struct _VampFeature
00175 {
00177     int hasTimestamp;
00178 
00180     int sec;
00181 
00183     int nsec;
00184 
00186     unsigned int valueCount;
00187 
00189     float *values;
00190 
00192     char *label;
00193 
00194 } VampFeature;
00195 
00196 typedef struct _VampFeatureV2
00197 {
00199     int hasDuration;
00200 
00202     int durationSec;
00203 
00205     int durationNsec;
00206 
00207 } VampFeatureV2;
00208 
00209 typedef union _VampFeatureUnion
00210 {
00211     // sizeof(featureV1) >= sizeof(featureV2) for backward compatibility
00212     VampFeature   v1;
00213     VampFeatureV2 v2;
00214 
00215 } VampFeatureUnion;
00216 
00217 typedef struct _VampFeatureList
00218 {
00220     unsigned int featureCount;
00221 
00235     VampFeatureUnion *features;
00236 
00237 } VampFeatureList;
00238 
00239 typedef enum
00240 {
00241     vampTimeDomain,
00242     vampFrequencyDomain
00243 
00244 } VampInputDomain;
00245 
00246 typedef void *VampPluginHandle;
00247 
00248 typedef struct _VampPluginDescriptor
00249 {
00251     unsigned int vampApiVersion;
00252 
00254     const char *identifier;
00255 
00257     const char *name;
00258 
00260     const char *description;
00261 
00263     const char *maker;
00264 
00266     int pluginVersion;
00267 
00269     const char *copyright;
00270 
00272     unsigned int parameterCount;
00273 
00275     const VampParameterDescriptor **parameters;
00276 
00278     unsigned int programCount;
00279 
00281     const char **programs;
00282 
00284     VampInputDomain inputDomain;
00285 
00287     VampPluginHandle (*instantiate)(const struct _VampPluginDescriptor *,
00288                                    float inputSampleRate);
00289 
00291     void (*cleanup)(VampPluginHandle);
00292 
00294     int (*initialise)(VampPluginHandle,
00295                       unsigned int inputChannels,
00296                       unsigned int stepSize, 
00297                       unsigned int blockSize);
00298 
00300     void (*reset)(VampPluginHandle);
00301 
00303     float (*getParameter)(VampPluginHandle, int);
00304 
00306     void  (*setParameter)(VampPluginHandle, int, float);
00307 
00309     unsigned int (*getCurrentProgram)(VampPluginHandle);
00310 
00312     void  (*selectProgram)(VampPluginHandle, unsigned int);
00313     
00315     unsigned int (*getPreferredStepSize)(VampPluginHandle);
00316 
00318     unsigned int (*getPreferredBlockSize)(VampPluginHandle);
00319 
00321     unsigned int (*getMinChannelCount)(VampPluginHandle);
00322 
00324     unsigned int (*getMaxChannelCount)(VampPluginHandle);
00325 
00327     unsigned int (*getOutputCount)(VampPluginHandle);
00328 
00333     VampOutputDescriptor *(*getOutputDescriptor)(VampPluginHandle,
00334                                                  unsigned int);
00335 
00337     void (*releaseOutputDescriptor)(VampOutputDescriptor *);
00338 
00344     VampFeatureList *(*process)(VampPluginHandle,
00345                                 const float *const *inputBuffers,
00346                                 int sec,
00347                                 int nsec);
00348 
00350     VampFeatureList *(*getRemainingFeatures)(VampPluginHandle);
00351 
00353     void (*releaseFeatureSet)(VampFeatureList *);
00354 
00355 } VampPluginDescriptor;
00356 
00357 
00376 const VampPluginDescriptor *vampGetPluginDescriptor
00377     (unsigned int hostApiVersion, unsigned int index);
00378 
00379 
00381 typedef const VampPluginDescriptor *(*VampGetPluginDescriptorFunction)
00382     (unsigned int, unsigned int);
00383 
00384 #ifdef __cplusplus
00385 }
00386 #endif
00387 
00388 #endif