Fix the consume logic so that it actually completes (though wrongly still, at this point)
This commit is contained in:
@@ -86,6 +86,12 @@ R3StretcherImpl::process(const float *const *input, size_t samples, bool final)
|
|||||||
{
|
{
|
||||||
//!!! todo: final
|
//!!! todo: final
|
||||||
|
|
||||||
|
m_parameters.logger("process called");
|
||||||
|
if (final) {
|
||||||
|
m_parameters.logger("final = true");
|
||||||
|
m_draining = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool allConsumed = false;
|
bool allConsumed = false;
|
||||||
|
|
||||||
size_t ws = m_channelData[0]->inbuf->getWriteSpace();
|
size_t ws = m_channelData[0]->inbuf->getWriteSpace();
|
||||||
@@ -110,12 +116,16 @@ R3StretcherImpl::process(const float *const *input, size_t samples, bool final)
|
|||||||
int
|
int
|
||||||
R3StretcherImpl::available() const
|
R3StretcherImpl::available() const
|
||||||
{
|
{
|
||||||
return int(m_channelData[0]->outbuf->getReadSpace());
|
m_parameters.logger("available called");
|
||||||
|
int av = int(m_channelData[0]->outbuf->getReadSpace());
|
||||||
|
if (av == 0 && m_draining) return -1;
|
||||||
|
else return av;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
R3StretcherImpl::retrieve(float *const *output, size_t samples) const
|
R3StretcherImpl::retrieve(float *const *output, size_t samples) const
|
||||||
{
|
{
|
||||||
|
m_parameters.logger("retrieve called");
|
||||||
size_t got = samples;
|
size_t got = samples;
|
||||||
|
|
||||||
for (size_t c = 0; c < m_parameters.channels; ++c) {
|
for (size_t c = 0; c < m_parameters.channels; ++c) {
|
||||||
@@ -140,7 +150,7 @@ R3StretcherImpl::consume()
|
|||||||
int longest = m_guideConfiguration.longestFftSize;
|
int longest = m_guideConfiguration.longestFftSize;
|
||||||
int classify = m_guideConfiguration.classificationFftSize;
|
int classify = m_guideConfiguration.classificationFftSize;
|
||||||
|
|
||||||
while (m_channelData[0]->inbuf->getReadSpace() >= longest &&
|
while ((m_draining || m_channelData[0]->inbuf->getReadSpace() >= longest) &&
|
||||||
m_channelData[0]->outbuf->getWriteSpace() >= outhop) {
|
m_channelData[0]->outbuf->getWriteSpace() >= outhop) {
|
||||||
|
|
||||||
m_parameters.logger("consume looping");
|
m_parameters.logger("consume looping");
|
||||||
@@ -150,7 +160,7 @@ R3StretcherImpl::consume()
|
|||||||
auto cd = m_channelData[c];
|
auto cd = m_channelData[c];
|
||||||
auto longestScale = cd->scales.at(longest);
|
auto longestScale = cd->scales.at(longest);
|
||||||
|
|
||||||
cd->inbuf->read(longestScale->timeDomainFrame.data(), longest);
|
cd->inbuf->peek(longestScale->timeDomainFrame.data(), longest);
|
||||||
|
|
||||||
for (auto it: cd->scales) {
|
for (auto it: cd->scales) {
|
||||||
int fftSize = it.first;
|
int fftSize = it.first;
|
||||||
@@ -227,6 +237,7 @@ R3StretcherImpl::consume()
|
|||||||
// copy to prevMag before filtering
|
// copy to prevMag before filtering
|
||||||
v_copy(scale->prevMag.data(), scale->mag.data(), bufSize);
|
v_copy(scale->prevMag.data(), scale->mag.data(), bufSize);
|
||||||
v_copy(scale->prevOutPhase.data(), scale->outPhase.data(), bufSize);
|
v_copy(scale->prevOutPhase.data(), scale->outPhase.data(), bufSize);
|
||||||
|
//!!! seems wasteful
|
||||||
for (int i = 0; i < bufSize; ++i) {
|
for (int i = 0; i < bufSize; ++i) {
|
||||||
scale->phase[i] = princarg(scale->outPhase[i]);
|
scale->phase[i] = princarg(scale->outPhase[i]);
|
||||||
}
|
}
|
||||||
@@ -244,6 +255,7 @@ R3StretcherImpl::consume()
|
|||||||
scaleData->fft.inversePolar(scale->mag.data(),
|
scaleData->fft.inversePolar(scale->mag.data(),
|
||||||
scale->phase.data(),
|
scale->phase.data(),
|
||||||
scale->timeDomainFrame.data());
|
scale->timeDomainFrame.data());
|
||||||
|
/*
|
||||||
int synthesisWindowSize = scaleData->synthesisWindow.getSize();
|
int synthesisWindowSize = scaleData->synthesisWindow.getSize();
|
||||||
int fromOffset = (fftSize - synthesisWindowSize) / 2;
|
int fromOffset = (fftSize - synthesisWindowSize) / 2;
|
||||||
int toOffset = (longest - synthesisWindowSize) / 2;
|
int toOffset = (longest - synthesisWindowSize) / 2;
|
||||||
@@ -251,6 +263,12 @@ R3StretcherImpl::consume()
|
|||||||
scaleData->synthesisWindow.cutAndAdd
|
scaleData->synthesisWindow.cutAndAdd
|
||||||
(scale->timeDomainFrame.data() + fromOffset,
|
(scale->timeDomainFrame.data() + fromOffset,
|
||||||
scale->accumulator.data() + toOffset);
|
scale->accumulator.data() + toOffset);
|
||||||
|
*/
|
||||||
|
int synthesisWindowSize = scaleData->synthesisWindow.getSize();
|
||||||
|
int offset = (fftSize - synthesisWindowSize) / 2;
|
||||||
|
scaleData->synthesisWindow.cutAndAdd
|
||||||
|
(scale->timeDomainFrame.data() + offset,
|
||||||
|
scale->accumulator.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ public:
|
|||||||
m_guide(Guide::Parameters(m_parameters.sampleRate)),
|
m_guide(Guide::Parameters(m_parameters.sampleRate)),
|
||||||
m_guideConfiguration(m_guide.getConfiguration()),
|
m_guideConfiguration(m_guide.getConfiguration()),
|
||||||
m_channelAssembly(m_parameters.channels),
|
m_channelAssembly(m_parameters.channels),
|
||||||
m_troughPicker(m_guideConfiguration.classificationFftSize / 2 + 1)
|
m_troughPicker(m_guideConfiguration.classificationFftSize / 2 + 1),
|
||||||
|
m_draining(false)
|
||||||
{
|
{
|
||||||
BinSegmenter::Parameters segmenterParameters
|
BinSegmenter::Parameters segmenterParameters
|
||||||
(m_guideConfiguration.classificationFftSize,
|
(m_guideConfiguration.classificationFftSize,
|
||||||
@@ -197,6 +198,7 @@ protected:
|
|||||||
Guide::Configuration m_guideConfiguration;
|
Guide::Configuration m_guideConfiguration;
|
||||||
ChannelAssembly m_channelAssembly;
|
ChannelAssembly m_channelAssembly;
|
||||||
Peak<float, std::less<float>> m_troughPicker;
|
Peak<float, std::less<float>> m_troughPicker;
|
||||||
|
bool m_draining;
|
||||||
|
|
||||||
void consume();
|
void consume();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user