From 4415e38d31983df745394aa2381c0c9d3fe55782 Mon Sep 17 00:00:00 2001 From: "jvde.github" Date: Thu, 3 Nov 2022 18:39:45 +0100 Subject: [PATCH] release v0.39 --- DSP/Demod.cpp | 68 ++++++++++++++++++++++---------------------- Device/AIRSPY.cpp | 3 -- Device/AIRSPYHF.cpp | 2 -- Device/RTLSDR.cpp | 1 - Device/RTLTCP.cpp | 1 - Device/SpyServer.cpp | 1 - IO/Network.cpp | 5 ---- IO/Network.h | 1 - 8 files changed, 34 insertions(+), 48 deletions(-) diff --git a/DSP/Demod.cpp b/DSP/Demod.cpp index c0b84b8111..e57f3a5ee6 100644 --- a/DSP/Demod.cpp +++ b/DSP/Demod.cpp @@ -36,7 +36,8 @@ namespace Demod { Send(output.data(), len, tag); } - void PhaseSearch::Receive(const CFLOAT32* data, int len, TAG& tag) { + // Same version as above but instead relying on moving average to speed up + void PhaseSearchEMA::Receive(const CFLOAT32* data, int len, TAG& tag) { for (int i = 0; i < len; i++) { FLOAT32 re, im; @@ -64,34 +65,28 @@ namespace Demod { // Determining the phase is approached as a linear classification problem. for (int j = 0; j < nPhases / 2; j++) { - FLOAT32 a = re * phase[j].real(); - FLOAT32 b = im * phase[j].imag(); - FLOAT32 t; + FLOAT32 t, a = re * phase[j].real(), b = im * phase[j].imag(); t = a + b; bits[j] = (bits[j] << 1) | (t > 0); - memory[j][last] = std::abs(t); + ma[j] = weight * ma[j] + (1 - weight) * std::abs(t); t = a - b; bits[nPhases - 1 - j] = (bits[nPhases - 1 - j] << 1) | (t > 0); - memory[nPhases - 1 - j][last] = std::abs(t); + ma[nPhases - 1 - j] = weight * ma[nPhases - 1 - j] + (1 - weight) * std::abs(t); } - last = (last + 1) % nHistory; - - FLOAT32 max_val = 0; - int prev_max = max_idx; - - // local minmax search - for (int p = nPhases + prev_max - nSearch; p <= nPhases + prev_max + nSearch; p++) { - int j = p % nPhases; - FLOAT32 avg = memory[j][0]; + // we look at previous [max_idx - nSearch, max_idx + nSearch] + int idx = (max_idx - nSearch + nPhases) & (nPhases - 1); + FLOAT32 max_val = ma[idx]; + max_idx = idx; - for (int l = 1; l < nHistory; l++) avg += memory[j][l]; + for (int p = 0; p < nSearch << 1; p++) { + idx = (++idx) & (nPhases - 1); - if (avg > max_val) { - max_val = avg; - max_idx = j; + if (ma[idx] > max_val) { + max_val = ma[idx]; + max_idx = idx; } } @@ -104,9 +99,8 @@ namespace Demod { Send(&b, 1, tag); } } - - // Same version as above but instead relying on moving average to speed up - void PhaseSearchEMA::Receive(const CFLOAT32* data, int len, TAG& tag) { + + void PhaseSearch::Receive(const CFLOAT32* data, int len, TAG& tag) { for (int i = 0; i < len; i++) { FLOAT32 re, im; @@ -134,28 +128,34 @@ namespace Demod { // Determining the phase is approached as a linear classification problem. for (int j = 0; j < nPhases / 2; j++) { - FLOAT32 t, a = re * phase[j].real(), b = im * phase[j].imag(); + FLOAT32 a = re * phase[j].real(); + FLOAT32 b = im * phase[j].imag(); + FLOAT32 t; t = a + b; bits[j] = (bits[j] << 1) | (t > 0); - ma[j] = weight * ma[j] + (1 - weight) * std::abs(t); + memory[j][last] = std::abs(t); t = a - b; bits[nPhases - 1 - j] = (bits[nPhases - 1 - j] << 1) | (t > 0); - ma[nPhases - 1 - j] = weight * ma[nPhases - 1 - j] + (1 - weight) * std::abs(t); + memory[nPhases - 1 - j][last] = std::abs(t); } - // we look at previous [max_idx - nSearch, max_idx + nSearch] - int idx = (max_idx - nSearch + nPhases) & (nPhases - 1); - FLOAT32 max_val = ma[idx]; - max_idx = idx; + last = (last + 1) % nHistory; - for (int p = 0; p < nSearch << 1; p++) { - idx = (++idx) & (nPhases - 1); + FLOAT32 max_val = 0; + int prev_max = max_idx; - if (ma[idx] > max_val) { - max_val = ma[idx]; - max_idx = idx; + // local minmax search + for (int p = nPhases + prev_max - nSearch; p <= nPhases + prev_max + nSearch; p++) { + int j = p % nPhases; + FLOAT32 avg = memory[j][0]; + + for (int l = 1; l < nHistory; l++) avg += memory[j][l]; + + if (avg > max_val) { + max_val = avg; + max_idx = j; } } diff --git a/Device/AIRSPY.cpp b/Device/AIRSPY.cpp index d29525a7b0..910f1be6bb 100644 --- a/Device/AIRSPY.cpp +++ b/Device/AIRSPY.cpp @@ -29,7 +29,6 @@ namespace Device { #ifdef HASAIRSPY void AIRSPY::Open(uint64_t h) { - if (airspy_open_sn(&dev, h) != AIRSPY_SUCCESS) throw "AIRSPY: cannot open device."; setDefaultRate(); Device::Open(h); @@ -163,7 +162,6 @@ namespace Device { setLNA_AGC((int)LNA_AGC); setMixer_AGC((int)mixer_AGC); - break; } if (bias_tee) setBiasTee(true); @@ -195,7 +193,6 @@ namespace Device { else if (option == "LNA") { mode = AIRSPYGainMode::Free; LNA_AGC = Util::Parse::AutoInteger(arg, 0, 14, LNA_Gain); - ; } else if (option == "BIASTEE") { bias_tee = Util::Parse::Switch(arg); diff --git a/Device/AIRSPYHF.cpp b/Device/AIRSPYHF.cpp index 7996b1e8d7..e694eba113 100644 --- a/Device/AIRSPYHF.cpp +++ b/Device/AIRSPYHF.cpp @@ -28,7 +28,6 @@ namespace Device { #ifdef HASAIRSPYHF void AIRSPYHF::Open(uint64_t h) { - if (airspyhf_open_sn(&dev, h) != AIRSPYHF_SUCCESS) throw "AIRSPYHF: cannot open device"; setDefaultRate(); @@ -120,7 +119,6 @@ namespace Device { } bool AIRSPYHF::isStreaming() { - if (Device::isStreaming() && airspyhf_is_streaming(dev) != 1) lost = true; return Device::isStreaming() && airspyhf_is_streaming(dev) == 1; diff --git a/Device/RTLSDR.cpp b/Device/RTLSDR.cpp index a4bb142a56..144c8fce54 100644 --- a/Device/RTLSDR.cpp +++ b/Device/RTLSDR.cpp @@ -202,7 +202,6 @@ namespace Device { } std::string RTLSDR::Get() { - std::string str = " tuner " + Util::Convert::toString(tuner_AGC, tuner_Gain); str += " rtlagc " + Util::Convert::toString(RTL_AGC) + " biastee " + Util::Convert::toString(bias_tee); diff --git a/Device/RTLTCP.cpp b/Device/RTLTCP.cpp index e5827430d2..48682c61fd 100644 --- a/Device/RTLTCP.cpp +++ b/Device/RTLTCP.cpp @@ -168,7 +168,6 @@ namespace Device { } std::string RTLTCP::Get() { - std::string str = " host " + host + " port " + port + " timeout " + std::to_string(timeout); str += " tuner " + Util::Convert::toString(tuner_AGC, tuner_Gain); str += " rtlagc " + Util::Convert::toString(RTL_AGC); diff --git a/Device/SpyServer.cpp b/Device/SpyServer.cpp index cc5510090b..73f29f1cca 100644 --- a/Device/SpyServer.cpp +++ b/Device/SpyServer.cpp @@ -326,7 +326,6 @@ namespace Device { bool SpyServer::setFreq(uint32_t f) { - if (f < device_info.MinimumFrequency || f > device_info.MaximumFrequency) { throw "SPYSERVER: server does not support required frequency."; } diff --git a/IO/Network.cpp b/IO/Network.cpp index fbd4f337b1..12f671746c 100644 --- a/IO/Network.cpp +++ b/IO/Network.cpp @@ -55,7 +55,6 @@ namespace IO { // curl callback size_t HTTP::curl_cb(char* contents, size_t size, size_t nmemb, char* s) { - int len = MIN(size * nmemb, 1023); std::memcpy(s, contents, len); @@ -64,7 +63,6 @@ namespace IO { } void HTTP::send(const std::string& msg, const std::string& copyname) { - CURL* ch; CURLcode r; @@ -139,7 +137,6 @@ namespace IO { } void HTTP::post() { - if (!queue.size()) return; std::list send_list; @@ -209,7 +206,6 @@ namespace IO { } void HTTP::process() { - int i = 0; while (!terminate) { @@ -224,7 +220,6 @@ namespace IO { #endif void HTTP::Set(std::string option, std::string arg) { - #ifdef HASCURL Util::Convert::toUpper(option); diff --git a/IO/Network.h b/IO/Network.h index 9e82b15d00..bad9477528 100644 --- a/IO/Network.h +++ b/IO/Network.h @@ -137,5 +137,4 @@ namespace IO { void openConnection(UDPEndPoint& u) { openConnection(u.address, u.port); } void closeConnection(); }; - }