From d859bf91926d95b2bbfc2930015d209baf4e16c1 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 20 Sep 2025 10:58:54 +0200 Subject: [PATCH] ready for Qt5 and Qt6 --- qt-dab-6.9.pro | 4 +- sources/devices/rtl_tcp/rtl_tcp_client.cpp | 4 +- sources/frontend/ofdm-decoder.cpp | 67 ++++++++-------------- sources/frontend/ofdm-decoder.h | 1 - 4 files changed, 28 insertions(+), 48 deletions(-) diff --git a/qt-dab-6.9.pro b/qt-dab-6.9.pro index 3367b290..a3d65bcc 100644 --- a/qt-dab-6.9.pro +++ b/qt-dab-6.9.pro @@ -442,8 +442,8 @@ equals (QT_MAJOR_VERSION, 6) { # qmake -set QMAKEFEATURES /usr/local/Cellar/qwt/6.2.0/features CONFIG += qwt #} -#CONFIG += double -CONFIG += single +CONFIG += double +#CONFIG += single # # comment or uncomment for the devices you want to have support for # (you obviously have libraries installed for the selected ones) diff --git a/sources/devices/rtl_tcp/rtl_tcp_client.cpp b/sources/devices/rtl_tcp/rtl_tcp_client.cpp index d54e6964..3842c692 100644 --- a/sources/devices/rtl_tcp/rtl_tcp_client.cpp +++ b/sources/devices/rtl_tcp/rtl_tcp_client.cpp @@ -109,10 +109,10 @@ typedef struct { // 12 bytes, 3 * 4 bytes #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) connect (biasTSelector, &QCheckBox::checkStateChanged, #else - connect (biasTSelector, &QCkeckBox::stateChanged, + connect (biasTSelector, &QCheckBox::stateChanged, #endif this, &rtl_tcp_client::setBiasT); - connect (portSelector, &QSpinBox::valueChanged, + connect (portSelector, qOverload(&QSpinBox::valueChanged), this, &rtl_tcp_client::setPort); connect (addressSelector, &QLineEdit::returnPressed, this, &rtl_tcp_client::setAddress); diff --git a/sources/frontend/ofdm-decoder.cpp b/sources/frontend/ofdm-decoder.cpp index 1db4da1a..b224fce9 100644 --- a/sources/frontend/ofdm-decoder.cpp +++ b/sources/frontend/ofdm-decoder.cpp @@ -43,23 +43,10 @@ #define ALPHA 0.005f static inline Complex normalize (const Complex &V) { -float Length = jan_abs (V); +DABFLOAT Length = jan_abs (V); return Length == 0.0f ? Complex (0.0, 0.0) : V / (DABFLOAT)Length; } -#define GRANULARITY 5000 -#define TABLE_SIZE (int)(GRANULARITY + RAD_PER_DEGREE * 30.0) -//Complex makeComplex (DABFLOAT phase) { -//DABFLOAT p2 = phase * phase; -//DABFLOAT p3 = p2 * phase; -//DABFLOAT p4 = p3 * phase; -//DABFLOAT p5 = p4 * phase; -//DABFLOAT p6 = p5 * phase; -//DABFLOAT sine = phase - p3 / 6 + p5 / 120; -//DABFLOAT cosi = 1 - p2 / 2 + p4 / 24 - p6 / 720; -// return Complex (cosi, sine); -//} - ofdmDecoder::ofdmDecoder (RadioInterface *mr, uint8_t dabMode, int16_t bitDepth, @@ -99,13 +86,7 @@ float Length = jan_abs (V); iqSelector = SHOW_DECODED; // iqSelector = SHOW_RAW; decoder = DECODER_1; - - compTable. resize (TABLE_SIZE); - for (int i = 0; i < TABLE_SIZE; i ++) { - float argum = (float)(i - TABLE_SIZE / 2) / TABLE_SIZE; - compTable [i] = Complex (cos (argum), sin (argum)); - } - sqrt_2 = sqrt (2); + sqrt_2 = sqrt (2); } ofdmDecoder::~ofdmDecoder () { @@ -176,7 +157,7 @@ int sign (DABFLOAT x) { return x < 0 ? -1 : x > 0 ? 1 : 0; } -void limit_symmetrically (DABFLOAT &v, float limit) { +void limit_symmetrically (DABFLOAT &v, DABFLOAT limit) { if (v < -limit) v = -limit; if (v > limit) @@ -206,19 +187,19 @@ void limit_symmetrically (DABFLOAT &v, float limit) { // It is still experimental!!! static inline -std::complex w (float kn) { - float re = cos (kn * M_PI / 4); - float im = sin (kn * M_PI / 4); - return std::complex (re, im); +Complex w (DABFLOAT kn) { + DABFLOAT re = cos (kn * M_PI / 4); + DABFLOAT im = sin (kn * M_PI / 4); + return Complex (re, im); } static inline -float makeA (int i, std::complex S, std::complex prevS) { +DABFLOAT makeA (int i, Complex S, Complex prevS) { return abs (prevS + w (-i) * S); } static inline -float IO (float x) { +DABFLOAT IO (DABFLOAT x) { return std::cyl_bessel_i (0.0f, x); } @@ -227,8 +208,8 @@ void ofdmDecoder::decode (std::vector &buffer, std::vector &softbits, DABFLOAT snr) { -float sum = 0; -float bitSum = 0; +DABFLOAT sum = 0; +DABFLOAT bitSum = 0; memcpy (fft_buffer. data (), &((buffer. data ()) [T_g]), T_u * sizeof (Complex)); @@ -281,7 +262,7 @@ float bitSum = 0; Complex R1 = corrector * normalize (fftBin) * (DABFLOAT)(sqrt (binAbsLevel * jan_abs (phaseReference [index]))); - float scaler = 140.0 / meanValue; + DABFLOAT scaler = 140.0 / meanValue; DABFLOAT leftBit = - real (R1) * scaler; limit_symmetrically (leftBit, MAX_VITERBI); softbits [i] = (int16_t)leftBit; @@ -300,7 +281,7 @@ float bitSum = 0; Complex R1 = corrector * normalize (fftBin) * (DABFLOAT)(sqrt (binAbsLevel * jan_abs (phaseReference [index]))); - float scaler = 100 / meanValue; + DABFLOAT scaler = 100.0 / meanValue; DABFLOAT leftBit = - real (R1) * scaler; limit_symmetrically (leftBit, MAX_VITERBI); softbits [i] = (int16_t)leftBit; @@ -320,25 +301,25 @@ float bitSum = 0; 1.0 * MAX_VITERBI; } else { // experimental decoder 4 - float P1 = makeA (1, fftBin, prevS) / + DABFLOAT P1 = makeA (1, fftBin, prevS) / sigmaSQ_Vector [index]; - float P7 = makeA (7, fftBin, prevS) / + DABFLOAT P7 = makeA (7, fftBin, prevS) / sigmaSQ_Vector [index]; - float P3 = makeA (3, fftBin, prevS) / + DABFLOAT P3 = makeA (3, fftBin, prevS) / sigmaSQ_Vector [index]; - float P5 = makeA (5, fftBin, prevS) / + DABFLOAT P5 = makeA (5, fftBin, prevS) / sigmaSQ_Vector [index]; - float IO_P1 = IO (P1); - float IO_P7 = IO (P7); - float IO_P3 = IO (P3); - float IO_P5 = IO (P5); + DABFLOAT IO_P1 = IO (P1); + DABFLOAT IO_P7 = IO (P7); + DABFLOAT IO_P3 = IO (P3); + DABFLOAT IO_P5 = IO (P5); - float b1 = log ((IO_P1 + IO_P7) / (IO_P3 + IO_P5)); - float b2 = log ((IO_P1 + IO_P3) / (IO_P5 + IO_P7)); + DABFLOAT b1 = log ((IO_P1 + IO_P7) / (IO_P3 + IO_P5)); + DABFLOAT b2 = log ((IO_P1 + IO_P3) / (IO_P5 + IO_P7)); bitSum += (abs (b1) + abs (b2)) / 2; - float scaler = 40 / avgBit; + DABFLOAT scaler = 40 / avgBit; int s1 = -real (fftBin) < 0 ? -1 : 1; int s2 = -imag (fftBin) < 0 ? -1 : 1; DABFLOAT xx1 = s1 * abs (b1) * scaler; diff --git a/sources/frontend/ofdm-decoder.h b/sources/frontend/ofdm-decoder.h index e4686fa3..9f4e51de 100644 --- a/sources/frontend/ofdm-decoder.h +++ b/sources/frontend/ofdm-decoder.h @@ -72,7 +72,6 @@ private: RingBuffer *devBuffer; RingBuffer *iqBuffer; - std::vector compTable; float computeQuality (Complex *); float compute_timeOffset (Complex *, Complex *);