annotate vamp-support/RequestResponse.h @ 296:50a0b4fea7f1 tip master

Merge pull request #8 from michel-slm/gcc15 Include headers needed to compile with GCC 15's -std=gnu23 default
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 27 Jan 2025 08:53:58 +0000
parents 09753ad777db
children
rev   line source
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"
cannam@287 42 #include "PluginProgramParameters.h"
c@97 43
c@97 44 #include <map>
c@97 45 #include <string>
c@97 46
c@97 47 namespace piper_vamp {
c@97 48
c@97 49 /**
c@97 50 * \class ListRequest
c@97 51 *
c@97 52 * ListRequest is a structure containing the information needed to
c@127 53 * list plugins.
c@97 54 *
c@97 55 * \see ListResponse
c@97 56 */
c@97 57 struct ListRequest
c@97 58 {
c@127 59 ListRequest() { } // no constraints by default
c@127 60
c@127 61 std::vector<std::string> from;
c@97 62 };
c@97 63
c@97 64 /**
c@97 65 * \class ListResponse
c@97 66 *
c@97 67 * ListResponse is a structure containing the information returned by
c@97 68 * PluginLoader when asked to list static information about the
c@97 69 * available plugins.
c@97 70 *
c@97 71 * \see PluginStaticData
c@97 72 */
c@97 73 struct ListResponse
c@97 74 {
c@97 75 ListResponse() { } // empty by default
c@97 76
c@97 77 std::vector<PluginStaticData> available;
c@97 78 };
c@97 79
c@97 80 /**
c@97 81 * \class LoadRequest
c@97 82 *
c@97 83 * LoadRequest is a structure containing the information necessary to
c@97 84 * load a plugin. When a request is made to load a plugin using a
c@97 85 * LoadRequest, the response is typically returned in a LoadResponse
c@97 86 * structure.
c@97 87 *
c@97 88 * \see LoadResponse
c@97 89 */
c@97 90 struct LoadRequest
c@97 91 {
c@97 92 LoadRequest() : // invalid request by default
c@97 93 inputSampleRate(0.f),
c@97 94 adapterFlags(0) { }
c@97 95
c@97 96 /**
c@97 97 * PluginKey is a string type that is used to identify a plugin
c@97 98 * uniquely within the scope of "the current system". For further
c@97 99 * details \see Vamp::PluginLoader::PluginKey.
c@97 100 */
c@97 101 typedef std::string PluginKey;
c@97 102
c@97 103 /**
c@97 104 * The identifying key for the plugin to be loaded.
c@97 105 */
c@97 106 PluginKey pluginKey;
c@97 107
c@97 108 /**
c@97 109 * Sample rate to be passed to the plugin's constructor.
c@97 110 */
c@97 111 float inputSampleRate;
c@97 112
c@97 113 /**
c@97 114 * A bitwise OR of the values in the PluginLoader::AdapterFlags
c@97 115 * enumeration, indicating under which circumstances an adapter
c@97 116 * should be used to wrap the original plugin. If adapterFlags is
c@97 117 * 0, no optional adapters will be used.
c@97 118 *
c@97 119 * \see Vamp::PluginLoader::AdapterFlags
c@97 120 */
c@97 121 int adapterFlags;
c@97 122 };
c@97 123
c@97 124 /**
c@97 125 * \class LoadResponse
c@97 126 *
c@97 127 * LoadResponse is a structure containing the information returned by
c@97 128 * PluginLoader when asked to load a plugin using a LoadRequest.
c@97 129 *
c@97 130 * If the plugin could not be loaded, the plugin field will be 0.
c@97 131 *
c@97 132 * The caller takes ownership of the plugin contained here, which
c@97 133 * should be deleted (using the standard C++ delete keyword) after
c@97 134 * use.
c@97 135 *
c@97 136 * \see LoadRequest
c@97 137 */
c@97 138 struct LoadResponse
c@97 139 {
c@97 140 LoadResponse() : // invalid (failed) response by default
c@97 141 plugin(0) { }
c@97 142
c@97 143 /**
c@97 144 * A pointer to the loaded plugin, or 0 if loading failed. Caller
c@97 145 * takes ownership of the plugin and must delete it after use.
c@97 146 */
c@97 147 Vamp::Plugin *plugin;
c@97 148
c@97 149 /**
c@97 150 * The static data associated with the loaded plugin, that is, all
c@97 151 * information about it that does not depend on its configuration
c@97 152 * (parameters, programs, initialisation parameters). The contents
c@97 153 * of this structure are only valid if plugin is non-0.
c@97 154 *
c@97 155 * Much of the data in here is duplicated with the plugin itself.
c@97 156 */
c@97 157 PluginStaticData staticData;
c@97 158
c@97 159 /**
c@97 160 * The default configuration for this plugin, that is, default
c@97 161 * values for parameters etc. The contents of this structure are
c@97 162 * only valid if plugin is non-0.
c@97 163 */
c@97 164 PluginConfiguration defaultConfiguration;
cannam@287 165
cannam@287 166 /**
cannam@287 167 * The parameter values associated with any program settings
cannam@287 168 * available for the plugin. The contents of this structure are
cannam@287 169 * only valid if plugin is non-0.
cannam@287 170 */
cannam@287 171 PluginProgramParameters programParameters;
c@97 172 };
c@97 173
c@97 174 /**
c@97 175 * \class ConfigurationRequest
c@97 176 *
c@97 177 * A wrapper for a plugin pointer and PluginConfiguration, bundling up
c@97 178 * the data needed to configure a plugin after it has been loaded.
c@97 179 *
c@97 180 * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse
c@97 181 */
c@97 182 struct ConfigurationRequest
c@97 183 {
c@97 184 public:
c@97 185 ConfigurationRequest() : // invalid request by default
c@97 186 plugin(0) { }
c@97 187
c@97 188 Vamp::Plugin *plugin;
c@97 189 PluginConfiguration configuration;
c@97 190 };
c@97 191
c@97 192 /**
c@97 193 * \class ConfigurationResponse
c@97 194 *
c@97 195 * The return value from a configuration request (i.e. setting the
c@97 196 * parameters and initialising the plugin). If the configuration was
c@97 197 * successful, the output list will contain the final
cannam@185 198 * post-initialisation output descriptors and the required step and
cannam@185 199 * block size. (The step and block size will usually match those
cannam@185 200 * passed to configure, but may differ if the parameter settings
cannam@185 201 * turned out to be incompatible with those.) If configuration failed,
c@97 202 * the output list will be empty.
c@97 203 *
c@97 204 * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse
c@97 205 */
c@97 206 struct ConfigurationResponse
c@97 207 {
c@97 208 public:
c@97 209 ConfigurationResponse() : // failed by default
c@97 210 plugin(0) { }
c@97 211
c@97 212 Vamp::Plugin *plugin;
c@97 213 Vamp::Plugin::OutputList outputs;
cannam@220 214 StaticOutputInfo staticOutputInfo; // stuff not in Plugin::OutputDescriptor
cannam@220 215
cannam@185 216 Framing framing;
c@97 217 };
c@97 218
c@97 219 /**
c@97 220 * \class ProcessRequest
c@97 221 *
c@97 222 * A structure that bundles the necessary data for making a process
c@97 223 * call: plugin, input buffers, and timestamp. Caller retains
c@97 224 * ownership of the plugin, but the buffers are passed "by value" to
c@97 225 * avoid ownership concerns.
c@97 226 *
c@97 227 * \see Vamp::Plugin::process()
c@97 228 */
c@97 229 struct ProcessRequest
c@97 230 {
c@97 231 public:
c@97 232 ProcessRequest() : // invalid by default
c@97 233 plugin(0) { }
c@97 234
c@97 235 Vamp::Plugin *plugin;
c@97 236 std::vector<std::vector<float> > inputBuffers;
c@97 237 Vamp::RealTime timestamp;
c@97 238 };
c@97 239
c@97 240 /**
c@97 241 * \class ProcessResponse
c@97 242 *
c@97 243 * A structure that bundles the data returned by a process call. This
c@97 244 * is simply a FeatureSet wrapper that happens to reference the plugin
c@97 245 * as well.
c@97 246 *
c@97 247 * \see FinishResponse, Vamp::Plugin::process()
c@97 248 */
c@97 249 struct ProcessResponse
c@97 250 {
c@97 251 public:
c@97 252 ProcessResponse() : // invalid by default
c@97 253 plugin(0) { }
c@97 254
c@97 255 Vamp::Plugin *plugin;
c@97 256 Vamp::Plugin::FeatureSet features;
c@97 257 };
c@97 258
c@97 259 /**
c@97 260 * \class FinishRequest
c@97 261 *
c@97 262 * A structure that bundles the necessary data for finishing
c@97 263 * processing, i.e. calling getRemainingFeatures(). This consists only
c@97 264 * of the plugin pointer. Caller retains ownership of the plugin.
c@97 265 *
c@97 266 * \see Vamp::Plugin::getRemainingFeatures()
c@97 267 */
c@97 268 struct FinishRequest
c@97 269 {
c@97 270 public:
c@97 271 FinishRequest() : // invalid by default
c@97 272 plugin(0) { }
c@97 273
c@97 274 Vamp::Plugin *plugin;
c@97 275 };
c@97 276
c@97 277
c@97 278 /**
c@97 279 * \class FinishResponse
c@97 280 *
c@97 281 * A structure that bundles the data returned by a
c@97 282 * getRemainingFeatures() call. This is identical to ProcessResponse.
c@97 283 *
c@97 284 * \see ProcessResponse, Vamp::Plugin::getRemainingFeatures()
c@97 285 */
c@97 286 struct FinishResponse
c@97 287 {
c@97 288 public:
c@97 289 FinishResponse() : // invalid by default
c@97 290 plugin(0) { }
c@97 291
c@97 292 Vamp::Plugin *plugin;
c@97 293 Vamp::Plugin::FeatureSet features;
c@97 294 };
c@97 295
c@97 296 }
c@97 297
c@97 298 #endif