Revision 2:c9a4bd247497
| Makefile | ||
|---|---|---|
| 2 | 2 |
LDFLAGS += -lvamp-hostsdk -ldl |
| 3 | 3 |
CXXFLAGS += -Wall -Wextra |
| 4 | 4 |
|
| 5 |
OBJECTS := vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o |
|
| 5 |
OBJECTS := vamp-plugin-tester.o Tester.o Test.o TestStaticData.o TestInputExtremes.o TestMultipleRuns.o
|
|
| 6 | 6 |
|
| 7 | 7 |
vamp-plugin-tester: $(OBJECTS) |
| 8 | 8 |
|
| TestInputExtremes.cpp | ||
|---|---|---|
| 45 | 45 |
#include <memory> |
| 46 | 46 |
using namespace std; |
| 47 | 47 |
|
| 48 |
#include <cstdlib> |
|
| 48 | 49 |
#include <cmath> |
| 49 | 50 |
|
| 50 | 51 |
Tester::TestRegistrar<TestNormalInput> |
| ... | ... | |
| 68 | 69 |
Test::Results |
| 69 | 70 |
TestNormalInput::test(string key) |
| 70 | 71 |
{
|
| 72 |
Plugin::FeatureSet f; |
|
| 71 | 73 |
int rate = 44100; |
| 72 | 74 |
auto_ptr<Plugin> p(load(key, rate)); |
| 73 | 75 |
Results r; |
| ... | ... | |
| 83 | 85 |
++idx; |
| 84 | 86 |
} |
| 85 | 87 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 86 |
p->process(block, timestamp); |
|
| 88 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 89 |
appendFeatures(f, fs); |
|
| 87 | 90 |
} |
| 88 | 91 |
destroyBlock(block, channels); |
| 89 | 92 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 90 |
if (allFeaturesValid(fs)) {
|
|
| 93 |
appendFeatures(f, fs); |
|
| 94 |
if (allFeaturesValid(f)) {
|
|
| 91 | 95 |
r.push_back(success()); |
| 92 | 96 |
} else {
|
| 93 | 97 |
r.push_back(warning("plugin returned one or more NaN/inf values"));
|
| ... | ... | |
| 114 | 118 |
Test::Results |
| 115 | 119 |
TestShortInput::test(string key) |
| 116 | 120 |
{
|
| 121 |
Plugin::FeatureSet f; |
|
| 117 | 122 |
int rate = 44100; |
| 118 | 123 |
auto_ptr<Plugin> p(load(key, rate)); |
| 119 | 124 |
Results r; |
| ... | ... | |
| 127 | 132 |
} |
| 128 | 133 |
++idx; |
| 129 | 134 |
} |
| 130 |
p->process(block, RealTime::zeroTime); |
|
| 135 |
Plugin::FeatureSet fs = p->process(block, RealTime::zeroTime); |
|
| 136 |
appendFeatures(f, fs); |
|
| 131 | 137 |
destroyBlock(block, channels); |
| 132 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
|
| 133 |
if (allFeaturesValid(fs)) {
|
|
| 138 |
fs = p->getRemainingFeatures(); |
|
| 139 |
appendFeatures(f, fs); |
|
| 140 |
if (allFeaturesValid(f)) {
|
|
| 134 | 141 |
r.push_back(success()); |
| 135 | 142 |
} else {
|
| 136 | 143 |
r.push_back(warning("plugin returned one or more NaN/inf values"));
|
| ... | ... | |
| 141 | 148 |
Test::Results |
| 142 | 149 |
TestSilentInput::test(string key) |
| 143 | 150 |
{
|
| 151 |
Plugin::FeatureSet f; |
|
| 144 | 152 |
int rate = 44100; |
| 145 | 153 |
auto_ptr<Plugin> p(load(key, rate)); |
| 146 | 154 |
Results r; |
| ... | ... | |
| 154 | 162 |
} |
| 155 | 163 |
for (int i = 0; i < 200; ++i) {
|
| 156 | 164 |
RealTime timestamp = RealTime::frame2RealTime(i * blocksize, rate); |
| 157 |
p->process(block, timestamp); |
|
| 165 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 166 |
appendFeatures(f, fs); |
|
| 158 | 167 |
} |
| 159 | 168 |
destroyBlock(block, channels); |
| 160 | 169 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 161 |
if (allFeaturesValid(fs)) {
|
|
| 170 |
appendFeatures(f, fs); |
|
| 171 |
if (allFeaturesValid(f)) {
|
|
| 162 | 172 |
r.push_back(success()); |
| 163 | 173 |
} else {
|
| 164 | 174 |
r.push_back(warning("plugin returned one or more NaN/inf values"));
|
| ... | ... | |
| 169 | 179 |
Test::Results |
| 170 | 180 |
TestTooLoudInput::test(string key) |
| 171 | 181 |
{
|
| 182 |
Plugin::FeatureSet f; |
|
| 172 | 183 |
int rate = 44100; |
| 173 | 184 |
auto_ptr<Plugin> p(load(key, rate)); |
| 174 | 185 |
Results r; |
| ... | ... | |
| 184 | 195 |
++idx; |
| 185 | 196 |
} |
| 186 | 197 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 187 |
p->process(block, timestamp); |
|
| 198 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 199 |
appendFeatures(f, fs); |
|
| 188 | 200 |
} |
| 189 | 201 |
destroyBlock(block, channels); |
| 190 | 202 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 191 |
if (allFeaturesValid(fs)) {
|
|
| 203 |
appendFeatures(f, fs); |
|
| 204 |
if (allFeaturesValid(f)) {
|
|
| 192 | 205 |
r.push_back(success()); |
| 193 | 206 |
} else {
|
| 194 | 207 |
r.push_back(warning("plugin returned one or more NaN/inf values"));
|
| ... | ... | |
| 199 | 212 |
Test::Results |
| 200 | 213 |
TestRandomInput::test(string key) |
| 201 | 214 |
{
|
| 215 |
Plugin::FeatureSet f; |
|
| 202 | 216 |
int rate = 44100; |
| 203 | 217 |
auto_ptr<Plugin> p(load(key, rate)); |
| 204 | 218 |
Results r; |
| ... | ... | |
| 214 | 228 |
++idx; |
| 215 | 229 |
} |
| 216 | 230 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 217 |
p->process(block, timestamp); |
|
| 231 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 232 |
appendFeatures(f, fs); |
|
| 218 | 233 |
} |
| 219 | 234 |
destroyBlock(block, channels); |
| 220 | 235 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 221 |
if (allFeaturesValid(fs)) {
|
|
| 236 |
appendFeatures(f, fs); |
|
| 237 |
if (allFeaturesValid(f)) {
|
|
| 222 | 238 |
r.push_back(success()); |
| 223 | 239 |
} else {
|
| 224 | 240 |
r.push_back(warning("plugin returned one or more NaN/inf values"));
|
| TestMultipleRuns.cpp | ||
|---|---|---|
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
|
| 2 |
|
|
| 3 |
/* |
|
| 4 |
Vamp Plugin Tester |
|
| 5 |
Chris Cannam, cannam@all-day-breakfast.com |
|
| 6 |
Centre for Digital Music, Queen Mary, University of London. |
|
| 7 |
Copyright 2009 QMUL. |
|
| 8 |
|
|
| 9 |
This program loads a Vamp plugin and tests its susceptibility to a |
|
| 10 |
number of common pitfalls, including handling of extremes of input |
|
| 11 |
data. If you can think of any additional useful tests that are |
|
| 12 |
easily added, please send them to me. |
|
| 13 |
|
|
| 14 |
Permission is hereby granted, free of charge, to any person |
|
| 15 |
obtaining a copy of this software and associated documentation |
|
| 16 |
files (the "Software"), to deal in the Software without |
|
| 17 |
restriction, including without limitation the rights to use, copy, |
|
| 18 |
modify, merge, publish, distribute, sublicense, and/or sell copies |
|
| 19 |
of the Software, and to permit persons to whom the Software is |
|
| 20 |
furnished to do so, subject to the following conditions: |
|
| 21 |
|
|
| 22 |
The above copyright notice and this permission notice shall be |
|
| 23 |
included in all copies or substantial portions of the Software. |
|
| 24 |
|
|
| 25 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
| 26 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
| 27 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
| 28 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
|
| 29 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
|
| 30 |
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
| 31 |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
| 32 |
|
|
| 33 |
Except as contained in this notice, the names of the Centre for |
|
| 34 |
Digital Music; Queen Mary, University of London; and Chris Cannam |
|
| 35 |
shall not be used in advertising or otherwise to promote the sale, |
|
| 36 |
use or other dealings in this Software without prior written |
|
| 37 |
authorization. |
|
| 38 |
*/ |
|
| 39 |
|
|
| 40 |
#include "TestMultipleRuns.h" |
|
| 41 |
|
|
| 42 |
#include <vamp-hostsdk/Plugin.h> |
|
| 43 |
using namespace Vamp; |
|
| 44 |
|
|
| 45 |
#include <memory> |
|
| 46 |
using namespace std; |
|
| 47 |
|
|
| 48 |
#include <cmath> |
|
| 49 |
|
|
| 50 |
Tester::TestRegistrar<TestDistinctRuns> |
|
| 51 |
TestDistinctRuns::m_registrar("Consecutive runs with separate instances");
|
|
| 52 |
|
|
| 53 |
Tester::TestRegistrar<TestReset> |
|
| 54 |
TestReset::m_registrar("Consecutive runs with a single instance using reset");
|
|
| 55 |
|
|
| 56 |
Tester::TestRegistrar<TestInterleavedRuns> |
|
| 57 |
TestInterleavedRuns::m_registrar("Simultaneous interleaved runs in a single thread");
|
|
| 58 |
|
|
| 59 |
Test::Results |
|
| 60 |
TestDistinctRuns::test(string key) |
|
| 61 |
{
|
|
| 62 |
Plugin::FeatureSet f[2]; |
|
| 63 |
int rate = 44100; |
|
| 64 |
Results r; |
|
| 65 |
float **block = 0; |
|
| 66 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 67 |
|
|
| 68 |
for (int run = 0; run < 2; ++run) {
|
|
| 69 |
auto_ptr<Plugin> p(load(key, rate)); |
|
| 70 |
if (!initDefaults(p.get(), channels, step, blocksize, r)) return r; |
|
| 71 |
if (!block) block = createBlock(channels, blocksize); |
|
| 72 |
int idx = 0; |
|
| 73 |
for (int i = 0; i < 100; ++i) {
|
|
| 74 |
for (size_t j = 0; j < blocksize; ++j) {
|
|
| 75 |
for (size_t c = 0; c < channels; ++c) {
|
|
| 76 |
block[c][j] = sinf(float(idx) / 10.f); |
|
| 77 |
if ((i == 20 || i == 80) && (j < 2)) {
|
|
| 78 |
block[c][j] = float(j) - 1.f; |
|
| 79 |
} |
|
| 80 |
} |
|
| 81 |
++idx; |
|
| 82 |
} |
|
| 83 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
|
| 84 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 85 |
appendFeatures(f[run], fs); |
|
| 86 |
} |
|
| 87 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
|
| 88 |
appendFeatures(f[run], fs); |
|
| 89 |
} |
|
| 90 |
if (block) destroyBlock(block, channels); |
|
| 91 |
|
|
| 92 |
if (!(f[0] == f[1])) {
|
|
| 93 |
r.push_back(warning("Consecutive runs with separate instances produce different results"));
|
|
| 94 |
} else {
|
|
| 95 |
r.push_back(success()); |
|
| 96 |
} |
|
| 97 |
|
|
| 98 |
return r; |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
Test::Results |
|
| 102 |
TestReset::test(string key) |
|
| 103 |
{
|
|
| 104 |
Plugin::FeatureSet f[2]; |
|
| 105 |
int rate = 44100; |
|
| 106 |
Results r; |
|
| 107 |
float **block = 0; |
|
| 108 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 109 |
|
|
| 110 |
auto_ptr<Plugin> p(load(key, rate)); |
|
| 111 |
for (int run = 0; run < 2; ++run) {
|
|
| 112 |
if (run == 1) p->reset(); |
|
| 113 |
if (!initDefaults(p.get(), channels, step, blocksize, r)) return r; |
|
| 114 |
if (!block) block = createBlock(channels, blocksize); |
|
| 115 |
int idx = 0; |
|
| 116 |
for (int i = 0; i < 100; ++i) {
|
|
| 117 |
for (size_t j = 0; j < blocksize; ++j) {
|
|
| 118 |
for (size_t c = 0; c < channels; ++c) {
|
|
| 119 |
block[c][j] = sinf(float(idx) / 10.f); |
|
| 120 |
if ((i == 20 || i == 80) && (j < 2)) {
|
|
| 121 |
block[c][j] = float(j) - 1.f; |
|
| 122 |
} |
|
| 123 |
} |
|
| 124 |
++idx; |
|
| 125 |
} |
|
| 126 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
|
| 127 |
Plugin::FeatureSet fs = p->process(block, timestamp); |
|
| 128 |
appendFeatures(f[run], fs); |
|
| 129 |
} |
|
| 130 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
|
| 131 |
appendFeatures(f[run], fs); |
|
| 132 |
} |
|
| 133 |
if (block) destroyBlock(block, channels); |
|
| 134 |
|
|
| 135 |
if (!(f[0] == f[1])) {
|
|
| 136 |
r.push_back(warning("Consecutive runs with the same instance (using reset) produce different results"));
|
|
| 137 |
} else {
|
|
| 138 |
r.push_back(success()); |
|
| 139 |
} |
|
| 140 |
|
|
| 141 |
return r; |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
Test::Results |
|
| 145 |
TestInterleavedRuns::test(string key) |
|
| 146 |
{
|
|
| 147 |
Plugin::FeatureSet f[2]; |
|
| 148 |
int rate = 44100; |
|
| 149 |
Results r; |
|
| 150 |
float **block = 0; |
|
| 151 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 152 |
Plugin *p[2]; |
|
| 153 |
for (int run = 0; run < 2; ++run) {
|
|
| 154 |
p[run] = load(key, rate); |
|
| 155 |
if (!initDefaults(p[run], channels, step, blocksize, r)) {
|
|
| 156 |
delete p[run]; |
|
| 157 |
if (run > 0) delete p[0]; |
|
| 158 |
return r; |
|
| 159 |
} |
|
| 160 |
if (!block) block = createBlock(channels, blocksize); |
|
| 161 |
} |
|
| 162 |
int idx = 0; |
|
| 163 |
for (int i = 0; i < 100; ++i) {
|
|
| 164 |
for (size_t j = 0; j < blocksize; ++j) {
|
|
| 165 |
for (size_t c = 0; c < channels; ++c) {
|
|
| 166 |
block[c][j] = sinf(float(idx) / 10.f); |
|
| 167 |
if ((i == 20 || i == 80) && (j < 2)) {
|
|
| 168 |
block[c][j] = float(j) - 1.f; |
|
| 169 |
} |
|
| 170 |
} |
|
| 171 |
++idx; |
|
| 172 |
} |
|
| 173 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
|
| 174 |
for (int run = 0; run < 2; ++run) {
|
|
| 175 |
Plugin::FeatureSet fs = p[run]->process(block, timestamp); |
|
| 176 |
appendFeatures(f[run], fs); |
|
| 177 |
} |
|
| 178 |
} |
|
| 179 |
for (int run = 0; run < 2; ++run) {
|
|
| 180 |
Plugin::FeatureSet fs = p[run]->getRemainingFeatures(); |
|
| 181 |
appendFeatures(f[run], fs); |
|
| 182 |
delete p[run]; |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
if (block) destroyBlock(block, channels); |
|
| 186 |
|
|
| 187 |
if (!(f[0] == f[1])) {
|
|
| 188 |
r.push_back(warning("Consecutive runs with the same instance (using reset) produce different results"));
|
|
| 189 |
} else {
|
|
| 190 |
r.push_back(success()); |
|
| 191 |
} |
|
| 192 |
|
|
| 193 |
return r; |
|
| 194 |
} |
|
| TestMultipleRuns.h | ||
|---|---|---|
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
|
| 2 |
|
|
| 3 |
/* |
|
| 4 |
Vamp Plugin Tester |
|
| 5 |
Chris Cannam, cannam@all-day-breakfast.com |
|
| 6 |
Centre for Digital Music, Queen Mary, University of London. |
|
| 7 |
Copyright 2009 QMUL. |
|
| 8 |
|
|
| 9 |
This program loads a Vamp plugin and tests its susceptibility to a |
|
| 10 |
number of common pitfalls, including handling of extremes of input |
|
| 11 |
data. If you can think of any additional useful tests that are |
|
| 12 |
easily added, please send them to me. |
|
| 13 |
|
|
| 14 |
Permission is hereby granted, free of charge, to any person |
|
| 15 |
obtaining a copy of this software and associated documentation |
|
| 16 |
files (the "Software"), to deal in the Software without |
|
| 17 |
restriction, including without limitation the rights to use, copy, |
|
| 18 |
modify, merge, publish, distribute, sublicense, and/or sell copies |
|
| 19 |
of the Software, and to permit persons to whom the Software is |
|
| 20 |
furnished to do so, subject to the following conditions: |
|
| 21 |
|
|
| 22 |
The above copyright notice and this permission notice shall be |
|
| 23 |
included in all copies or substantial portions of the Software. |
|
| 24 |
|
|
| 25 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
| 26 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
| 27 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
| 28 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
|
| 29 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
|
| 30 |
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
| 31 |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
| 32 |
|
|
| 33 |
Except as contained in this notice, the names of the Centre for |
|
| 34 |
Digital Music; Queen Mary, University of London; and Chris Cannam |
|
| 35 |
shall not be used in advertising or otherwise to promote the sale, |
|
| 36 |
use or other dealings in this Software without prior written |
|
| 37 |
authorization. |
|
| 38 |
*/ |
|
| 39 |
|
|
| 40 |
#ifndef _TEST_MULTIPLE_RUNS_H_ |
|
| 41 |
#define _TEST_MULTIPLE_RUNS_H_ |
|
| 42 |
|
|
| 43 |
#include "Test.h" |
|
| 44 |
#include "Tester.h" |
|
| 45 |
|
|
| 46 |
class TestDistinctRuns : public Test |
|
| 47 |
{
|
|
| 48 |
public: |
|
| 49 |
TestDistinctRuns() : Test() { }
|
|
| 50 |
Results test(std::string key); |
|
| 51 |
|
|
| 52 |
protected: |
|
| 53 |
static Tester::TestRegistrar<TestDistinctRuns> m_registrar; |
|
| 54 |
}; |
|
| 55 |
|
|
| 56 |
class TestReset : public Test |
|
| 57 |
{
|
|
| 58 |
public: |
|
| 59 |
TestReset() : Test() { }
|
|
| 60 |
Results test(std::string key); |
|
| 61 |
|
|
| 62 |
protected: |
|
| 63 |
static Tester::TestRegistrar<TestReset> m_registrar; |
|
| 64 |
}; |
|
| 65 |
|
|
| 66 |
class TestInterleavedRuns : public Test |
|
| 67 |
{
|
|
| 68 |
public: |
|
| 69 |
TestInterleavedRuns() : Test() { }
|
|
| 70 |
Results test(std::string key); |
|
| 71 |
|
|
| 72 |
protected: |
|
| 73 |
static Tester::TestRegistrar<TestInterleavedRuns> m_registrar; |
|
| 74 |
}; |
|
| 75 |
|
|
| 76 |
#endif |
|
Also available in: Unified diff