cannam@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@0
|
2
|
cannam@0
|
3 /*
|
cannam@0
|
4 Vamp Plugin Tester
|
cannam@0
|
5 Chris Cannam, cannam@all-day-breakfast.com
|
cannam@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
cannam@0
|
7 Copyright 2009 QMUL.
|
cannam@0
|
8
|
cannam@0
|
9 This program loads a Vamp plugin and tests its susceptibility to a
|
cannam@0
|
10 number of common pitfalls, including handling of extremes of input
|
cannam@0
|
11 data. If you can think of any additional useful tests that are
|
cannam@0
|
12 easily added, please send them to me.
|
cannam@0
|
13
|
cannam@0
|
14 Permission is hereby granted, free of charge, to any person
|
cannam@0
|
15 obtaining a copy of this software and associated documentation
|
cannam@0
|
16 files (the "Software"), to deal in the Software without
|
cannam@0
|
17 restriction, including without limitation the rights to use, copy,
|
cannam@0
|
18 modify, merge, publish, distribute, sublicense, and/or sell copies
|
cannam@0
|
19 of the Software, and to permit persons to whom the Software is
|
cannam@0
|
20 furnished to do so, subject to the following conditions:
|
cannam@0
|
21
|
cannam@0
|
22 The above copyright notice and this permission notice shall be
|
cannam@0
|
23 included in all copies or substantial portions of the Software.
|
cannam@0
|
24
|
cannam@0
|
25 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
cannam@0
|
26 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
cannam@0
|
27 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
cannam@0
|
28 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
cannam@0
|
29 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
cannam@0
|
30 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
cannam@0
|
31 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
cannam@0
|
32
|
cannam@0
|
33 Except as contained in this notice, the names of the Centre for
|
cannam@0
|
34 Digital Music; Queen Mary, University of London; and Chris Cannam
|
cannam@0
|
35 shall not be used in advertising or otherwise to promote the sale,
|
cannam@0
|
36 use or other dealings in this Software without prior written
|
cannam@0
|
37 authorization.
|
cannam@0
|
38 */
|
cannam@0
|
39
|
cannam@0
|
40 #include <vamp-hostsdk/PluginHostAdapter.h>
|
cannam@0
|
41 #include <vamp-hostsdk/PluginInputDomainAdapter.h>
|
cannam@0
|
42 #include <vamp-hostsdk/PluginLoader.h>
|
cannam@0
|
43
|
cannam@0
|
44 #include <iostream>
|
cannam@0
|
45
|
cannam@0
|
46 #include <cstring>
|
cannam@0
|
47 #include <cstdlib>
|
cannam@0
|
48 #include <cmath>
|
cannam@0
|
49
|
cannam@0
|
50 #include "Tester.h"
|
cannam@0
|
51
|
cannam@0
|
52 using Vamp::Plugin;
|
cannam@0
|
53 using Vamp::PluginHostAdapter;
|
cannam@0
|
54 using Vamp::RealTime;
|
cannam@0
|
55 using Vamp::HostExt::PluginLoader;
|
cannam@0
|
56 using Vamp::HostExt::PluginWrapper;
|
cannam@0
|
57 using Vamp::HostExt::PluginInputDomainAdapter;
|
cannam@0
|
58
|
cannam@0
|
59 using namespace std;
|
cannam@0
|
60
|
cannam@0
|
61 Tester::Tester(std::string key) :
|
cannam@0
|
62 m_key(key)
|
cannam@0
|
63 {
|
cannam@0
|
64 }
|
cannam@0
|
65
|
cannam@0
|
66 Tester::~Tester()
|
cannam@0
|
67 {
|
cannam@0
|
68 }
|
cannam@0
|
69
|
cannam@0
|
70 Tester::Registry &
|
cannam@0
|
71 Tester::registry()
|
cannam@0
|
72 {
|
cannam@0
|
73 static Registry r;
|
cannam@0
|
74 return r;
|
cannam@0
|
75 }
|
cannam@0
|
76
|
cannam@0
|
77 bool
|
cannam@0
|
78 Tester::test()
|
cannam@0
|
79 {
|
cannam@0
|
80 /*
|
cannam@0
|
81
|
cannam@0
|
82 Things I would like to see tested:
|
cannam@0
|
83
|
cannam@0
|
84 * Identifiers for parameters, outputs, or plugin itself contain
|
cannam@0
|
85 illegal characters - DONE
|
cannam@0
|
86
|
cannam@0
|
87 * Any of the plugin's name, maker etc fields are empty - DONE
|
cannam@0
|
88
|
cannam@1
|
89 * Default value of a parameter is not quantized as specified - DONE
|
cannam@1
|
90
|
cannam@1
|
91 * Parameter minValue >= maxValue, or defaultValue < minValue
|
cannam@1
|
92 or > maxValue - DONE
|
cannam@1
|
93
|
cannam@1
|
94 * Plugin fails when given zero-length or very short input - DONE
|
cannam@1
|
95
|
cannam@1
|
96 * Plugin fails when given "all digital zeros" input - DONE
|
cannam@1
|
97
|
cannam@1
|
98 * Plugin fails when given input that exceeds +/-1 - DONE
|
cannam@1
|
99
|
cannam@1
|
100 * Plugin fails when given "normal" random input (just in case!) - DONE
|
cannam@1
|
101
|
cannam@0
|
102 * Plugin returns different results if another instance is
|
cannam@3
|
103 constructed and run "interleaved" with it (from same thread) - DONE
|
cannam@0
|
104
|
cannam@0
|
105 * Plugin's returned timestamps do not change as expected when
|
cannam@0
|
106 run with a different base timestamp for input (though there
|
cannam@0
|
107 could be legitimate reasons for this)
|
cannam@0
|
108
|
cannam@0
|
109 * Plugin produces different results on second run, after reset
|
cannam@3
|
110 called - DONE
|
cannam@0
|
111
|
cannam@0
|
112 * Initial value of a parameter on plugin construction differs
|
cannam@0
|
113 from its default value (i.e. plugin produces different
|
cannam@0
|
114 results depending on whether parameter is set explicitly by
|
cannam@0
|
115 host to default value or not)
|
cannam@0
|
116
|
cannam@0
|
117 * If a plugin reports any programs, selecting default program
|
cannam@0
|
118 explicitly changes results (as for default parameters)
|
cannam@0
|
119
|
cannam@0
|
120 * Output feature does not hasTimestamp when output type is
|
cannam@0
|
121 VariableSampleRate
|
cannam@0
|
122
|
cannam@0
|
123 * Output feature hasTimestamp or hasDuration when output type is
|
cannam@0
|
124 OneSamplePerStep (warning only, this is not an error)
|
cannam@0
|
125
|
cannam@0
|
126 * Plugin fails gracelessly when constructed with "weird" sample
|
cannam@0
|
127 rate or initialised with "wrong" step size, block size, or
|
cannam@0
|
128 number of channels
|
cannam@0
|
129
|
cannam@0
|
130 * Plugin returns features whose output numbers do not have
|
cannam@0
|
131 a corresponding record in output descriptor list
|
cannam@0
|
132
|
cannam@0
|
133 * Plugin fails to return any features on some output (warning
|
cannam@0
|
134 only)
|
cannam@0
|
135
|
cannam@0
|
136 * Constructor takes a long time to run. A fuzzy concept, but
|
cannam@0
|
137 suggests that some work should have been deferred to
|
cannam@0
|
138 initialise(). Warning only
|
cannam@0
|
139
|
cannam@0
|
140 Well, that's quite a lot of tests already. What else?
|
cannam@0
|
141
|
cannam@0
|
142 */
|
cannam@0
|
143
|
cannam@0
|
144 bool good = true;
|
cannam@0
|
145
|
cannam@0
|
146 try {
|
cannam@0
|
147 for (Registry::const_iterator i = registry().begin();
|
cannam@0
|
148 i != registry().end(); ++i) {
|
cannam@0
|
149
|
cannam@3
|
150 std::cout << " -- Performing test: " << i->first << std::endl;
|
cannam@0
|
151
|
cannam@0
|
152 Test *test = i->second->makeTest();
|
cannam@0
|
153 Test::Results results = test->test(m_key);
|
cannam@0
|
154 delete test;
|
cannam@0
|
155
|
cannam@0
|
156 for (int j = 0; j < (int)results.size(); ++j) {
|
cannam@0
|
157 switch (results[j].code()) {
|
cannam@0
|
158 case Test::Result::Success:
|
cannam@0
|
159 break;
|
cannam@3
|
160 case Test::Result::Note:
|
cannam@3
|
161 std::cout << " ** NOTE: " << results[j].message() << std::endl;
|
cannam@3
|
162 break;
|
cannam@0
|
163 case Test::Result::Warning:
|
cannam@3
|
164 std::cout << " ** WARNING: " << results[j].message() << std::endl;
|
cannam@0
|
165 break;
|
cannam@0
|
166 case Test::Result::Error:
|
cannam@3
|
167 std::cout << " ** ERROR: " << results[j].message() << std::endl;
|
cannam@0
|
168 good = false;
|
cannam@0
|
169 break;
|
cannam@0
|
170 }
|
cannam@0
|
171 }
|
cannam@0
|
172 }
|
cannam@0
|
173 } catch (Test::FailedToLoadPlugin) {
|
cannam@3
|
174 std::cout << "ERROR: Failed to load plugin (key = \"" << m_key
|
cannam@0
|
175 << "\")" << std::endl;
|
cannam@0
|
176 }
|
cannam@0
|
177
|
cannam@0
|
178 return good;
|
cannam@0
|
179 }
|
cannam@0
|
180
|