From 5d320fdd53bbfba6755f7f1a316471e59c047089 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Tue, 3 Nov 2020 19:22:53 +0100 Subject: [PATCH] Fixes --- core/src/dsp/block.h | 2 +- core/src/dsp/resampling.h | 31 +++++++++++++++---------------- soapy/src/main.cpp | 3 +-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/core/src/dsp/block.h b/core/src/dsp/block.h index 318da8a1..090f1aee 100644 --- a/core/src/dsp/block.h +++ b/core/src/dsp/block.h @@ -69,7 +69,7 @@ namespace dsp { } virtual void doStart() { - workerThread = std::thread(&generic_block::workerLoop, this); + workerThread = std::thread(&generic_block::workerLoop, this); } virtual void doStop() { diff --git a/core/src/dsp/resampling.h b/core/src/dsp/resampling.h index 02da3c26..2c88504c 100644 --- a/core/src/dsp/resampling.h +++ b/core/src/dsp/resampling.h @@ -92,6 +92,7 @@ namespace dsp { taps[tapCount - i - 1] = taps[i] * (float)_interp; taps[i] = tap * (float)_interp; } + bufStart = &buffer[tapCount]; generic_block>::tempStart(); } @@ -99,7 +100,7 @@ namespace dsp { return (in * _interp) / _decim; } - int run() { + virtual int run() override { count = _in->read(); if (count < 0) { return -1; @@ -107,7 +108,7 @@ namespace dsp { int outCount = calcOutSize(count); - memcpy(bufStart, _in->data, count * sizeof(T)); + memcpy(&buffer[tapCount], _in->data, count * sizeof(T)); _in->flush(); // Write to output @@ -115,21 +116,19 @@ namespace dsp { return -1; } int outIndex = 0; - // if constexpr (std::is_same_v) { - // // for (int i = 0; outIndex < outCount; i += _decim) { - // // out.data[outIndex] = 0; - // // for (int j = i % _interp; j < tapCount; j += _interp) { - // // out.data[outIndex] += buffer[((i - j) / _interp) + tapCount] * taps[j]; - // // } - // // outIndex++; - // // } - // for (int i = 0; i < outCount; i++) { - // out.data[i] = 1.0f; - // } - // } + if constexpr (std::is_same_v) { + for (int i = 0; i < count; i++) { + buffer[tapCount + i] = 1.0f; + } + for (int i = 0; outIndex < outCount; i += _decim) { + out.data[outIndex] = 0; + for (int j = i % _interp; j < tapCount; j += _interp) { + out.data[outIndex] += buffer[((i - j) / _interp) + tapCount] * taps[j]; + } + outIndex++; + } + } if constexpr (std::is_same_v) { - static_assert(std::is_same_v); - spdlog::warn("{0}", outCount); for (int i = 0; outIndex < outCount; i += _decim) { out.data[outIndex].i = 0; out.data[outIndex].q = 0; diff --git a/soapy/src/main.cpp b/soapy/src/main.cpp index 81ded3b5..027f7df8 100644 --- a/soapy/src/main.cpp +++ b/soapy/src/main.cpp @@ -287,7 +287,6 @@ private: } static void _worker(SoapyModule* _this) { - spdlog::info("SOAPY: WORKER STARTED {0}", _this->sampleRate); int blockSize = _this->sampleRate / 200.0f; int flags = 0; long long timeMs = 0; @@ -297,7 +296,7 @@ private: int res = _this->dev->readStream(_this->devStream, (void**)&_this->stream.data, blockSize, flags, timeMs); if (res < 1) { continue; - } + } _this->stream.write(res); } }