comparison vamp-support/PluginConfiguration.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 3eb00e5c76c4
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_PLUGIN_CONFIGURATION_H
38 #define PIPER_PLUGIN_CONFIGURATION_H
39
40 #include <vamp-hostsdk/Plugin.h>
41
42 #include <map>
43 #include <string>
44
45 namespace piper_vamp {
46
47 /**
48 * \class PluginConfiguration
49 *
50 * PluginConfiguration is a structure bundling together data that
51 * affect the configuration of a plugin: parameter values, programs,
52 * and initialisation settings. Although an interactive Vamp plugin
53 * host may configure a plugin in stages, for example to take into
54 * account that a plugin's preferred step and block size may change
55 * when its parameters are changed, a batch host or a host supporting
56 * store and recall of configurations may wish to keep all
57 * configuration settings together.
58 */
59 struct PluginConfiguration
60 {
61 PluginConfiguration() : // invalid configuration by default
62 channelCount(0), stepSize(0), blockSize(0) { }
63
64 int channelCount;
65 int stepSize;
66 int blockSize;
67 typedef std::map<std::string, float> ParameterMap;
68 ParameterMap parameterValues;
69 std::string currentProgram;
70
71 static PluginConfiguration
72 fromPlugin(Vamp::Plugin *p,
73 int channelCount,
74 int stepSize,
75 int blockSize) {
76
77 PluginConfiguration c;
78
79 c.channelCount = channelCount;
80 c.stepSize = stepSize;
81 c.blockSize = blockSize;
82
83 Vamp::PluginBase::ParameterList params = p->getParameterDescriptors();
84 for (Vamp::PluginBase::ParameterList::const_iterator i = params.begin();
85 i != params.end(); ++i) {
86 std::string pid = i->identifier;
87 c.parameterValues[pid] = p->getParameter(pid);
88 }
89
90 if (!p->getPrograms().empty()) {
91 c.currentProgram = p->getCurrentProgram();
92 }
93
94 return c;
95 }
96 };
97
98 }
99
100 #endif