Mercurial > hg > piper-cpp
comparison vamp-support/RequestResponse.h @ 97:427c4c725085
Bring in the Request/Response classes that were in the Vamp SDK, adding them to vamp-support in here instead
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 13 Oct 2016 18:05:35 +0100 |
parents | |
children | 5b113c87b6e6 |
comparison
equal
deleted
inserted
replaced
96:215c9fb6b7a4 | 97:427c4c725085 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Piper C++ | |
5 | |
6 An API for audio analysis and feature extraction plugins. | |
7 | |
8 Centre for Digital Music, Queen Mary, University of London. | |
9 Copyright 2006-2016 Chris Cannam and QMUL. | |
10 | |
11 Permission is hereby granted, free of charge, to any person | |
12 obtaining a copy of this software and associated documentation | |
13 files (the "Software"), to deal in the Software without | |
14 restriction, including without limitation the rights to use, copy, | |
15 modify, merge, publish, distribute, sublicense, and/or sell copies | |
16 of the Software, and to permit persons to whom the Software is | |
17 furnished to do so, subject to the following conditions: | |
18 | |
19 The above copyright notice and this permission notice shall be | |
20 included in all copies or substantial portions of the Software. | |
21 | |
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR | |
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
29 | |
30 Except as contained in this notice, the names of the Centre for | |
31 Digital Music; Queen Mary, University of London; and Chris Cannam | |
32 shall not be used in advertising or otherwise to promote the sale, | |
33 use or other dealings in this Software without prior written | |
34 authorization. | |
35 */ | |
36 | |
37 #ifndef PIPER_REQUEST_RESPONSE_H | |
38 #define PIPER_REQUEST_RESPONSE_H | |
39 | |
40 #include "PluginStaticData.h" | |
41 #include "PluginConfiguration.h" | |
42 | |
43 #include <map> | |
44 #include <string> | |
45 | |
46 namespace piper_vamp { | |
47 | |
48 /** | |
49 * \class ListRequest | |
50 * | |
51 * ListRequest is a structure containing the information needed to | |
52 * list plugins. Currently empty. | |
53 * | |
54 * \see ListResponse | |
55 */ | |
56 struct ListRequest | |
57 { | |
58 }; | |
59 | |
60 /** | |
61 * \class ListResponse | |
62 * | |
63 * ListResponse is a structure containing the information returned by | |
64 * PluginLoader when asked to list static information about the | |
65 * available plugins. | |
66 * | |
67 * \see PluginStaticData | |
68 */ | |
69 struct ListResponse | |
70 { | |
71 ListResponse() { } // empty by default | |
72 | |
73 std::vector<PluginStaticData> available; | |
74 }; | |
75 | |
76 /** | |
77 * \class LoadRequest | |
78 * | |
79 * LoadRequest is a structure containing the information necessary to | |
80 * load a plugin. When a request is made to load a plugin using a | |
81 * LoadRequest, the response is typically returned in a LoadResponse | |
82 * structure. | |
83 * | |
84 * \see LoadResponse | |
85 */ | |
86 struct LoadRequest | |
87 { | |
88 LoadRequest() : // invalid request by default | |
89 inputSampleRate(0.f), | |
90 adapterFlags(0) { } | |
91 | |
92 /** | |
93 * PluginKey is a string type that is used to identify a plugin | |
94 * uniquely within the scope of "the current system". For further | |
95 * details \see Vamp::PluginLoader::PluginKey. | |
96 */ | |
97 typedef std::string PluginKey; | |
98 | |
99 /** | |
100 * The identifying key for the plugin to be loaded. | |
101 */ | |
102 PluginKey pluginKey; | |
103 | |
104 /** | |
105 * Sample rate to be passed to the plugin's constructor. | |
106 */ | |
107 float inputSampleRate; | |
108 | |
109 /** | |
110 * A bitwise OR of the values in the PluginLoader::AdapterFlags | |
111 * enumeration, indicating under which circumstances an adapter | |
112 * should be used to wrap the original plugin. If adapterFlags is | |
113 * 0, no optional adapters will be used. | |
114 * | |
115 * \see Vamp::PluginLoader::AdapterFlags | |
116 */ | |
117 int adapterFlags; | |
118 }; | |
119 | |
120 /** | |
121 * \class LoadResponse | |
122 * | |
123 * LoadResponse is a structure containing the information returned by | |
124 * PluginLoader when asked to load a plugin using a LoadRequest. | |
125 * | |
126 * If the plugin could not be loaded, the plugin field will be 0. | |
127 * | |
128 * The caller takes ownership of the plugin contained here, which | |
129 * should be deleted (using the standard C++ delete keyword) after | |
130 * use. | |
131 * | |
132 * \see LoadRequest | |
133 */ | |
134 struct LoadResponse | |
135 { | |
136 LoadResponse() : // invalid (failed) response by default | |
137 plugin(0) { } | |
138 | |
139 /** | |
140 * A pointer to the loaded plugin, or 0 if loading failed. Caller | |
141 * takes ownership of the plugin and must delete it after use. | |
142 */ | |
143 Vamp::Plugin *plugin; | |
144 | |
145 /** | |
146 * The static data associated with the loaded plugin, that is, all | |
147 * information about it that does not depend on its configuration | |
148 * (parameters, programs, initialisation parameters). The contents | |
149 * of this structure are only valid if plugin is non-0. | |
150 * | |
151 * Much of the data in here is duplicated with the plugin itself. | |
152 */ | |
153 PluginStaticData staticData; | |
154 | |
155 /** | |
156 * The default configuration for this plugin, that is, default | |
157 * values for parameters etc. The contents of this structure are | |
158 * only valid if plugin is non-0. | |
159 */ | |
160 PluginConfiguration defaultConfiguration; | |
161 }; | |
162 | |
163 /** | |
164 * \class ConfigurationRequest | |
165 * | |
166 * A wrapper for a plugin pointer and PluginConfiguration, bundling up | |
167 * the data needed to configure a plugin after it has been loaded. | |
168 * | |
169 * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse | |
170 */ | |
171 struct ConfigurationRequest | |
172 { | |
173 public: | |
174 ConfigurationRequest() : // invalid request by default | |
175 plugin(0) { } | |
176 | |
177 Vamp::Plugin *plugin; | |
178 PluginConfiguration configuration; | |
179 }; | |
180 | |
181 /** | |
182 * \class ConfigurationResponse | |
183 * | |
184 * The return value from a configuration request (i.e. setting the | |
185 * parameters and initialising the plugin). If the configuration was | |
186 * successful, the output list will contain the final | |
187 * post-initialisation output descriptors. If configuration failed, | |
188 * the output list will be empty. | |
189 * | |
190 * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse | |
191 */ | |
192 struct ConfigurationResponse | |
193 { | |
194 public: | |
195 ConfigurationResponse() : // failed by default | |
196 plugin(0) { } | |
197 | |
198 Vamp::Plugin *plugin; | |
199 Vamp::Plugin::OutputList outputs; | |
200 }; | |
201 | |
202 /** | |
203 * \class ProcessRequest | |
204 * | |
205 * A structure that bundles the necessary data for making a process | |
206 * call: plugin, input buffers, and timestamp. Caller retains | |
207 * ownership of the plugin, but the buffers are passed "by value" to | |
208 * avoid ownership concerns. | |
209 * | |
210 * \see Vamp::Plugin::process() | |
211 */ | |
212 struct ProcessRequest | |
213 { | |
214 public: | |
215 ProcessRequest() : // invalid by default | |
216 plugin(0) { } | |
217 | |
218 Vamp::Plugin *plugin; | |
219 std::vector<std::vector<float> > inputBuffers; | |
220 Vamp::RealTime timestamp; | |
221 }; | |
222 | |
223 /** | |
224 * \class ProcessResponse | |
225 * | |
226 * A structure that bundles the data returned by a process call. This | |
227 * is simply a FeatureSet wrapper that happens to reference the plugin | |
228 * as well. | |
229 * | |
230 * \see FinishResponse, Vamp::Plugin::process() | |
231 */ | |
232 struct ProcessResponse | |
233 { | |
234 public: | |
235 ProcessResponse() : // invalid by default | |
236 plugin(0) { } | |
237 | |
238 Vamp::Plugin *plugin; | |
239 Vamp::Plugin::FeatureSet features; | |
240 }; | |
241 | |
242 /** | |
243 * \class FinishRequest | |
244 * | |
245 * A structure that bundles the necessary data for finishing | |
246 * processing, i.e. calling getRemainingFeatures(). This consists only | |
247 * of the plugin pointer. Caller retains ownership of the plugin. | |
248 * | |
249 * \see Vamp::Plugin::getRemainingFeatures() | |
250 */ | |
251 struct FinishRequest | |
252 { | |
253 public: | |
254 FinishRequest() : // invalid by default | |
255 plugin(0) { } | |
256 | |
257 Vamp::Plugin *plugin; | |
258 }; | |
259 | |
260 | |
261 /** | |
262 * \class FinishResponse | |
263 * | |
264 * A structure that bundles the data returned by a | |
265 * getRemainingFeatures() call. This is identical to ProcessResponse. | |
266 * | |
267 * \see ProcessResponse, Vamp::Plugin::getRemainingFeatures() | |
268 */ | |
269 struct FinishResponse | |
270 { | |
271 public: | |
272 FinishResponse() : // invalid by default | |
273 plugin(0) { } | |
274 | |
275 Vamp::Plugin *plugin; | |
276 Vamp::Plugin::FeatureSet features; | |
277 }; | |
278 | |
279 } | |
280 | |
281 #endif |