mirror of
				https://github.com/AlexandreRouma/SDRPlusPlus.git
				synced 2025-10-31 00:48:11 +01:00 
			
		
		
		
	Improved performance of DC correction
This commit is contained in:
		| @@ -64,7 +64,7 @@ namespace dsp { | ||||
|         stream<complex_t> out; | ||||
|  | ||||
|         // TEMPORARY FOR DEBUG PURPOSES | ||||
|         bool bypass = true; | ||||
|         bool bypass = false; | ||||
|         complex_t offset; | ||||
|  | ||||
|     private: | ||||
|   | ||||
| @@ -108,7 +108,7 @@ namespace displaymenu { | ||||
|         ImGui::SameLine(); | ||||
|         ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); | ||||
|         if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) { | ||||
|             std::clamp<int>(fftRate, 1, 200); | ||||
|             fftRate = std::max<int>(1, fftRate); | ||||
|             sigpath::signalPath.setFFTRate(fftRate); | ||||
|             core::configManager.acquire(); | ||||
|             core::configManager.conf["fftRate"] = fftRate; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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<dsp::complex_t>* decimator = new dsp::HalfDecimator<dsp::complex_t>((i == 0) ? &corrector.out : &decimators[i-1]->out, &halfBandWindow); | ||||
|         dsp::HalfDecimator<dsp::complex_t>* decimator; | ||||
|         if (iqCorrection && i == 0) { | ||||
|             decimator = new dsp::HalfDecimator<dsp::complex_t>(&corrector.out, &halfBandWindow); | ||||
|         } | ||||
|         else if (i == 0) { | ||||
|             decimator = new dsp::HalfDecimator<dsp::complex_t>(&inputBuffer.out, &halfBandWindow); | ||||
|         } | ||||
|         else { | ||||
|             decimator = new dsp::HalfDecimator<dsp::complex_t>(&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; | ||||
|   | ||||
| @@ -56,4 +56,5 @@ private: | ||||
|     int inputBlockSize; | ||||
|     bool bufferingEnabled = false; | ||||
|     bool running = false; | ||||
|     bool iqCorrection = false; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user