From 38fbcc65b76e414f6bc92320364558357f2697b0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 11 Jan 2023 00:21:47 +0100 Subject: [PATCH] : FT8 demod: implement Qt dependency and export for MSVC --- exports/export.h | 12 ++++++++++++ ft8/CMakeLists.txt | 5 +++++ ft8/fft.cpp | 5 +++-- ft8/fft.h | 4 +++- ft8/ft8.cpp | 36 +++++++++++++++++++----------------- ft8/ft8.h | 18 ++++++++++-------- ft8/osd.h | 14 +++++++------- ft8/unpack.h | 2 ++ ft8/util.h | 5 +++-- logging/CMakeLists.txt | 2 +- 10 files changed, 65 insertions(+), 38 deletions(-) diff --git a/exports/export.h b/exports/export.h index eee96b603..527685d80 100644 --- a/exports/export.h +++ b/exports/export.h @@ -151,4 +151,16 @@ # define MODEMM17_API #endif +/* the 'FT8_API' controls the import/export of 'ft8' symbols + */ +#if !defined(sdrangel_STATIC) +# ifdef ft8_EXPORTS +# define FT8_API __SDR_EXPORT +# else +# define FT8_API __SDR_IMPORT +# endif +#else +# define FT8_API +#endif + #endif /* __SDRANGEL_EXPORT_H */ diff --git a/ft8/CMakeLists.txt b/ft8/CMakeLists.txt index e58523db8..de077eddd 100644 --- a/ft8/CMakeLists.txt +++ b/ft8/CMakeLists.txt @@ -18,12 +18,17 @@ set(ft8_HEADERS util.h ) +include_directories( + ${CMAKE_SOURCE_DIR}/exports +) + add_library(ft8 SHARED ${ft8_SOURCES} ) target_link_libraries(ft8 ${FFTW3F_LIBRARIES} + Qt::Core ) install(TARGETS ft8 DESTINATION ${INSTALL_LIB_DIR}) diff --git a/ft8/fft.cpp b/ft8/fft.cpp index d24ae00ca..2cfec06a6 100644 --- a/ft8/fft.cpp +++ b/ft8/fft.cpp @@ -19,8 +19,9 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// -#include "fft.h" #include +#include +#include "fft.h" #include "util.h" #define TIMING 0 @@ -564,7 +565,7 @@ void FFTEngine::fft_stats() for (int i = 0; i < nplans; i++) { Plan *p = plans[i]; - printf("%-13s %6d %9d %6.3f\n", + qDebug("FT8::FFTEngine::fft_stats: %-13s %6d %9d %6.3fn", p->why_, p->n_, p->uses_, diff --git a/ft8/fft.h b/ft8/fft.h index 473be626f..67947d2e1 100644 --- a/ft8/fft.h +++ b/ft8/fft.h @@ -27,9 +27,11 @@ #include #include +#include "export.h" + namespace FT8 { -class FFTEngine +class FT8_API FFTEngine { public: // a cached fftw plan, for both of: diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index 4e7f1709f..c24f0fbea 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -43,6 +43,8 @@ #include #include #include +// #include + #include "util.h" #include "ft8.h" #include "libldpc.h" @@ -490,7 +492,7 @@ int FT8::blocksize(int rate) // -// look for potential signals by searching FFT bins for Costas symbol +// look for potential psignals by searching FFT bins for Costas symbol // blocks. returns a vector of candidate positions. // std::vector FT8::coarse(const FFTEngine::ffts_t &bins, int si0, int si1) @@ -2737,17 +2739,17 @@ int FT8::one_iter(const std::vector &samples200, int best_off, float hz_f float FT8::guess_snr(const FFTEngine::ffts_t &m79) { int costas[] = {3, 1, 4, 0, 6, 5, 2}; - float noises = 0; - float signals = 0; + float pnoises = 0; + float psignals = 0; for (int i = 0; i < 7; i++) { - signals += std::abs(m79[i][costas[i]]); - signals += std::abs(m79[36 + i][costas[i]]); - signals += std::abs(m79[72 + i][costas[i]]); - noises += std::abs(m79[i][(costas[i] + 4) % 8]); - noises += std::abs(m79[36 + i][(costas[i] + 4) % 8]); - noises += std::abs(m79[72 + i][(costas[i] + 4) % 8]); + psignals += std::abs(m79[i][costas[i]]); + psignals += std::abs(m79[36 + i][costas[i]]); + psignals += std::abs(m79[72 + i][costas[i]]); + pnoises += std::abs(m79[i][(costas[i] + 4) % 8]); + pnoises += std::abs(m79[36 + i][(costas[i] + 4) % 8]); + pnoises += std::abs(m79[72 + i][(costas[i] + 4) % 8]); } for (int i = 0; i < 79; i++) @@ -2760,17 +2762,17 @@ float FT8::guess_snr(const FFTEngine::ffts_t &m79) v[j] = std::abs(m79[i][j]); } std::sort(v.begin(), v.end()); - signals += v[7]; // strongest tone, probably the signal - noises += (v[2] + v[3] + v[4]) / 3; + psignals += v[7]; // strongest tone, probably the signal + pnoises += (v[2] + v[3] + v[4]) / 3; } - noises /= 79; - signals /= 79; + pnoises /= 79; + psignals /= 79; - noises *= noises; // square yields power - signals *= signals; + pnoises *= pnoises; // square yields power + psignals *= psignals; - float raw = signals / noises; + float raw = psignals / pnoises; raw -= 1; // turn (s+n)/n into s/n if (raw < 0.1) raw = 0.1; @@ -2956,7 +2958,7 @@ void FT8::fine(const FFTEngine::ffts_t &m79, int, float &adj_hz, float &adj_off) if (nlate > 0) late /= nlate; - // printf("early %d %.1f, late %d %.1f\n", nearly, early, nlate, late); + // qDebug("early %d %.1f, late %d %.1f", nearly, early, nlate, late); // assumes 32 samples/symbol. if (nearly > 2 * nlate) diff --git a/ft8/ft8.h b/ft8/ft8.h index de8c2bb48..92ab0105a 100644 --- a/ft8/ft8.h +++ b/ft8/ft8.h @@ -25,9 +25,11 @@ #include #include "fft.h" +#include "export.h" + namespace FT8 { // Callback interface to get the results -class CallbackInterface +class FT8_API CallbackInterface { public: virtual int hcb( @@ -54,7 +56,7 @@ public: // 4: similar to 3. // 5: laplace // -class Stats +class FT8_API Stats { public: std::vector a_; @@ -89,7 +91,7 @@ private: float log_rate_; }; -class Strength +class FT8_API Strength { public: float hz_; @@ -99,7 +101,7 @@ public: // same as Python class CDECODE // -struct cdecode +struct FT8_API cdecode { float hz0; float hz1; @@ -121,7 +123,7 @@ struct cdecode // total transmission time is 12.64 seconds // tunable parameters -struct FT8Params +struct FT8_API FT8Params { int nthreads; // number of parallel threads, for multi-core int npasses_one; // number of spectral subtraction passes @@ -260,7 +262,7 @@ struct FT8Params }; // class FT8Params // The FT8 worker -class FT8 +class FT8_API FT8 { public: std::thread *th_; @@ -649,7 +651,7 @@ private: static const double apriori174[]; }; // class FT8 -class FT8Decoder { +class FT8_API FT8Decoder { public: void entry( float xsamples[], @@ -669,7 +671,7 @@ public: FT8Params& getParams() { return params; } private: FT8Params params; -}; +}; // FT8Decoder } // namespace FT8 diff --git a/ft8/osd.h b/ft8/osd.h index 73a98c309..db408fc99 100644 --- a/ft8/osd.h +++ b/ft8/osd.h @@ -23,13 +23,13 @@ namespace FT8 { - extern int gen_sys[174][91]; - int check_crc(const int a91[91]); - void ldpc_encode(int plain[91], int codeword[174]); - float osd_score(int xplain[91], float ll174[174]); - int osd_check(const int plain[91]); - void matmul(int a[91][91], int b[91], int c[91]); - int osd_decode(float codeword[174], int depth, int out[91], int *out_depth); +extern int gen_sys[174][91]; +int check_crc(const int a91[91]); +void ldpc_encode(int plain[91], int codeword[174]); +float osd_score(int xplain[91], float ll174[174]); +int osd_check(const int plain[91]); +void matmul(int a[91][91], int b[91], int c[91]); +int osd_decode(float codeword[174], int depth, int out[91], int *out_depth); } // namepsace FT8 diff --git a/ft8/unpack.h b/ft8/unpack.h index a8a344e77..cb7951ed0 100644 --- a/ft8/unpack.h +++ b/ft8/unpack.h @@ -21,6 +21,8 @@ #ifndef unpack_h #define unpack_h +#include + namespace FT8 { std::string unpack(int a91[], std::string& call1str, std::string& call2str, std::string& locstr); diff --git a/ft8/util.h b/ft8/util.h index 7f855b4cc..5e5526a66 100644 --- a/ft8/util.h +++ b/ft8/util.h @@ -24,8 +24,8 @@ #include #include -namespace FT8 -{ +namespace FT8 { + double now(); void writetxt(std::vector v, const char *filename); std::complex goertzel(std::vector v, int rate, int i0, int n, float hz); @@ -51,6 +51,7 @@ std::string trim(const std::string &s); typedef unsigned long ulong; typedef unsigned int uint; + } // namespace FT8 #endif diff --git a/logging/CMakeLists.txt b/logging/CMakeLists.txt index 995e22ce2..b40fe18bc 100644 --- a/logging/CMakeLists.txt +++ b/logging/CMakeLists.txt @@ -8,7 +8,7 @@ set(logging_SOURCES logmessage.cpp ) -set(httpserver_HEADERS +set(logging_HEADERS dualfilelogger.h loggerwithfile.h filelogger.h