kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			: FT8 demod: implement Qt dependency and export for MSVC
							rodzic
							
								
									22acbebab6
								
							
						
					
					
						commit
						38fbcc65b7
					
				|  | @ -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 */ | ||||
|  |  | |||
|  | @ -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}) | ||||
|  |  | |||
|  | @ -19,8 +19,9 @@ | |||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include "fft.h" | ||||
| #include <assert.h> | ||||
| #include <QDebug> | ||||
| #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_, | ||||
|  |  | |||
|  | @ -27,9 +27,11 @@ | |||
| #include <complex> | ||||
| #include <fftw3.h> | ||||
| 
 | ||||
| #include "export.h" | ||||
| 
 | ||||
| namespace FT8 | ||||
| { | ||||
| class FFTEngine | ||||
| class FT8_API FFTEngine | ||||
| { | ||||
| public: | ||||
|     // a cached fftw plan, for both of:
 | ||||
|  |  | |||
							
								
								
									
										36
									
								
								ft8/ft8.cpp
								
								
								
								
							
							
						
						
									
										36
									
								
								ft8/ft8.cpp
								
								
								
								
							|  | @ -43,6 +43,8 @@ | |||
| #include <random> | ||||
| #include <functional> | ||||
| #include <map> | ||||
| // #include <QDebug>
 | ||||
| 
 | ||||
| #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<Strength> FT8::coarse(const FFTEngine::ffts_t &bins, int si0, int si1) | ||||
|  | @ -2737,17 +2739,17 @@ int FT8::one_iter(const std::vector<float> &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) | ||||
|  |  | |||
							
								
								
									
										18
									
								
								ft8/ft8.h
								
								
								
								
							
							
						
						
									
										18
									
								
								ft8/ft8.h
								
								
								
								
							|  | @ -25,9 +25,11 @@ | |||
| #include <mutex> | ||||
| #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<float> 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
 | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										14
									
								
								ft8/osd.h
								
								
								
								
							
							
						
						
									
										14
									
								
								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
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -21,6 +21,8 @@ | |||
| #ifndef unpack_h | ||||
| #define unpack_h | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| namespace FT8 { | ||||
| 
 | ||||
| std::string unpack(int a91[], std::string& call1str, std::string& call2str, std::string& locstr); | ||||
|  |  | |||
|  | @ -24,8 +24,8 @@ | |||
| #include <vector> | ||||
| #include <complex> | ||||
| 
 | ||||
| namespace FT8 | ||||
| { | ||||
| namespace FT8 { | ||||
| 
 | ||||
| double now(); | ||||
| void writetxt(std::vector<float> v, const char *filename); | ||||
| std::complex<float> goertzel(std::vector<float> 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 | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ set(logging_SOURCES | |||
|    logmessage.cpp | ||||
| ) | ||||
| 
 | ||||
| set(httpserver_HEADERS | ||||
| set(logging_HEADERS | ||||
|    dualfilelogger.h | ||||
|    loggerwithfile.h | ||||
|    filelogger.h | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 f4exb
						f4exb