From 91176c929151d875a70d2664d7063cde3de60e89 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sun, 18 Apr 2021 00:47:23 +0200 Subject: [PATCH] =?UTF-8?q?More=20fixes=20to=20wf=C3=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/dsp/resampling.h | 50 +++++++++++++++--------------- core/src/gui/widgets/waterfall.cpp | 3 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/core/src/dsp/resampling.h b/core/src/dsp/resampling.h index 42a36032..32041b73 100644 --- a/core/src/dsp/resampling.h +++ b/core/src/dsp/resampling.h @@ -103,35 +103,35 @@ namespace dsp { return -1; } - generic_block>::ctrlMtx.lock(); + { + std::lock_guard lck(ctrlMtx); + int outCount = calcOutSize(count); + memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T)); + _in->flush(); - int outCount = calcOutSize(count); - - memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T)); - _in->flush(); - - // Write to output - int outIndex = 0; - int _interp_m_1 = _interp - 1; - if constexpr (std::is_same_v) { - for (int i = 0; outIndex < outCount; i += _decim) { - int phase = i % _interp; - volk_32f_x2_dot_prod_32f(&out.writeBuf[outIndex], &buffer[i / _interp], tapPhases[phase], tapsPerPhase); - outIndex++; + // Write to output + int outIndex = 0; + int _interp_m_1 = _interp - 1; + if constexpr (std::is_same_v) { + for (int i = 0; outIndex < outCount; i += _decim) { + int phase = i % _interp; + volk_32f_x2_dot_prod_32f(&out.writeBuf[outIndex], &buffer[i / _interp], tapPhases[phase], tapsPerPhase); + outIndex++; + } } - } - if constexpr (std::is_same_v || std::is_same_v) { - for (int i = 0; outIndex < outCount; i += _decim) { - int phase = i % _interp; - volk_32fc_32f_dot_prod_32fc((lv_32fc_t*)&out.writeBuf[outIndex], (lv_32fc_t*)&buffer[(i / _interp)], tapPhases[phase], tapsPerPhase); - outIndex++; + if constexpr (std::is_same_v || std::is_same_v) { + for (int i = 0; outIndex < outCount; i += _decim) { + int phase = i % _interp; + volk_32fc_32f_dot_prod_32fc((lv_32fc_t*)&out.writeBuf[outIndex], (lv_32fc_t*)&buffer[(i / _interp)], tapPhases[phase], tapsPerPhase); + outIndex++; + } } + if (!out.swap(outCount)) { + return -1; + } + + memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T)); } - if (!out.swap(outCount)) { return -1; } - - memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T)); - - generic_block>::ctrlMtx.unlock(); return count; } diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index c25ec1e6..8daa76e3 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -317,7 +317,8 @@ namespace ImGui { // If a vfo border is selected, resize VFO accordingly if (vfoBorderSelect) { - double dist = fabsf(mousePos.x - relatedVfo->lineMin.x); + double dist = (relatedVfo->reference == REF_CENTER) ? fabsf(mousePos.x - relatedVfo->lineMin.x) : (mousePos.x - relatedVfo->lineMin.x); + if (relatedVfo->reference == REF_UPPER) { dist = -dist; } double hzDist = dist * (viewBandwidth / (double)dataWidth); if (relatedVfo->reference == REF_CENTER) { hzDist *= 2.0;