Wire up setExpectedInputDuration

This commit is contained in:
Chris Cannam
2022-07-07 10:54:23 +01:00
parent 263e0cbf70
commit dca4c96834
3 changed files with 19 additions and 2 deletions

View File

@@ -216,7 +216,7 @@ public:
setExpectedInputDuration(size_t samples) setExpectedInputDuration(size_t samples)
{ {
if (m_r2) m_r2->setExpectedInputDuration(samples); if (m_r2) m_r2->setExpectedInputDuration(samples);
//!!! perhaps also for R3 else m_r3->setExpectedInputDuration(samples);
} }
void void

View File

@@ -47,6 +47,7 @@ R3Stretcher::R3Stretcher(Parameters parameters,
m_unityCount(0), m_unityCount(0),
m_startSkip(0), m_startSkip(0),
m_studyInputDuration(0), m_studyInputDuration(0),
m_suppliedInputDuration(0),
m_totalTargetDuration(0), m_totalTargetDuration(0),
m_consumedInputDuration(0), m_consumedInputDuration(0),
m_lastKeyFrameSurpassed(0), m_lastKeyFrameSurpassed(0),
@@ -449,6 +450,7 @@ R3Stretcher::reset()
m_prevOuthop = int(round(m_inhop * getEffectiveRatio())); m_prevOuthop = int(round(m_inhop * getEffectiveRatio()));
m_studyInputDuration = 0; m_studyInputDuration = 0;
m_suppliedInputDuration = 0;
m_totalTargetDuration = 0; m_totalTargetDuration = 0;
m_consumedInputDuration = 0; m_consumedInputDuration = 0;
m_lastKeyFrameSurpassed = 0; m_lastKeyFrameSurpassed = 0;
@@ -479,6 +481,12 @@ R3Stretcher::study(const float *const *, size_t samples, bool)
m_studyInputDuration += samples; m_studyInputDuration += samples;
} }
void
R3Stretcher::setExpectedInputDuration(size_t samples)
{
m_suppliedInputDuration = samples;
}
size_t size_t
R3Stretcher::getSamplesRequired() const R3Stretcher::getSamplesRequired() const
{ {
@@ -524,6 +532,13 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final)
size_t(round(m_studyInputDuration * m_timeRatio)); size_t(round(m_studyInputDuration * m_timeRatio));
m_log.log(1, "study duration and target duration", m_log.log(1, "study duration and target duration",
m_studyInputDuration, m_totalTargetDuration); m_studyInputDuration, m_totalTargetDuration);
} else if (m_mode == ProcessMode::JustCreated) {
if (m_suppliedInputDuration != 0) {
m_totalTargetDuration =
size_t(round(m_suppliedInputDuration * m_timeRatio));
m_log.log(1, "supplied duration and target duration",
m_suppliedInputDuration, m_totalTargetDuration);
}
} }
// Update this on every process round, checking whether we've // Update this on every process round, checking whether we've

View File

@@ -90,6 +90,7 @@ public:
size_t getChannelCount() const; size_t getChannelCount() const;
void setExpectedInputDuration(size_t samples);
void setMaxProcessSize(size_t samples); void setMaxProcessSize(size_t samples);
void setDebugLevel(int level) { void setDebugLevel(int level) {
@@ -303,6 +304,7 @@ protected:
int m_startSkip; int m_startSkip;
size_t m_studyInputDuration; size_t m_studyInputDuration;
size_t m_suppliedInputDuration;
size_t m_totalTargetDuration; size_t m_totalTargetDuration;
size_t m_consumedInputDuration; size_t m_consumedInputDuration;
size_t m_lastKeyFrameSurpassed; size_t m_lastKeyFrameSurpassed;