Added IQ correction

This commit is contained in:
Ryzerth 2021-07-27 23:50:48 +02:00
parent 5f29350dd1
commit 679fb49743
4 changed files with 30 additions and 3 deletions

View File

@ -206,6 +206,7 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["showWaterfall"] = true;
defConfig["source"] = "";
defConfig["decimationPower"] = 0;
defConfig["iqCorrection"] = false;
defConfig["streams"]["Radio"]["muted"] = false;
defConfig["streams"]["Radio"]["sink"] = "Audio";

View File

@ -12,6 +12,7 @@ namespace sourecmenu {
double customOffset = 0.0;
double effectiveOffset = 0.0;
int decimationPower = 0;
bool iqCorrection = false;
EventHandler<std::string> sourceRegisteredHandler;
EventHandler<std::string> sourceUnregisterHandler;
@ -124,6 +125,8 @@ namespace sourecmenu {
customOffset = core::configManager.conf["offset"];
offsetMode = core::configManager.conf["offsetMode"];
decimationPower = core::configManager.conf["decimationPower"];
iqCorrection = core::configManager.conf["iqCorrection"];
sigpath::signalPath.setIQCorrection(iqCorrection);
updateOffset();
refreshSources();
@ -158,6 +161,13 @@ namespace sourecmenu {
sigpath::sourceManager.showSelectedMenu();
if (ImGui::Checkbox("IQ Correction##_sdrpp_iq_corr", &iqCorrection)) {
sigpath::signalPath.setIQCorrection(iqCorrection);
core::configManager.acquire();
core::configManager.conf["iqCorrection"] = iqCorrection;
core::configManager.release(true);
}
ImGui::Text("Offset mode");
ImGui::SameLine();
ImGui::SetNextItemWidth(itemWidth - ImGui::GetCursorPosX());

View File

@ -16,7 +16,8 @@ void SignalPath::init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream
// split.init(input);
inputBuffer.init(input);
split.init(&inputBuffer.out);
corrector.init(&inputBuffer.out, 100.0f / sampleRate);
split.init(&corrector.out);
reshape.init(&fftStream, fftSize, (sampleRate / fftRate) - fftSize);
split.bindStream(&fftStream);
@ -43,6 +44,8 @@ void SignalPath::setSampleRate(double sampleRate) {
vfo.vfo->start();
}
corrector.setCorrectionRate(100.0f / sampleRate);
split.start();
}
@ -55,6 +58,7 @@ void SignalPath::start() {
decimator->start();
}
inputBuffer.start();
corrector.start();
split.start();
reshape.start();
fftHandlerSink.start();
@ -66,6 +70,7 @@ void SignalPath::stop() {
decimator->stop();
}
inputBuffer.stop();
corrector.stop();
split.stop();
reshape.stop();
fftHandlerSink.stop();
@ -159,7 +164,7 @@ void SignalPath::setDecimation(int dec) {
// If no decimation, reconnect
if (!dec) {
split.setInput(&inputBuffer.out);
split.setInput(&corrector.out);
if (running) { split.start(); }
core::setInputSampleRate(sourceSampleRate);
return;
@ -167,7 +172,7 @@ 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) ? &inputBuffer.out : &decimators[i-1]->out, &halfBandWindow);
dsp::HalfDecimator<dsp::complex_t>* decimator = new dsp::HalfDecimator<dsp::complex_t>((i == 0) ? &corrector.out : &decimators[i-1]->out, &halfBandWindow);
if (running) { decimator->start(); }
decimators.push_back(decimator);
}
@ -177,3 +182,11 @@ void SignalPath::setDecimation(int dec) {
// Update the DSP sample rate
core::setInputSampleRate(sourceSampleRate);
}
void SignalPath::setIQCorrection(bool enabled) {
corrector.bypass = !enabled;
if (!enabled) {
corrector.offset.re = 0;
corrector.offset.im = 0;
}
}

View File

@ -4,6 +4,7 @@
#include <map>
#include <dsp/sink.h>
#include <dsp/decimation.h>
#include <dsp/correction.h>
class SignalPath {
public:
@ -24,6 +25,7 @@ public:
void stopFFT();
void setBuffering(bool enabled);
void setDecimation(int dec);
void setIQCorrection(bool enabled);
dsp::SampleFrameBuffer<dsp::complex_t> inputBuffer;
double sourceSampleRate = 0;
@ -36,6 +38,7 @@ private:
};
dsp::Splitter<dsp::complex_t> split;
dsp::IQCorrector corrector;
// FFT
dsp::stream<dsp::complex_t> fftStream;