Revision 3:0f65bb22172b TestMultipleRuns.cpp
| TestMultipleRuns.cpp | ||
|---|---|---|
| 56 | 56 |
Tester::TestRegistrar<TestInterleavedRuns> |
| 57 | 57 |
TestInterleavedRuns::m_registrar("Simultaneous interleaved runs in a single thread");
|
| 58 | 58 |
|
| 59 |
static const size_t _step = 1000; |
|
| 60 |
|
|
| 59 | 61 |
Test::Results |
| 60 | 62 |
TestDistinctRuns::test(string key) |
| 61 | 63 |
{
|
| 62 | 64 |
Plugin::FeatureSet f[2]; |
| 63 | 65 |
int rate = 44100; |
| 64 | 66 |
Results r; |
| 65 |
float **block = 0; |
|
| 66 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 67 |
float **data = 0; |
|
| 68 |
size_t channels = 0; |
|
| 69 |
size_t count = 100; |
|
| 67 | 70 |
|
| 68 | 71 |
for (int run = 0; run < 2; ++run) {
|
| 69 | 72 |
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 |
} |
|
| 73 |
if (!initAdapted(p.get(), channels, _step, _step, r)) return r; |
|
| 74 |
if (!data) data = createTestAudio(channels, _step, count); |
|
| 75 |
for (size_t i = 0; i < count; ++i) {
|
|
| 76 |
float *ptr[channels]; |
|
| 77 |
size_t idx = i * _step; |
|
| 78 |
for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; |
|
| 83 | 79 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 84 |
Plugin::FeatureSet fs = p->process(block, timestamp);
|
|
| 80 |
Plugin::FeatureSet fs = p->process(ptr, timestamp);
|
|
| 85 | 81 |
appendFeatures(f[run], fs); |
| 86 | 82 |
} |
| 87 | 83 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 88 | 84 |
appendFeatures(f[run], fs); |
| 89 | 85 |
} |
| 90 |
if (block) destroyBlock(block, channels);
|
|
| 86 |
if (data) destroyTestAudio(data, channels);
|
|
| 91 | 87 |
|
| 92 | 88 |
if (!(f[0] == f[1])) {
|
| 93 | 89 |
r.push_back(warning("Consecutive runs with separate instances produce different results"));
|
| ... | ... | |
| 104 | 100 |
Plugin::FeatureSet f[2]; |
| 105 | 101 |
int rate = 44100; |
| 106 | 102 |
Results r; |
| 107 |
float **block = 0; |
|
| 108 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 103 |
float **data = 0; |
|
| 104 |
size_t channels = 0; |
|
| 105 |
size_t count = 100; |
|
| 109 | 106 |
|
| 110 | 107 |
auto_ptr<Plugin> p(load(key, rate)); |
| 108 |
|
|
| 111 | 109 |
for (int run = 0; run < 2; ++run) {
|
| 112 | 110 |
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 |
} |
|
| 111 |
if (!initAdapted(p.get(), channels, _step, _step, r)) return r; |
|
| 112 |
if (!data) data = createTestAudio(channels, _step, count); |
|
| 113 |
for (size_t i = 0; i < count; ++i) {
|
|
| 114 |
float *ptr[channels]; |
|
| 115 |
size_t idx = i * _step; |
|
| 116 |
for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; |
|
| 126 | 117 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 127 |
Plugin::FeatureSet fs = p->process(block, timestamp);
|
|
| 118 |
Plugin::FeatureSet fs = p->process(ptr, timestamp);
|
|
| 128 | 119 |
appendFeatures(f[run], fs); |
| 129 | 120 |
} |
| 130 | 121 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
| 131 | 122 |
appendFeatures(f[run], fs); |
| 132 | 123 |
} |
| 133 |
if (block) destroyBlock(block, channels);
|
|
| 124 |
if (data) destroyTestAudio(data, channels);
|
|
| 134 | 125 |
|
| 135 | 126 |
if (!(f[0] == f[1])) {
|
| 136 |
r.push_back(warning("Consecutive runs with the same instance (using reset) produce different results"));
|
|
| 127 |
Result res = warning("Consecutive runs with the same instance (using reset) produce different results");
|
|
| 128 |
dump(res, f[0], f[1]); |
|
| 129 |
r.push_back(res); |
|
| 137 | 130 |
} else {
|
| 138 | 131 |
r.push_back(success()); |
| 139 | 132 |
} |
| ... | ... | |
| 147 | 140 |
Plugin::FeatureSet f[2]; |
| 148 | 141 |
int rate = 44100; |
| 149 | 142 |
Results r; |
| 150 |
float **block = 0; |
|
| 151 |
size_t channels = 0, step = 0, blocksize = 0; |
|
| 143 |
float **data = 0; |
|
| 144 |
size_t channels = 0; |
|
| 145 |
size_t count = 100; |
|
| 146 |
|
|
| 152 | 147 |
Plugin *p[2]; |
| 153 | 148 |
for (int run = 0; run < 2; ++run) {
|
| 154 | 149 |
p[run] = load(key, rate); |
| 155 |
if (!initDefaults(p[run], channels, step, blocksize, r)) {
|
|
| 150 |
if (!initAdapted(p[run], channels, _step, _step, r)) {
|
|
| 156 | 151 |
delete p[run]; |
| 157 | 152 |
if (run > 0) delete p[0]; |
| 158 | 153 |
return r; |
| 159 | 154 |
} |
| 160 |
if (!block) block = createBlock(channels, blocksize);
|
|
| 155 |
if (!data) data = createTestAudio(channels, _step, count);
|
|
| 161 | 156 |
} |
| 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 |
} |
|
| 157 |
for (size_t i = 0; i < count; ++i) {
|
|
| 158 |
float *ptr[channels]; |
|
| 159 |
size_t idx = i * _step; |
|
| 160 |
for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; |
|
| 173 | 161 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
| 174 | 162 |
for (int run = 0; run < 2; ++run) {
|
| 175 |
Plugin::FeatureSet fs = p[run]->process(block, timestamp);
|
|
| 163 |
Plugin::FeatureSet fs = p[run]->process(ptr, timestamp);
|
|
| 176 | 164 |
appendFeatures(f[run], fs); |
| 177 | 165 |
} |
| 178 | 166 |
} |
| ... | ... | |
| 182 | 170 |
delete p[run]; |
| 183 | 171 |
} |
| 184 | 172 |
|
| 185 |
if (block) destroyBlock(block, channels);
|
|
| 173 |
if (data) destroyTestAudio(data, channels);
|
|
| 186 | 174 |
|
| 187 | 175 |
if (!(f[0] == f[1])) {
|
| 188 |
r.push_back(warning("Consecutive runs with the same instance (using reset) produce different results"));
|
|
| 176 |
r.push_back(warning("Simultaneous runs with separate instances produce different results"));
|
|
| 189 | 177 |
} else {
|
| 190 | 178 |
r.push_back(success()); |
| 191 | 179 |
} |
Also available in: Unified diff