More reset tests, tighten up reset logic
This commit is contained in:
@@ -92,6 +92,17 @@ public:
|
|||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
|
while (m_vfQueue.getReadSpace() > 0) {
|
||||||
|
process_t *entry = m_vfQueue.readOne();
|
||||||
|
deallocate(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < m_parameters.horizontalFilterLag; ++i) {
|
||||||
|
process_t *entry =
|
||||||
|
allocate_and_zero<process_t>(m_parameters.binCount);
|
||||||
|
m_vfQueue.write(&entry, 1);
|
||||||
|
}
|
||||||
|
|
||||||
m_hFilters->reset();
|
m_hFilters->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -533,6 +533,7 @@ void
|
|||||||
R3Stretcher::reset()
|
R3Stretcher::reset()
|
||||||
{
|
{
|
||||||
m_calculator->reset();
|
m_calculator->reset();
|
||||||
|
|
||||||
if (m_resampler) {
|
if (m_resampler) {
|
||||||
m_resampler->reset();
|
m_resampler->reset();
|
||||||
}
|
}
|
||||||
@@ -545,6 +546,7 @@ R3Stretcher::reset()
|
|||||||
cd->reset();
|
cd->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_unityCount = 0;
|
||||||
m_studyInputDuration = 0;
|
m_studyInputDuration = 0;
|
||||||
m_suppliedInputDuration = 0;
|
m_suppliedInputDuration = 0;
|
||||||
m_totalTargetDuration = 0;
|
m_totalTargetDuration = 0;
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ protected:
|
|||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
v_zero(prevMag.data(), prevMag.size());
|
v_zero(prevMag.data(), prevMag.size());
|
||||||
|
v_zero(pendingKick.data(), pendingKick.size());
|
||||||
v_zero(accumulator.data(), accumulator.size());
|
v_zero(accumulator.data(), accumulator.size());
|
||||||
accumulatorFill = 0;
|
accumulatorFill = 0;
|
||||||
}
|
}
|
||||||
@@ -226,7 +227,7 @@ protected:
|
|||||||
std::unique_ptr<FormantData> formant;
|
std::unique_ptr<FormantData> formant;
|
||||||
ChannelData(BinSegmenter::Parameters segmenterParameters,
|
ChannelData(BinSegmenter::Parameters segmenterParameters,
|
||||||
BinClassifier::Parameters classifierParameters,
|
BinClassifier::Parameters classifierParameters,
|
||||||
int longestFftSize,
|
int /*!!! longestFftSize */,
|
||||||
int windowSourceSize,
|
int windowSourceSize,
|
||||||
int inRingBufferSize,
|
int inRingBufferSize,
|
||||||
int outRingBufferSize) :
|
int outRingBufferSize) :
|
||||||
@@ -252,6 +253,9 @@ protected:
|
|||||||
segmentation = BinSegmenter::Segmentation();
|
segmentation = BinSegmenter::Segmentation();
|
||||||
prevSegmentation = BinSegmenter::Segmentation();
|
prevSegmentation = BinSegmenter::Segmentation();
|
||||||
nextSegmentation = BinSegmenter::Segmentation();
|
nextSegmentation = BinSegmenter::Segmentation();
|
||||||
|
for (size_t i = 0; i < nextClassification.size(); ++i) {
|
||||||
|
nextClassification[i] = BinClassifier::Classification::Residual;
|
||||||
|
}
|
||||||
inbuf->reset();
|
inbuf->reset();
|
||||||
outbuf->reset();
|
outbuf->reset();
|
||||||
for (auto &s : scales) {
|
for (auto &s : scales) {
|
||||||
|
|||||||
@@ -1251,6 +1251,79 @@ BOOST_AUTO_TEST_CASE(final_fast_lower_realtime_finer_after)
|
|||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(impulses_2x_0up_offline_reset_finer)
|
||||||
|
{
|
||||||
|
int n = 10000;
|
||||||
|
int rate = 44100;
|
||||||
|
RubberBandStretcher stretcher
|
||||||
|
(rate, 1, RubberBandStretcher::OptionEngineFiner);
|
||||||
|
|
||||||
|
stretcher.setTimeRatio(2.0);
|
||||||
|
stretcher.setPitchScale(1.0);
|
||||||
|
|
||||||
|
vector<float> in(n, 0.f), out1(n * 2, 0.f), out2(n * 2, 0.f);
|
||||||
|
|
||||||
|
in[100] = 1.f;
|
||||||
|
in[101] = -1.f;
|
||||||
|
|
||||||
|
in[5000] = 1.f;
|
||||||
|
in[5001] = -1.f;
|
||||||
|
|
||||||
|
in[9900] = 1.f;
|
||||||
|
in[9901] = -1.f;
|
||||||
|
|
||||||
|
float *inp = in.data(), *outp1 = out1.data(), *outp2 = out2.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.getStartDelay() == 0); // offline mode
|
||||||
|
|
||||||
|
size_t got = stretcher.retrieve(&outp1, n * 2);
|
||||||
|
BOOST_TEST(got == n * 2);
|
||||||
|
BOOST_TEST(stretcher.available() == -1);
|
||||||
|
|
||||||
|
stretcher.reset();
|
||||||
|
|
||||||
|
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.getStartDelay() == 0); // offline mode
|
||||||
|
|
||||||
|
got = stretcher.retrieve(&outp2, n * 2);
|
||||||
|
BOOST_TEST(got == n * 2);
|
||||||
|
BOOST_TEST(stretcher.available() == -1);
|
||||||
|
|
||||||
|
for (int i = 0; i < n * 2; ++i) {
|
||||||
|
BOOST_TEST(outp1[i] == outp2[i]);
|
||||||
|
if (outp1[i] != outp2[i]) {
|
||||||
|
std::cerr << "Failure at index " << i << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "ms\tV" << std::endl;
|
||||||
|
for (int i = 0; i < n*2; ++i) {
|
||||||
|
std::cout << i << "\t" << out[i] << std::endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(impulses_2x_5up_offline_reset_finer)
|
BOOST_AUTO_TEST_CASE(impulses_2x_5up_offline_reset_finer)
|
||||||
{
|
{
|
||||||
int n = 10000;
|
int n = 10000;
|
||||||
@@ -1324,4 +1397,53 @@ BOOST_AUTO_TEST_CASE(impulses_2x_5up_offline_reset_finer)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(impulses_2x_5up_realtime_reset_finer)
|
||||||
|
{
|
||||||
|
int n = 10000;
|
||||||
|
int rate = 44100;
|
||||||
|
RubberBandStretcher stretcher
|
||||||
|
(rate, 1, RubberBandStretcher::OptionEngineFiner);
|
||||||
|
|
||||||
|
stretcher.setTimeRatio(2.0);
|
||||||
|
stretcher.setPitchScale(1.5);
|
||||||
|
|
||||||
|
vector<float> in(n, 0.f), out1(n * 2, 0.f), out2(n * 2, 0.f);
|
||||||
|
|
||||||
|
in[100] = 1.f;
|
||||||
|
in[101] = -1.f;
|
||||||
|
|
||||||
|
in[5000] = 1.f;
|
||||||
|
in[5001] = -1.f;
|
||||||
|
|
||||||
|
in[9900] = 1.f;
|
||||||
|
in[9901] = -1.f;
|
||||||
|
|
||||||
|
float *inp = in.data(), *outp1 = out1.data(), *outp2 = out2.data();
|
||||||
|
|
||||||
|
stretcher.process(&inp, n, true);
|
||||||
|
size_t got1 = stretcher.retrieve(&outp1, n * 2);
|
||||||
|
BOOST_TEST(got1 <= n * 2);
|
||||||
|
|
||||||
|
stretcher.reset();
|
||||||
|
|
||||||
|
stretcher.process(&inp, n, true);
|
||||||
|
size_t got2 = stretcher.retrieve(&outp2, n * 2);
|
||||||
|
BOOST_TEST(got2 == got1);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < got1; ++i) {
|
||||||
|
BOOST_TEST(outp1[i] == outp2[i]);
|
||||||
|
if (outp1[i] != outp2[i]) {
|
||||||
|
std::cerr << "Failure at index " << i << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::cout << "ms\tV" << std::endl;
|
||||||
|
for (int i = 0; i < n*2; ++i) {
|
||||||
|
std::cout << i << "\t" << out[i] << std::endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
Reference in New Issue
Block a user