Mercurial > hg > vamp-plugin-sdk
comparison vamp/vamp.h @ 24:e252b1ab423f
* add documentation to the C header
author | cannam |
---|---|
date | Tue, 25 Apr 2006 14:15:48 +0000 |
parents | b4043af42278 |
children | ca1309b937b6 |
comparison
equal
deleted
inserted
replaced
23:db01ce9e7657 | 24:e252b1ab423f |
---|---|
42 * | 42 * |
43 * This is the formal plugin API for Vamp. Plugin authors may prefer | 43 * This is the formal plugin API for Vamp. Plugin authors may prefer |
44 * to use the C++ classes provided in the Vamp plugin SDK, instead of | 44 * to use the C++ classes provided in the Vamp plugin SDK, instead of |
45 * using this API directly. There is an adapter class provided that | 45 * using this API directly. There is an adapter class provided that |
46 * makes C++ plugins available using this C API with relatively little | 46 * makes C++ plugins available using this C API with relatively little |
47 * work, and the C++ headers are thoroughly documented. | 47 * work, and the C++ headers are more thoroughly documented. |
48 * | |
49 * IMPORTANT: The comments in this file summarise the purpose of each | |
50 * of the declared fields and functions, but do not provide a complete | |
51 * guide to their permitted values and expected usage. Please refer | |
52 * to the C++ headers in the Vamp plugin SDK for further details and | |
53 * plugin lifecycle documentation. | |
48 */ | 54 */ |
49 | 55 |
50 #ifdef __cplusplus | 56 #ifdef __cplusplus |
51 extern "C" { | 57 extern "C" { |
52 #endif | 58 #endif |
59 #define VAMP_API_VERSION_MAJOR 0 | 65 #define VAMP_API_VERSION_MAJOR 0 |
60 #define VAMP_API_VERSION_MINOR 2 | 66 #define VAMP_API_VERSION_MINOR 2 |
61 | 67 |
62 typedef struct _VampParameterDescriptor | 68 typedef struct _VampParameterDescriptor |
63 { | 69 { |
70 /** Computer-usable name of the parameter. Must not change. [a-zA-Z0-9_] */ | |
64 const char *name; | 71 const char *name; |
72 | |
73 /** Human-readable name of the parameter. May be translatable. */ | |
65 const char *description; | 74 const char *description; |
75 | |
76 /** Human-readable unit of the parameter. */ | |
66 const char *unit; | 77 const char *unit; |
78 | |
79 /** Minimum value. */ | |
67 float minValue; | 80 float minValue; |
81 | |
82 /** Maximum value. */ | |
68 float maxValue; | 83 float maxValue; |
84 | |
85 /** Default value. Plugin is responsible for setting this on initialise. */ | |
69 float defaultValue; | 86 float defaultValue; |
87 | |
88 /** 1 if parameter values are quantized to a particular resolution. */ | |
70 int isQuantized; | 89 int isQuantized; |
90 | |
91 /** Quantization resolution, if isQuantized. */ | |
71 float quantizeStep; | 92 float quantizeStep; |
93 | |
94 /** Human-readable names of the values, if isQuantized. May be NULL. */ | |
72 const char **valueNames; | 95 const char **valueNames; |
73 | 96 |
74 } VampParameterDescriptor; | 97 } VampParameterDescriptor; |
75 | 98 |
76 typedef enum | 99 typedef enum |
77 { | 100 { |
101 /** Each process call returns results aligned with call's block start. */ | |
78 vampOneSamplePerStep, | 102 vampOneSamplePerStep, |
103 | |
104 /** Returned results are evenly spaced at samplerate specified below. */ | |
79 vampFixedSampleRate, | 105 vampFixedSampleRate, |
106 | |
107 /** Returned results have their own individual timestamps. */ | |
80 vampVariableSampleRate | 108 vampVariableSampleRate |
81 | 109 |
82 } VampSampleType; | 110 } VampSampleType; |
83 | 111 |
84 typedef struct _VampOutputDescriptor | 112 typedef struct _VampOutputDescriptor |
85 { | 113 { |
114 /** Computer-usable name of the output. Must not change. [a-zA-Z0-9_] */ | |
86 const char *name; | 115 const char *name; |
116 | |
117 /** Human-readable name of the output. May be translatable. */ | |
87 const char *description; | 118 const char *description; |
119 | |
120 /** Human-readable name of the unit of the output. */ | |
88 const char *unit; | 121 const char *unit; |
122 | |
123 /** 1 if output has equal number of values for each returned result. */ | |
89 int hasFixedBinCount; | 124 int hasFixedBinCount; |
125 | |
126 /** Number of values per result, if hasFixedBinCount. */ | |
90 unsigned int binCount; | 127 unsigned int binCount; |
128 | |
129 /** Names of returned value bins, if hasFixedBinCount. May be NULL. */ | |
91 const char **binNames; | 130 const char **binNames; |
131 | |
132 /** 1 if each returned value falls within the same fixed min/max range. */ | |
92 int hasKnownExtents; | 133 int hasKnownExtents; |
134 | |
135 /** Minimum value for a returned result in any bin, if hasKnownExtents. */ | |
93 float minValue; | 136 float minValue; |
137 | |
138 /** Maximum value for a returned result in any bin, if hasKnownExtents. */ | |
94 float maxValue; | 139 float maxValue; |
140 | |
141 /** 1 if returned results are quantized to a particular resolution. */ | |
95 int isQuantized; | 142 int isQuantized; |
143 | |
144 /** Quantization resolution for returned results, if isQuantized. */ | |
96 float quantizeStep; | 145 float quantizeStep; |
146 | |
147 /** Time positioning method for returned results (see VampSampleType). */ | |
97 VampSampleType sampleType; | 148 VampSampleType sampleType; |
149 | |
150 /** Sample rate of returned results, if sampleType is vampFixedSampleRate. | |
151 "Resolution" of result, if sampleType is vampVariableSampleRate. */ | |
98 float sampleRate; | 152 float sampleRate; |
99 | 153 |
100 } VampOutputDescriptor; | 154 } VampOutputDescriptor; |
101 | 155 |
102 typedef struct _VampFeature | 156 typedef struct _VampFeature |
103 { | 157 { |
158 /** 1 if the feature has a timestamp (i.e. if vampVariableSampleRate). */ | |
104 int hasTimestamp; | 159 int hasTimestamp; |
160 | |
161 /** Seconds component of timestamp. */ | |
105 int sec; | 162 int sec; |
163 | |
164 /** Nanoseconds component of timestamp. */ | |
106 int nsec; | 165 int nsec; |
166 | |
167 /** Number of values. Must be binCount if hasFixedBinCount. */ | |
107 unsigned int valueCount; | 168 unsigned int valueCount; |
169 | |
170 /** Values for this returned sample. */ | |
108 float *values; | 171 float *values; |
172 | |
173 /** Label for this returned sample. May be NULL. */ | |
109 char *label; | 174 char *label; |
110 | 175 |
111 } VampFeature; | 176 } VampFeature; |
112 | 177 |
113 typedef struct _VampFeatureList | 178 typedef struct _VampFeatureList |
114 { | 179 { |
180 /** Number of features in this feature list. */ | |
115 unsigned int featureCount; | 181 unsigned int featureCount; |
182 | |
183 /** Features in this feature list. May be NULL if featureCount is zero. */ | |
116 VampFeature *features; | 184 VampFeature *features; |
117 | 185 |
118 } VampFeatureList; | 186 } VampFeatureList; |
119 | 187 |
120 typedef enum | 188 typedef enum |
126 | 194 |
127 typedef void *VampPluginHandle; | 195 typedef void *VampPluginHandle; |
128 | 196 |
129 typedef struct _VampPluginDescriptor | 197 typedef struct _VampPluginDescriptor |
130 { | 198 { |
199 /** Computer-usable name of the plugin. Must not change. [a-zA-Z0-9_] */ | |
131 const char *name; | 200 const char *name; |
201 | |
202 /** Human-readable name of the plugin. May be translatable. */ | |
132 const char *description; | 203 const char *description; |
204 | |
205 /** Human-readable name of plugin's author or vendor. */ | |
133 const char *maker; | 206 const char *maker; |
207 | |
208 /** Version number of the plugin. */ | |
134 int pluginVersion; | 209 int pluginVersion; |
210 | |
211 /** Human-readable summary of copyright or licensing for plugin. */ | |
135 const char *copyright; | 212 const char *copyright; |
213 | |
214 /** Number of parameter inputs. */ | |
136 unsigned int parameterCount; | 215 unsigned int parameterCount; |
216 | |
217 /** Fixed descriptors for parameter inputs. */ | |
137 const VampParameterDescriptor **parameters; | 218 const VampParameterDescriptor **parameters; |
219 | |
220 /** Number of programs. */ | |
138 unsigned int programCount; | 221 unsigned int programCount; |
222 | |
223 /** Fixed names for programs. */ | |
139 const char **programs; | 224 const char **programs; |
225 | |
226 /** Preferred input domain for audio input (time or frequency). */ | |
140 VampInputDomain inputDomain; | 227 VampInputDomain inputDomain; |
141 | 228 |
229 /** Create and return a new instance of this plugin. */ | |
142 VampPluginHandle (*instantiate)(const struct _VampPluginDescriptor *, | 230 VampPluginHandle (*instantiate)(const struct _VampPluginDescriptor *, |
143 float inputSampleRate); | 231 float inputSampleRate); |
144 | 232 |
233 /** Destroy an instance of this plugin. */ | |
145 void (*cleanup)(VampPluginHandle); | 234 void (*cleanup)(VampPluginHandle); |
146 | 235 |
236 /** Initialise an instance following parameter configuration. */ | |
147 int (*initialise)(VampPluginHandle, | 237 int (*initialise)(VampPluginHandle, |
148 unsigned int inputChannels, | 238 unsigned int inputChannels, |
149 unsigned int stepSize, | 239 unsigned int stepSize, |
150 unsigned int blockSize); | 240 unsigned int blockSize); |
151 | 241 |
242 /** Reset an instance, ready to use again on new input data. */ | |
152 void (*reset)(VampPluginHandle); | 243 void (*reset)(VampPluginHandle); |
153 | 244 |
245 /** Get a parameter value. */ | |
154 float (*getParameter)(VampPluginHandle, int); | 246 float (*getParameter)(VampPluginHandle, int); |
247 | |
248 /** Set a parameter value. May only be called before initialise. */ | |
155 void (*setParameter)(VampPluginHandle, int, float); | 249 void (*setParameter)(VampPluginHandle, int, float); |
156 | 250 |
251 /** Get the current program (if programCount > 0). */ | |
157 unsigned int (*getCurrentProgram)(VampPluginHandle); | 252 unsigned int (*getCurrentProgram)(VampPluginHandle); |
253 | |
254 /** Set the current program. May only be called before initialise. */ | |
158 void (*selectProgram)(VampPluginHandle, unsigned int); | 255 void (*selectProgram)(VampPluginHandle, unsigned int); |
159 | 256 |
257 /** Get the plugin's preferred processing window increment in samples. */ | |
160 unsigned int (*getPreferredStepSize)(VampPluginHandle); | 258 unsigned int (*getPreferredStepSize)(VampPluginHandle); |
259 | |
260 /** Get the plugin's preferred processing window size in samples. */ | |
161 unsigned int (*getPreferredBlockSize)(VampPluginHandle); | 261 unsigned int (*getPreferredBlockSize)(VampPluginHandle); |
262 | |
263 /** Get the minimum number of input channels this plugin can handle. */ | |
162 unsigned int (*getMinChannelCount)(VampPluginHandle); | 264 unsigned int (*getMinChannelCount)(VampPluginHandle); |
265 | |
266 /** Get the maximum number of input channels this plugin can handle. */ | |
163 unsigned int (*getMaxChannelCount)(VampPluginHandle); | 267 unsigned int (*getMaxChannelCount)(VampPluginHandle); |
164 | 268 |
269 /** Get the number of feature outputs (distinct sets of results). */ | |
165 unsigned int (*getOutputCount)(VampPluginHandle); | 270 unsigned int (*getOutputCount)(VampPluginHandle); |
271 | |
272 /** Get a descriptor for a given feature output. Returned pointer | |
273 is valid only until next call to getOutputDescriptor for this | |
274 handle, or releaseOutputDescriptor for this descriptor. Host | |
275 must call releaseOutputDescriptor after use. */ | |
166 VampOutputDescriptor *(*getOutputDescriptor)(VampPluginHandle, | 276 VampOutputDescriptor *(*getOutputDescriptor)(VampPluginHandle, |
167 unsigned int); | 277 unsigned int); |
278 | |
279 /** Destroy a descriptor for a feature output. */ | |
168 void (*releaseOutputDescriptor)(VampOutputDescriptor *); | 280 void (*releaseOutputDescriptor)(VampOutputDescriptor *); |
169 | 281 |
282 /** Process an input block and return a set of features. Returned | |
283 pointer is valid only until next call to process, | |
284 getRemainingFeatures, or cleanup for this handle, or | |
285 releaseFeatureSet for this feature set. Host must call | |
286 releaseFeatureSet after use. */ | |
170 VampFeatureList *(*process)(VampPluginHandle, | 287 VampFeatureList *(*process)(VampPluginHandle, |
171 float **inputBuffers, | 288 float **inputBuffers, |
172 int sec, | 289 int sec, |
173 int nsec); | 290 int nsec); |
291 | |
292 /** Return any remaining features at the end of processing. */ | |
174 VampFeatureList *(*getRemainingFeatures)(VampPluginHandle); | 293 VampFeatureList *(*getRemainingFeatures)(VampPluginHandle); |
294 | |
295 /** Release a feature set returned from process or getRemainingFeatures. */ | |
175 void (*releaseFeatureSet)(VampFeatureList *); | 296 void (*releaseFeatureSet)(VampFeatureList *); |
176 | 297 |
177 } VampPluginDescriptor; | 298 } VampPluginDescriptor; |
178 | 299 |
300 /** Get the descriptor for a given plugin index in this library. | |
301 Return NULL if the index is outside the range of valid indices for | |
302 this plugin library. */ | |
179 const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int index); | 303 const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int index); |
180 | 304 |
305 /** Function pointer type for vampGetPluginDescriptor. */ | |
181 typedef const VampPluginDescriptor *(*VampGetPluginDescriptorFunction)(unsigned int); | 306 typedef const VampPluginDescriptor *(*VampGetPluginDescriptorFunction)(unsigned int); |
182 | 307 |
183 #ifdef __cplusplus | 308 #ifdef __cplusplus |
184 } | 309 } |
185 #endif | 310 #endif |