Toward further tests
This commit is contained in:
@@ -378,8 +378,8 @@ R3Stretcher::getLatency() const
|
|||||||
if (!isRealTime()) {
|
if (!isRealTime()) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
double factor = m_pitchScale * 0.5;
|
return size_t(ceil(m_guideConfiguration.longestFftSize
|
||||||
return size_t(ceil(m_guideConfiguration.longestFftSize * factor));
|
* 0.5 * m_pitchScale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_single_offline_faster)
|
|||||||
// thing. It will have lower precision for a while at the start
|
// thing. It will have lower precision for a while at the start
|
||||||
// and end because of windowing factors, so we check those with a
|
// and end because of windowing factors, so we check those with a
|
||||||
// threshold of 0.1; in the middle we expect better
|
// threshold of 0.1; in the middle we expect better
|
||||||
// precision. Note that these are relative precisions, not
|
// precision. Note that these are relative tolerances, not
|
||||||
// absolute, i.e. 0.001 means 0.001 of the smaller value - so they
|
// absolute, i.e. 0.001 means 0.001x the smaller value - so they
|
||||||
// are tighter than they appear.
|
// are tighter than they appear.
|
||||||
|
|
||||||
// This syntax for comparing containers with a certain tolerance
|
// This syntax for comparing containers with a certain tolerance
|
||||||
@@ -84,11 +84,11 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_single_offline_faster)
|
|||||||
// you're comparing are floats (it sets the tolerance for doubles,
|
// you're comparing are floats (it sets the tolerance for doubles,
|
||||||
// leaving float comparison unchanged). Clever... too clever.
|
// leaving float comparison unchanged). Clever... too clever.
|
||||||
|
|
||||||
BOOST_TEST(in == out,
|
BOOST_TEST(out == in,
|
||||||
tt::tolerance(0.1f) << tt::per_element());
|
tt::tolerance(0.1f) << tt::per_element());
|
||||||
|
|
||||||
BOOST_TEST(vector<float>(in.begin() + 1024, in.begin() + n - 1024) ==
|
BOOST_TEST(vector<float>(out.begin() + 1024, out.begin() + n - 1024) ==
|
||||||
vector<float>(out.begin() + 1024, out.begin() + n - 1024),
|
vector<float>(in.begin() + 1024, in.begin() + n - 1024),
|
||||||
tt::tolerance(0.001f) << tt::per_element());
|
tt::tolerance(0.001f) << tt::per_element());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,11 +127,11 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_single_offline_finer)
|
|||||||
// its different windowing design, though see the note above about
|
// its different windowing design, though see the note above about
|
||||||
// what these tolerances mean
|
// what these tolerances mean
|
||||||
|
|
||||||
BOOST_TEST(in == out,
|
BOOST_TEST(out == in,
|
||||||
tt::tolerance(0.15f) << tt::per_element());
|
tt::tolerance(0.15f) << tt::per_element());
|
||||||
|
|
||||||
BOOST_TEST(vector<float>(in.begin() + 1024, in.begin() + n - 1024) ==
|
BOOST_TEST(vector<float>(out.begin() + 1024, out.begin() + n - 1024) ==
|
||||||
vector<float>(out.begin() + 1024, out.begin() + n - 1024),
|
vector<float>(in.begin() + 1024, in.begin() + n - 1024),
|
||||||
tt::tolerance(0.01f) << tt::per_element());
|
tt::tolerance(0.01f) << tt::per_element());
|
||||||
|
|
||||||
// std::cout << "ms\tV" << std::endl;
|
// std::cout << "ms\tV" << std::endl;
|
||||||
@@ -140,4 +140,77 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_single_offline_finer)
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NOT_YET
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(impulses_2_offline_faster)
|
||||||
|
{
|
||||||
|
int n = 10000;
|
||||||
|
float freq = 440.f;
|
||||||
|
int rate = 44100;
|
||||||
|
RubberBandStretcher stretcher
|
||||||
|
(rate, 1, RubberBandStretcher::OptionEngineFaster, 2.0, 1.0);
|
||||||
|
|
||||||
|
vector<float> in(n, 0.f), out(n * 2, 0.f);
|
||||||
|
|
||||||
|
in[0] = 1.f;
|
||||||
|
in[1] = -1.f;
|
||||||
|
|
||||||
|
in[4999] = 1.f;
|
||||||
|
in[5000] = -1.f;
|
||||||
|
|
||||||
|
in[9998] = 1.f;
|
||||||
|
in[9999] = -1.f;
|
||||||
|
|
||||||
|
float *inp = in.data(), *outp = out.data();
|
||||||
|
|
||||||
|
stretcher.setMaxProcessSize(n);
|
||||||
|
stretcher.setExpectedInputDuration(n);
|
||||||
|
BOOST_TEST(stretcher.available() == 0);
|
||||||
|
|
||||||
|
stretcher.study(&inp, n, true);
|
||||||
|
BOOST_TEST(stretcher.available() == 0);
|
||||||
|
|
||||||
|
stretcher.process(&inp, n, true);
|
||||||
|
BOOST_TEST(stretcher.available() == n * 2);
|
||||||
|
|
||||||
|
BOOST_TEST(stretcher.getLatency() == 0); // offline mode
|
||||||
|
|
||||||
|
size_t got = stretcher.retrieve(&outp, n * 2);
|
||||||
|
BOOST_TEST(got == n * 2);
|
||||||
|
BOOST_TEST(stretcher.available() == -1);
|
||||||
|
|
||||||
|
float max;
|
||||||
|
int peak0, peak1, peak2;
|
||||||
|
|
||||||
|
for (int i = 0, max = -2.f; i < n/2; ++i) {
|
||||||
|
if (out[i] > max) {
|
||||||
|
max = out[i];
|
||||||
|
peak0 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = n/2, max = -2.f; i < (n*3)/2; ++i) {
|
||||||
|
if (out[i] > max) {
|
||||||
|
max = out[i];
|
||||||
|
peak1 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = (n*3)/2, max = -2.f; i < n*2; ++i) {
|
||||||
|
if (out[i] > max) {
|
||||||
|
max = out[i];
|
||||||
|
peak2 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TEST(peak0 == 0);
|
||||||
|
BOOST_TEST(peak1 == n - 1);
|
||||||
|
BOOST_TEST(peak2 == n*2 - 2);
|
||||||
|
|
||||||
|
std::cout << "ms\tV" << std::endl;
|
||||||
|
for (int i = 0; i < n*2; ++i) {
|
||||||
|
std::cout << i << "\t" << out[i] << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
Reference in New Issue
Block a user