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