Skip to content

Commit

Permalink
Fixed slow waterfall with low sample rates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzerth committed Jul 20, 2020
1 parent ed49ad6 commit f5d6e60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/dsp/resampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ namespace dsp {
if (running) {
return;
}
if (blockSize < 1 ) {
return;
}
_blockSize = blockSize;
output.setMaxLatency(blockSize * 2);
}
Expand All @@ -159,9 +156,6 @@ namespace dsp {
if (running) {
return;
}
if (skip < 0 ) {
skip = 0;
}
_skip = skip;
}

Expand All @@ -170,9 +164,20 @@ namespace dsp {
private:
static void _worker(BlockDecimator* _this) {
complex_t* buf = new complex_t[_this->_blockSize];
bool delay = _this->_skip < 0;

int readCount = std::min<int>(_this->_blockSize + _this->_skip, _this->_blockSize);
int skip = std::max<int>(_this->_skip, 0);
int delaySize = (-_this->_skip) * sizeof(complex_t);

complex_t* start = &buf[std::max<int>(-_this->_skip, 0)];
complex_t* delayStart = &buf[_this->_blockSize + _this->_skip];

while (true) {
int read = _this->_input->readAndSkip(buf, _this->_blockSize, _this->_skip);
if (read < 0) { break; };
if (delay) {
memmove(buf, delayStart, delaySize);
}
if (_this->_input->readAndSkip(start, readCount, skip) < 0) { break; };
if (_this->output.write(buf, _this->_blockSize) < 0) { break; };
}
delete[] buf;
Expand Down
3 changes: 2 additions & 1 deletion src/signal_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void SignalPath::setSampleRate(float sampleRate) {

dcBiasRemover.setBlockSize(inputBlockSize);
split.setBlockSize(inputBlockSize);
fftBlockDec.setSkip((sampleRate / fftRate) - fftSize);
int skip = (sampleRate / fftRate) - fftSize;
fftBlockDec.setSkip(skip);
mainVFO.setInputSampleRate(sampleRate, inputBlockSize);

// // Reset the modulator and audio systems
Expand Down

0 comments on commit f5d6e60

Please sign in to comment.