Skip to content

Commit

Permalink
Hack to keep resampler from crashing despite fp error accumulation; b…
Browse files Browse the repository at this point in the history
…etter fix coming later. (#14)
  • Loading branch information
sdatkinson authored Apr 3, 2024
1 parent 7fc7d9a commit 2df2048
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dsp/ResamplingContainer/ResamplingContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,14 @@ class ResamplingContainer
const auto populated2 = mResampler2->PopBlock(outputs, nFrames);
if (populated2 < nFrames)
{
throw std::runtime_error("Did not yield enough samples to provide the required output buffer!");
std::cerr << "Did not yield enough samples (" << populated2 << ") to provide the required output buffer (expected"
<< nFrames << ")! Filling with last sample..." << std::endl;
for (int c = 0; c < NCHANS; c++) {
const T lastSample = populated2 > 0 ? outputs[c][populated2 - 1] : 0.0;
for (int i = populated2; i < nFrames; i++) {
outputs[c][i] = lastSample;
}
}
}
// Get ready for the next block:
mResampler1->RenormalizePhases();
Expand Down

0 comments on commit 2df2048

Please sign in to comment.