diff --git a/core/src/dsp/correction.h b/core/src/dsp/correction.h index 3c50458c..d785a320 100644 --- a/core/src/dsp/correction.h +++ b/core/src/dsp/correction.h @@ -64,7 +64,7 @@ namespace dsp { stream out; // TEMPORARY FOR DEBUG PURPOSES - bool bypass = true; + bool bypass = false; complex_t offset; private: diff --git a/core/src/gui/menus/display.cpp b/core/src/gui/menus/display.cpp index e42cd5b0..1e03e7bc 100644 --- a/core/src/gui/menus/display.cpp +++ b/core/src/gui/menus/display.cpp @@ -108,7 +108,7 @@ namespace displaymenu { ImGui::SameLine(); ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) { - std::clamp(fftRate, 1, 200); + fftRate = std::max(1, fftRate); sigpath::signalPath.setFFTRate(fftRate); core::configManager.acquire(); core::configManager.conf["fftRate"] = fftRate; diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index f33c12db..7d3e6d41 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -362,7 +362,7 @@ namespace ImGui { // If the mouse wheel is moved on the frequency scale if (mouseWheel != 0 && mouseInFreq) { - viewOffset -= (double)mouseWheel * viewBandwidth / 20.0; + viewOffset -= (double)mouseWheel * viewBandwidth / 20.0; if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) { double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0); diff --git a/core/src/signal_path/dsp.cpp b/core/src/signal_path/dsp.cpp index 15a30781..269a4f0d 100644 --- a/core/src/signal_path/dsp.cpp +++ b/core/src/signal_path/dsp.cpp @@ -16,8 +16,8 @@ void SignalPath::init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream // split.init(input); inputBuffer.init(input); - corrector.init(&inputBuffer.out, 100.0f / sampleRate); - split.init(&corrector.out); + corrector.init(&inputBuffer.out, 50.0f / sampleRate); + split.init(&inputBuffer.out); reshape.init(&fftStream, fftSize, (sampleRate / fftRate) - fftSize); split.bindStream(&fftStream); @@ -44,7 +44,7 @@ void SignalPath::setSampleRate(double sampleRate) { vfo.vfo->start(); } - corrector.setCorrectionRate(100.0f / sampleRate); + corrector.setCorrectionRate(50.0f / sampleRate); split.start(); } @@ -58,7 +58,7 @@ void SignalPath::start() { decimator->start(); } inputBuffer.start(); - corrector.start(); + if (iqCorrection) { corrector.start(); } split.start(); reshape.start(); fftHandlerSink.start(); @@ -70,7 +70,7 @@ void SignalPath::stop() { decimator->stop(); } inputBuffer.stop(); - corrector.stop(); + if (iqCorrection) { corrector.stop(); } split.stop(); reshape.stop(); fftHandlerSink.stop(); @@ -164,7 +164,13 @@ void SignalPath::setDecimation(int dec) { // If no decimation, reconnect if (!dec) { - split.setInput(&corrector.out); + if (iqCorrection) { + split.setInput(&corrector.out); + } + else { + split.setInput(&inputBuffer.out); + } + if (running) { split.start(); } core::setInputSampleRate(sourceSampleRate); return; @@ -172,7 +178,17 @@ void SignalPath::setDecimation(int dec) { // Create new decimators for (int i = 0; i < dec; i++) { - dsp::HalfDecimator* decimator = new dsp::HalfDecimator((i == 0) ? &corrector.out : &decimators[i-1]->out, &halfBandWindow); + dsp::HalfDecimator* decimator; + if (iqCorrection && i == 0) { + decimator = new dsp::HalfDecimator(&corrector.out, &halfBandWindow); + } + else if (i == 0) { + decimator = new dsp::HalfDecimator(&inputBuffer.out, &halfBandWindow); + } + else { + decimator = new dsp::HalfDecimator(&decimators[i-1]->out, &halfBandWindow); + } + if (running) { decimator->start(); } decimators.push_back(decimator); } @@ -184,7 +200,28 @@ void SignalPath::setDecimation(int dec) { } void SignalPath::setIQCorrection(bool enabled) { - corrector.bypass = !enabled; + if (iqCorrection == enabled) { return; } + + if (!iqCorrection && enabled) { + if (decimation) { + decimators[0]->setInput(&corrector.out); + } + else { + split.setInput(&corrector.out); + } + if (running) { corrector.start(); } + } + else if (iqCorrection && !enabled) { + if (running) { corrector.stop(); } + if (decimation) { + decimators[0]->setInput(&inputBuffer.out); + } + else { + split.setInput(&inputBuffer.out); + } + } + + iqCorrection = enabled; if (!enabled) { corrector.offset.re = 0; corrector.offset.im = 0; diff --git a/core/src/signal_path/dsp.h b/core/src/signal_path/dsp.h index cf6f2afc..5f122213 100644 --- a/core/src/signal_path/dsp.h +++ b/core/src/signal_path/dsp.h @@ -56,4 +56,5 @@ private: int inputBlockSize; bool bufferingEnabled = false; bool running = false; + bool iqCorrection = false; }; \ No newline at end of file