Implement setMaxProcessSize in R3

This commit is contained in:
Chris Cannam
2022-06-24 14:01:11 +01:00
parent 9c04885d27
commit b9e6ebb6e3
3 changed files with 22 additions and 3 deletions

View File

@@ -206,7 +206,8 @@ public:
void
setMaxProcessSize(size_t samples)
{
if (m_r2) m_r2->setMaxProcessSize(samples); //!!! definitely need for r3d
if (m_r2) m_r2->setMaxProcessSize(samples);
else m_r3->setMaxProcessSize(samples);
}
void

View File

@@ -452,6 +452,23 @@ R3Stretcher::getSamplesRequired() const
}
}
void
R3Stretcher::setMaxProcessSize(size_t n)
{
size_t oldSize = m_channelData[0]->inbuf->getSize();
size_t newSize = m_guideConfiguration.longestFftSize + n;
if (newSize > oldSize) {
m_log.log(1, "setMaxProcessSize: resizing from and to", oldSize, newSize);
for (int c = 0; c < m_parameters.channels; ++c) {
m_channelData[c]->inbuf = std::unique_ptr<RingBuffer<float>>
(m_channelData[c]->inbuf->resized(newSize));
}
} else {
m_log.log(1, "setMaxProcessSize: nothing to be done, newSize <= oldSize", newSize, oldSize);
}
}
void
R3Stretcher::process(const float *const *input, size_t samples, bool final)
{
@@ -505,8 +522,7 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final)
size_t ws = m_channelData[0]->inbuf->getWriteSpace();
if (samples > ws) {
//!!! check this
m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve.");
m_log.log(0, "R3Stretcher::process: WARNING: Forced to increase input buffer size. Either setMaxProcessSize was not properly called or process is being called repeatedly without retrieve. Write space and samples", ws, samples);
size_t newSize = m_channelData[0]->inbuf->getSize() - ws + samples;
for (int c = 0; c < m_parameters.channels; ++c) {
auto newBuf = m_channelData[c]->inbuf->resized(newSize);

View File

@@ -86,6 +86,8 @@ public:
size_t getLatency() const;
size_t getChannelCount() const;
void setMaxProcessSize(size_t samples);
void setDebugLevel(int level) {
m_log.setDebugLevel(level);