Skip to content

Commit

Permalink
release v0.39
Browse files Browse the repository at this point in the history
  • Loading branch information
jvde-github committed Nov 3, 2022
1 parent ec1f481 commit 4415e38
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 48 deletions.
68 changes: 34 additions & 34 deletions DSP/Demod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}

Expand Down
3 changes: 0 additions & 3 deletions Device/AIRSPY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -163,7 +162,6 @@ namespace Device {

setLNA_AGC((int)LNA_AGC);
setMixer_AGC((int)mixer_AGC);

break;
}
if (bias_tee) setBiasTee(true);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions Device/AIRSPYHF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Device/RTLSDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion Device/RTLTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion Device/SpyServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
}
Expand Down
5 changes: 0 additions & 5 deletions IO/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -64,7 +63,6 @@ namespace IO {
}

void HTTP::send(const std::string& msg, const std::string& copyname) {

CURL* ch;
CURLcode r;

Expand Down Expand Up @@ -139,7 +137,6 @@ namespace IO {
}

void HTTP::post() {

if (!queue.size()) return;

std::list<std::string> send_list;
Expand Down Expand Up @@ -209,7 +206,6 @@ namespace IO {
}

void HTTP::process() {

int i = 0;

while (!terminate) {
Expand All @@ -224,7 +220,6 @@ namespace IO {
#endif

void HTTP::Set(std::string option, std::string arg) {

#ifdef HASCURL
Util::Convert::toUpper(option);

Expand Down
1 change: 0 additions & 1 deletion IO/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,4 @@ namespace IO {
void openConnection(UDPEndPoint& u) { openConnection(u.address, u.port); }
void closeConnection();
};

}

0 comments on commit 4415e38

Please sign in to comment.