Projects
home:wkazubski
qt-dab
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 6
View file
qt-dab.changes
Changed
@@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Nov 1 22:53:30 UTC 2018 - wk@ire.pw.edu.pl + +- updated to git 20181030 +- patch qt-dab-qt-dab-2.0-fix-no-return.patch removed (fixed + upstream) + +------------------------------------------------------------------- Thu Oct 11 00:13:21 UTC 2018 - wk@ire.pw.edu.pl - updated to git 20181009
View file
qt-dab.spec
Changed
@@ -18,9 +18,9 @@ #norootforbuild Name: qt-dab -Version: 2.0git20181009 +Version: 2.0git20181030 Release: 0 -License: GPL-2.0+ +License: GPL-2.0-or-later Summary: Simple DAB/DAB+ receiver Url: http://www.sdr-j.tk/index.html %if 0%{?suse_version} @@ -30,9 +30,7 @@ Group: Applications/Multimedia %endif Source0: https://github.com/JvanKatwijk/%{name}/archive/%{name}-%{version}.tar.gz -Patch0: %{name}-%{name}-2.0-fix-no-return.patch Patch1: %{name}-%{name}-2.0-use-qwt6-qt5.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: libqt5-qtbase-devel @@ -70,9 +68,10 @@ %prep %setup -q -n %{name} -%patch0 -p 1 %patch1 -p 1 +rm devices/sdrplay-handler/mirsdrapi-rsp.h + %build #qmake-qt5 qt-dab.pro @@ -129,8 +128,8 @@ %files -%defattr(-, root, root) -%doc AUTHORS README.md COPYING +%doc AUTHORS README.md +%license COPYING %{_bindir}/* %{_datadir}/applications/%{name}.desktop %{_datadir}/icons/hicolor/*x*/apps/%{name}.png
View file
qt-dab-qt-dab-2.0-fix-no-return.patch
Deleted
@@ -1,11 +0,0 @@ -diff -up qt-dab-qt-dab-2.0/src/ofdm/tii_detector.cpp.XXX qt-dab-qt-dab-2.0/src/ofdm/tii_detector.cpp ---- qt-dab-qt-dab-2.0/src/ofdm/tii_detector.cpp.XXX 2018-07-03 17:40:38.000000000 +0200 -+++ qt-dab-qt-dab-2.0/src/ofdm/tii_detector.cpp 2018-07-20 22:34:30.000000000 +0200 -@@ -212,6 +212,7 @@ int16_t b; - } - - int16_t TII_Detector::A_mode_4 (uint8_t c, uint8_t p, int16_t k) { -+return (0); - } - - int16_t TII_Detector::A_mode_1 (uint8_t c, uint8_t p, int16_t k) {
View file
qt-dab-2.0git20181009.tar.gz/CMakeLists.txt -> qt-dab-2.0git20181030.tar.gz/CMakeLists.txt
Changed
@@ -195,7 +195,7 @@ ./includes/ofdm/tii_table.h ./includes/ofdm/tii_detector.h ./includes/ofdm/timesyncer.h - ./includes/protection/protTables.cpp + ./includes/protection/protTables.h ./includes/protection/protection.h ./includes/protection/uep-protection.h ./includes/protection/eep-protection.h @@ -230,7 +230,9 @@ ./includes/backend/data/data-processor.h ./devices/virtual-input.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/output/fir-filters.h ./includes/output/audio-base.h ./includes/output/newconverter.h @@ -299,7 +301,9 @@ ./src/backend/data/data-processor.cpp ./devices/virtual-input.cpp ./devices/rawfiles/rawfiles.cpp + ./devices/rawfiles/raw-reader.cpp ./devices/wavfiles/wavfiles.cpp + ./devices/wavfiles/wav-reader.cpp ./src/output/audio-base.cpp ./src/output/newconverter.cpp ./src/output/fir-filters.cpp @@ -342,7 +346,9 @@ ./includes/backend/data/journaline-datahandler.h ./includes/backend/data/data-processor.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/scopes-qwt6/iqdisplay.h ./spectrum-viewer/spectrum-viewer.h ./impulse-viewer/impulse-viewer.h
View file
qt-dab-2.0git20181009.tar.gz/CMakeLists.txt-qt4 -> qt-dab-2.0git20181030.tar.gz/CMakeLists.txt-qt4
Changed
@@ -225,7 +225,9 @@ ./includes/backend/data/data-processor.h ./devices/virtual-input.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/output/fir-filters.h ./includes/output/audio-base.h ./includes/output/audiosink.h @@ -296,7 +298,9 @@ ./src/backend/data/data-processor.cpp ./devices/virtual-input.cpp ./devices/rawfiles/rawfiles.cpp + ./devices/rawfiles/raw-reader.cpp ./devices/wavfiles/wavfiles.cpp + ./devices/wavfiles/wav-reader.cpp ./src/output/audio-base.cpp ./src/output/audiosink.cpp ./src/output/newconverter.cpp @@ -340,7 +344,9 @@ ./includes/backend/data/journaline-datahandler.h ./includes/backend/data/data-processor.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/scopes-qwt6/iqdisplay.h ./spectrum-viewer/spectrum-viewer.h ./impulse-viewer/impulse-viewer.h
View file
qt-dab-2.0git20181009.tar.gz/CMakeLists.txt-qt5 -> qt-dab-2.0git20181030.tar.gz/CMakeLists.txt-qt5
Changed
@@ -230,7 +230,9 @@ ./includes/backend/data/data-processor.h ./devices/virtual-input.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/output/fir-filters.h ./includes/output/audio-base.h ./includes/output/newconverter.h @@ -299,7 +301,9 @@ ./src/backend/data/data-processor.cpp ./devices/virtual-input.cpp ./devices/rawfiles/rawfiles.cpp + ./devices/rawfiles/raw-reader.cpp ./devices/wavfiles/wavfiles.cpp + ./devices/wavfiles/wav-reader.cpp ./src/output/audio-base.cpp ./src/output/newconverter.cpp ./src/output/fir-filters.cpp @@ -342,7 +346,9 @@ ./includes/backend/data/journaline-datahandler.h ./includes/backend/data/data-processor.h ./devices/rawfiles/rawfiles.h + ./devices/rawfiles/raw-reader.h ./devices/wavfiles/wavfiles.h + ./devices/wavfiles/wav-reader.h ./includes/scopes-qwt6/iqdisplay.h ./spectrum-viewer/spectrum-viewer.h ./impulse-viewer/impulse-viewer.h
View file
qt-dab-2.0git20181009.tar.gz/dab-processor.cpp -> qt-dab-2.0git20181030.tar.gz/dab-processor.cpp
Changed
@@ -67,7 +67,6 @@ dabMode, theRig -> bitDepth (), iqBuffer) { -int32_t i; this -> myRadioInterface = mr; this -> theRig = theRig; @@ -153,6 +152,7 @@ //Initing: notSynced: setSynced (false); + my_TII_Detector. reset(); switch (myTimeSyncer. sync (T_null, T_F)) { case TIMESYNC_ESTABLISHED: break; // yes, we are ready @@ -295,16 +295,14 @@ my_TII_Detector. processNULL (&mainId, &subId); if (mainId > 0) showCoordinates (mainId, subId); - } - if ((tii_counter & 02) != 0) { + tiiBuffer -> putDataIntoBuffer (ofdmBuffer. data (), T_u); show_tii (1); - } - if (tii_counter >= tii_delay) tii_counter = 1; } } + } /** * The first sample to be found for the next frame should be T_g * samples ahead. Before going for the next frame, we @@ -452,4 +450,3 @@ } } -
View file
qt-dab-2.0git20181009.tar.gz/dab-processor.h -> qt-dab-2.0git20181030.tar.gz/dab-processor.h
Changed
@@ -98,6 +98,7 @@ RingBuffer<std::complex<float> > *tiiBuffer; int16_t tii_delay; int16_t tii_counter; + sampleReader myReader; RadioInterface *myRadioInterface; ficHandler my_ficHandler;
View file
qt-dab-2.0git20181030.tar.gz/devices/rawfiles/raw-reader.cpp
Added
@@ -0,0 +1,110 @@ +# +/* + * Copyright (C) 2013 .. 2017 + * Jan van Katwijk (J.vanKatwijk@gmail.com) + * Lazy Chair Computing + * + * This file is part of the Qt-DAB program + * Qt-DAB is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Qt-DAB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qt-DAB; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <sys/time.h> +#include "raw-reader.h" +#include "rawfiles.h" + + +#define BUFFERSIZE 32768 +static inline +int64_t getMyTime (void) { +struct timeval tv; + + gettimeofday (&tv, NULL); + return ((int64_t)tv. tv_sec * 1000000 + (int64_t)tv. tv_usec); +} + + rawReader::rawReader (rawFiles *mr, + FILE *filePointer, + RingBuffer<uint8_t> *theBuffer) { + this -> parent = mr; + this -> filePointer = filePointer; + this -> theBuffer = theBuffer; + + fseek (filePointer, 0, SEEK_END); + fileLength = ftell (filePointer); + fprintf (stderr, "fileLength = %d\n", fileLength); + fseek (filePointer, 0, SEEK_SET); + period = (32768 * 1000) / (2 * 2048); // full IQś read + fprintf (stderr, "Period = %ld\n", period); + bi = new uint8_t [BUFFERSIZE]; + running. store (false); + start (); +} + + rawReader::~rawReader (void) { + stopReader (); + delete[] bi; +} + +void rawReader::stopReader (void) { + if (running) { + running = false; + while (isRunning ()) + usleep (200); + } +} + +void rawReader::run (void) { +int64_t nextStop; +int i; +int teller = 0; + + connect (this, SIGNAL (setProgress (int, float)), + parent, SLOT (setProgress (int, float))); + fseek (filePointer, 0, SEEK_SET); + running. store (true); + nextStop = getMyTime (); + try { + while (running. load ()) { + while (theBuffer -> WriteSpace () < BUFFERSIZE + 10) { + if (!running. load ()) + throw (32); + usleep (100); + } + + if (++teller >= 20) { + int xx = ftell (filePointer); + float progress = (float)xx / fileLength; + setProgress ((int)(progress * 100), (float)xx / (2 * 2048000)); + teller = 0; + } + + nextStop += period; + int n = fread (bi, sizeof (uint8_t), BUFFERSIZE, filePointer); + if (n < BUFFERSIZE) { + fprintf (stderr, "eof gehad\n"); + fseek (filePointer, 0, SEEK_SET); + for (i = n; i < BUFFERSIZE; i ++) + bi [i] = 0; + } + + theBuffer -> putDataIntoBuffer (bi, BUFFERSIZE); + if (nextStop - getMyTime () > 0) + usleep (nextStop - getMyTime ()); + } + } catch (int e) {} + fprintf (stderr, "taak voor replay eindigt hier\n"); +} + +
View file
qt-dab-2.0git20181030.tar.gz/devices/rawfiles/raw-reader.h
Added
@@ -0,0 +1,53 @@ +# +/* + * Copyright (C) 2013 .. 2017 + * Jan van Katwijk (J.vanKatwijk@gmail.com) + * Lazy Chair Computing + * + * This file is part of the Qt-DAB program + * Qt-DAB is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Qt-DAB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qt-DAB; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __RAW_READER__ +#define __RAW_READER__ + +#include <QThread> +#include "dab-constants.h" +#include "ringbuffer.h" +#include <atomic> +class rawFiles; + +class rawReader:public QThread { +Q_OBJECT +public: + rawReader (rawFiles *, + FILE *, RingBuffer<uint8_t> *); + ~rawReader (void); + void startReader (void); + void stopReader (void); +private: +virtual void run (void); + FILE *filePointer; + RingBuffer<uint8_t> *theBuffer; + uint64_t period; + std::atomic<bool> running; + uint8_t *bi; + rawFiles *parent; + int64_t fileLength; +signals: + void setProgress (int, float); +}; + +#endif +
View file
qt-dab-2.0git20181009.tar.gz/devices/rawfiles/rawfiles.cpp -> qt-dab-2.0git20181030.tar.gz/devices/rawfiles/rawfiles.cpp
Changed
@@ -32,13 +32,7 @@ #include <sys/time.h> #include <time.h> -static inline -int64_t getMyTime (void) { -struct timeval tv; - - gettimeofday (&tv, NULL); - return ((int64_t)tv. tv_sec * 1000000 + (int64_t)tv. tv_usec); -} +#include "raw-reader.h" #define INPUT_FRAMEBUFFERSIZE 8 * 32768 // @@ -49,7 +43,6 @@ setupUi (myFrame); myFrame -> show (); _I_Buffer = new RingBuffer<uint8_t>(INPUT_FRAMEBUFFERSIZE); - readerOK = false; filePointer = fopen (f. toUtf8 (). data (), "rb"); if (filePointer == NULL) { fprintf (stderr, "file %s cannot open\n", @@ -60,33 +53,46 @@ throw (31); } nameofFile -> setText (f); - readerOK = true; - readerPausing = true; - currPos = 0; - start (); + fseek (filePointer, 0, SEEK_END); + int64_t fileLength = ftell (filePointer); + totalTime -> display ((float)fileLength / (2048000 * 2)); + fseek (filePointer, 0, SEEK_SET); + fileProgress -> setValue (0); + currentTime -> display (0); + + running. store (false); } rawFiles::~rawFiles (void) { - ExitCondition = true; - if (readerOK) { - while (isRunning ()) + if (running. load ()) { + readerTask -> stopReader (); + while (readerTask -> isRunning ()) usleep (100); - if (filePointer != NULL) - fclose (filePointer); + delete readerTask; } + if (filePointer != NULL) + fclose (filePointer); + delete _I_Buffer; delete myFrame; } bool rawFiles::restartReader (void) { - if (readerOK) - readerPausing = false; - return readerOK; + if (running. load ()) + return true; + readerTask = new rawReader (this, filePointer, _I_Buffer); + running. store (true); + return true; } void rawFiles::stopReader (void) { - if (readerOK) - readerPausing = true; + if (running. load ()) { + readerTask -> stopReader (); + while (readerTask -> isRunning ()) + usleep (100); + delete readerTask; + } + running. store (false); } // size is in I/Q pairs, file contains 8 bits values @@ -98,10 +104,7 @@ return 0; while ((int32_t)(_I_Buffer -> GetRingBufferReadAvailable ()) < 2 * size) - if (readerPausing) - usleep (100000); - else - msleep (100); + usleep (500); amount = _I_Buffer -> getDataFromBuffer (temp, 2 * size); for (i = 0; i < amount / 2; i ++) @@ -114,76 +117,9 @@ return _I_Buffer -> GetRingBufferReadAvailable () / 2; } -void rawFiles::run (void) { -int32_t t, i; -uint8_t *bi; -int32_t bufferSize = 32768; -int64_t period; -int64_t nextStop; -int64_t fileLength; -int teller = 0; - - if (!readerOK) - return; - - ExitCondition = false; - - fileProgress -> setValue (0); - currentTime -> display (0); - fseek (filePointer, 0, SEEK_END); - fileLength = ftell (filePointer); - fseek (filePointer, 0, SEEK_SET); - totalTime -> display ((float)fileLength / 2048000); - - period = (32768 * 1000) / (2 * 2048); // full IQś read - fprintf (stderr, "Period = %ld\n", period); - bi = new uint8_t [bufferSize]; - nextStop = getMyTime (); - while (!ExitCondition) { - if (readerPausing) { - usleep (1000); - nextStop = getMyTime (); - continue; - } - while (_I_Buffer -> WriteSpace () < bufferSize + 10) { - if (ExitCondition) - break; - usleep (100); - } - - if (++teller > 20) { - teller = 0; - int xx = ftell (filePointer); - float progress = (float)xx / fileLength; - fileProgress -> setValue (progress * 100); - currentTime -> display ((float)xx / 2048000); - } - - nextStop += period; - t = readBuffer (bi, bufferSize); - if (t <= 0) { - for (i = 0; i < bufferSize; i ++) - bi [i] = 0; - t = bufferSize; - } - _I_Buffer -> putDataIntoBuffer (bi, t); - if (nextStop - getMyTime () > 0) - usleep (nextStop - getMyTime ()); - } - fprintf (stderr, "taak voor replay eindigt hier\n"); +void rawFiles::setProgress (int progress, float timelength) { + fileProgress -> setValue (progress); + currentTime -> display (timelength); } -/* - * length is number of uints that we read. - */ -int32_t rawFiles::readBuffer (uint8_t *data, int32_t length) { -int32_t n; - n = fread (data, sizeof (uint8_t), length, filePointer); - currPos += n; - if (n < length) { - fseek (filePointer, 0, SEEK_SET); - fprintf (stderr, "End of file, restarting\n"); - } - return n & ~01; -}
View file
qt-dab-2.0git20181009.tar.gz/devices/rawfiles/rawfiles.h -> qt-dab-2.0git20181030.tar.gz/devices/rawfiles/rawfiles.h
Changed
@@ -25,6 +25,7 @@ #include <QThread> #include <QString> #include <QFrame> +#include <atomic> #include "dab-constants.h" #include "virtual-input.h" #include "ringbuffer.h" @@ -33,11 +34,12 @@ class QLabel; class QSettings; -class fileHulp; +class rawReader; /* */ class rawFiles: public virtualInput, - public Ui_filereaderWidget, QThread { + public Ui_filereaderWidget { +Q_OBJECT public: rawFiles (QString); @@ -49,17 +51,13 @@ void stopReader (void); private: QString fileName; -virtual void run (void); QFrame *myFrame; - int32_t readBuffer (uint8_t *, int32_t); RingBuffer<uint8_t> *_I_Buffer; - int32_t bufferSize; FILE *filePointer; - bool readerOK; - bool readerPausing; - bool ExitCondition; - bool ThreadFinished; - int64_t currPos; + rawReader *readerTask; + std::atomic<bool> running; +public slots: + void setProgress (int, float); }; #endif
View file
qt-dab-2.0git20181030.tar.gz/devices/wavfiles/wav-reader.cpp
Added
@@ -0,0 +1,110 @@ +# +/* + * Copyright (C) 2013 .. 2017 + * Jan van Katwijk (J.vanKatwijk@gmail.com) + * Lazy Chair Computing + * + * This file is part of the Qt-DAB program + * Qt-DAB is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Qt-DAB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qt-DAB; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <sys/time.h> +#include "wav-reader.h" +#include "wavfiles.h" + + +#define BUFFERSIZE 32768 +static inline +int64_t getMyTime (void) { +struct timeval tv; + + gettimeofday (&tv, NULL); + return ((int64_t)tv. tv_sec * 1000000 + (int64_t)tv. tv_usec); +} + + wavReader::wavReader (wavFiles *mr, + SNDFILE *filePointer, + RingBuffer<std::complex<float> > *theBuffer) { + this -> parent = mr; + this -> filePointer = filePointer; + this -> theBuffer = theBuffer; + fileLength = sf_seek (filePointer, 0, SEEK_END); + fprintf (stderr, "fileLength = %d\n", fileLength); + sf_seek (filePointer, 0, SEEK_SET); + period = (32768 * 1000) / (2048); // full IQś read + fprintf (stderr, "Period = %ld\n", period); + running. store (false); + start (); +} + + wavReader::~wavReader (void) { + stopReader (); +} + +void wavReader::stopReader (void) { + if (running. load ()) { + running. store (false); + while (isRunning ()) + usleep (200); + } +} + +void wavReader::run (void) { +int32_t t, i; +std::complex<float> *bi; +int32_t bufferSize = 32768; +int64_t nextStop; +int teller = 0; + + connect (this, SIGNAL (setProgress (int, float)), + parent, SLOT (setProgress (int, float))); + sf_seek (filePointer, 0, SEEK_SET); + + running. store (true); + + bi = new std::complex<float> [bufferSize]; + nextStop = getMyTime (); + try { + while (running. load ()) { + while (theBuffer -> WriteSpace () < bufferSize) { + if (!running. load ()) + throw (33); + usleep (100); + } + + if (++teller >= 20) { + int xx = sf_seek (filePointer, 0, SEEK_CUR); + float progress = (float)xx / fileLength; + setProgress ((int)(progress * 100), (float)xx / 2048000); + teller = 0; + } + + nextStop += period; + int n = sf_readf_float (filePointer, + (float *)bi, bufferSize); + if (n < bufferSize) { + sf_seek (filePointer, 0, SEEK_SET); + for (i = n; i < bufferSize; i ++) + bi [i] = std::complex <float> (0, 0); + } + theBuffer -> putDataIntoBuffer (bi, bufferSize); + if (nextStop - getMyTime () > 0) + usleep (nextStop - getMyTime ()); + } + } catch (int e) {} + fprintf (stderr, "taak voor replay eindigt hier\n"); fflush (stderr); + delete[] bi; +} +
View file
qt-dab-2.0git20181030.tar.gz/devices/wavfiles/wav-reader.h
Added
@@ -0,0 +1,54 @@ +# +/* + * Copyright (C) 2013 .. 2017 + * Jan van Katwijk (J.vanKatwijk@gmail.com) + * Lazy Chair Computing + * + * This file is part of the Qt-DAB program + * Qt-DAB is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Qt-DAB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qt-DAB; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __WAV_READER__ +#define __WAV_READER__ + +#include <QThread> +#include <sndfile.h> +#include "dab-constants.h" +#include "ringbuffer.h" +#include <atomic> +class wavFiles; + +class wavReader:public QThread { +Q_OBJECT +public: + wavReader (wavFiles *, + SNDFILE *, + RingBuffer<std::complex<float>> *); + ~wavReader (void); + void startReader (void); + void stopReader (void); +private: +virtual void run (void); + SNDFILE *filePointer; + RingBuffer<std::complex<float> > *theBuffer; + uint64_t period; + std::atomic<bool> running; + wavFiles *parent; + int64_t fileLength; +signals: + void setProgress (int, float); +}; + +#endif +
View file
qt-dab-2.0git20181009.tar.gz/devices/wavfiles/wavfiles.cpp -> qt-dab-2.0git20181030.tar.gz/devices/wavfiles/wavfiles.cpp
Changed
@@ -28,14 +28,6 @@ #include <QString> #include "wavfiles.h" -static inline -int64_t getMyTime (void) { -struct timeval tv; - - gettimeofday (&tv, NULL); - return ((int64_t)tv. tv_sec * 1000000 + (int64_t)tv. tv_usec); -} - #define __BUFFERSIZE 8 * 32768 wavFiles::wavFiles (QString f) { @@ -46,8 +38,7 @@ setupUi (myFrame); myFrame -> show (); - readerOK = false; - _I_Buffer = new RingBuffer<std::complex<float>>(__BUFFERSIZE); + _I_Buffer = new RingBuffer<std::complex<float>> (__BUFFERSIZE); sf_info = (SF_INFO *)alloca (sizeof (SF_INFO)); sf_info -> format = 0; @@ -66,47 +57,54 @@ throw (25); } nameofFile -> setText (f); - readerOK = true; - readerPausing = true; - currPos = 0; -// start (); + fileProgress -> setValue (0); + currentTime -> display (0); + int64_t fileLength = sf_seek (filePointer, 0, SEEK_END); + totalTime -> display ((float)fileLength / 2048000); + running. store (false); } +// +// Note that running == true <==> readerTask has value assigned wavFiles::~wavFiles (void) { - ExitCondition = true; - if (readerOK) { - while (isRunning ()) - usleep (100); - sf_close (filePointer); + if (running. load ()) { + readerTask -> stopReader (); + while (readerTask -> isRunning ()) + usleep (500); + delete readerTask; } + if (filePointer != NULL) + sf_close (filePointer); delete _I_Buffer; delete myFrame; } bool wavFiles::restartReader (void) { - if (readerOK) - readerPausing = false; - start (); - return readerOK; + if (running. load ()) + return true; + readerTask = new wavReader (this, filePointer, _I_Buffer); + running. store (true); + return true; } void wavFiles::stopReader (void) { - if (readerOK) - readerPausing = true; + if (running. load ()) { + readerTask -> stopReader (); + while (readerTask -> isRunning ()) + usleep (100); + delete readerTask; + } + running. store (false); } // size is in I/Q pairs int32_t wavFiles::getSamples (std::complex<float> *V, int32_t size) { int32_t amount; - if (filePointer == NULL) return 0; while (_I_Buffer -> GetRingBufferReadAvailable () < size) - if (readerPausing) - usleep (100000); - else usleep (100); amount = _I_Buffer -> getDataFromBuffer (V, size); @@ -118,77 +116,10 @@ return _I_Buffer -> GetRingBufferReadAvailable (); } -void wavFiles::run (void) { -int32_t t, i; -std::complex<float> *bi; -int32_t bufferSize = 32768; -int64_t period; -int64_t nextStop; -int64_t fileLength; -int teller = 0; - - if (!readerOK) - return; +void wavFiles::setProgress (int progress, float timelength) { + fileProgress -> setValue (progress); + currentTime -> display (timelength); +} - fileProgress -> setValue (0); - currentTime -> display (0); - fileLength = sf_seek (filePointer, 0, SEEK_END); - totalTime -> display ((float)fileLength / 2048000); - ExitCondition = false; - - period = (32768 * 1000) / 2048; // full IQś read - fprintf (stderr, "Period = %ld\n", period); - bi = new std::complex<float> [bufferSize]; - nextStop = getMyTime (); - while (!ExitCondition) { - if (readerPausing) { - usleep (1000); - nextStop = getMyTime (); - continue; - } - while (_I_Buffer -> WriteSpace () < bufferSize) { - if (ExitCondition) - break; - usleep (100); - } - - if (++teller >= 20) { - int xx = sf_seek (filePointer, 0, SEEK_CUR); - float progress = (float)xx / fileLength; - fileProgress -> setValue ((int) (progress * 100)); - currentTime -> display ((float)xx / 2048000); - teller = 0; - } - - nextStop += period; - t = readBuffer (bi, bufferSize); - if (t < bufferSize) { - for (i = t; i < bufferSize; i ++) - bi [i] = 0; - t = bufferSize; - } - _I_Buffer -> putDataIntoBuffer (bi, bufferSize); - if (nextStop - getMyTime () > 0) - usleep (nextStop - getMyTime ()); - } - fprintf (stderr, "taak voor replay eindigt hier\n"); fflush (stderr); -} -/* - * length is number of uints that we read. - */ -int32_t wavFiles::readBuffer (std::complex<float> *data, int32_t length) { -int32_t i, n; -float temp [2 * length]; - - n = sf_readf_float (filePointer, temp, length); - if (n < length) { - int xx = sf_seek (filePointer, 0, SEEK_SET); - fprintf (stderr, "xx = %d\n", xx); - fprintf (stderr, "End of file, restarting\n"); - } - for (i = 0; i < n; i ++) - data [i] = std::complex<float> (temp [2 * i], temp [2 * i + 1]); - return n & ~01; -}
View file
qt-dab-2.0git20181009.tar.gz/devices/wavfiles/wavfiles.h -> qt-dab-2.0git20181030.tar.gz/devices/wavfiles/wavfiles.h
Changed
@@ -22,39 +22,37 @@ #ifndef __WAV_FILES__ #define __WAV_FILES__ -#include <QThread> #include <QString> #include <QFrame> #include <sndfile.h> +#include <atomic> #include "dab-constants.h" #include "virtual-input.h" #include "ringbuffer.h" #include "ui_filereader-widget.h" +#include "wav-reader.h" class wavFiles: public virtualInput, - public Ui_filereaderWidget, QThread { + public Ui_filereaderWidget { +Q_OBJECT public: wavFiles (QString); ~wavFiles (void); int32_t getSamples (std::complex<float> *, int32_t); - uint8_t myIdentity (void); int32_t Samples (void); bool restartReader (void); void stopReader (void); private: QString fileName; - int tester; QFrame *myFrame; -virtual void run (void); - int32_t readBuffer (std::complex<float> *, int32_t); RingBuffer<std::complex<float>> *_I_Buffer; int32_t bufferSize; SNDFILE *filePointer; - bool readerOK; - bool readerPausing; - bool ExitCondition; - int64_t currPos; + wavReader *readerTask; + std::atomic<bool> running; +public slots: + void setProgress (int, float); }; #endif
View file
qt-dab-2.0git20181009.tar.gz/includes/ofdm/tii_detector.h -> qt-dab-2.0git20181030.tar.gz/includes/ofdm/tii_detector.h
Changed
@@ -35,10 +35,13 @@ ~TII_Detector (void); void reset (void); void addBuffer (std::vector<std::complex<float>>); - int16_t find_C (int16_t, int); void processNULL (int16_t *, int16_t *); private: + void collapse (std::complex<float> *, + float *); + uint8_t invTable [256]; + void initInvTable (void); dabParams params; fftHandler my_fftHandler; int16_t T_u; @@ -49,18 +52,11 @@ std::vector<float> window; std::vector<complex<float> > refTable; int16_t fillCount; - int16_t A (uint8_t, uint8_t c, + int16_t A (uint8_t c, uint8_t p, int16_t k); - int16_t A_mode_1 (uint8_t c, uint8_t p, int16_t k); - int16_t A_mode_2 (uint8_t c, uint8_t p, int16_t k); - int16_t A_mode_4 (uint8_t c, uint8_t p, int16_t k); - float correlate (std::vector<complex<float> >, - int16_t, uint64_t, int); + void createPattern (void); + void printOverlap (int pNum, int cNum); - void createPattern (uint8_t); - void createPattern_1 (void); - void createPattern_2 (void); - void createPattern_4 (void); struct nullTable { int16_t carrier; uint64_t pattern;
View file
qt-dab-2.0git20181009.tar.gz/qt-dab.pro -> qt-dab-2.0git20181030.tar.gz/qt-dab.pro
Changed
@@ -9,12 +9,12 @@ QT += widgets CONFIG += console QMAKE_CXXFLAGS += -std=c++11 -#QMAKE_CFLAGS += -flto -ffast-math -#QMAKE_CXXFLAGS += -flto -ffast-math -#QMAKE_LFLAGS += -flto -QMAKE_CFLAGS += -g -QMAKE_CXXFLAGS += -g -QMAKE_LFLAGS += -g +QMAKE_CFLAGS += -flto -ffast-math +QMAKE_CXXFLAGS += -flto -ffast-math +QMAKE_LFLAGS += -flto +#QMAKE_CFLAGS += -g +#QMAKE_CXXFLAGS += -g +#QMAKE_LFLAGS += -g QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS] RC_ICONS = qt-dab.ico RESOURCES += resources.qrc @@ -148,7 +148,9 @@ ./includes/scopes-qwt6/iqdisplay.h \ ./devices/virtual-input.h \ ./devices/rawfiles/rawfiles.h \ + ./devices/rawfiles/raw-reader.h \ ./devices/wavfiles/wavfiles.h \ + ./devices/wavfiles/wav-reader.h \ ./spectrum-viewer/spectrum-viewer.h \ ./impulse-viewer/impulse-viewer.h \ ./tii-viewer/tii-viewer.h @@ -226,7 +228,9 @@ ./src/scopes-qwt6/iqdisplay.cpp \ ./devices/virtual-input.cpp \ ./devices/rawfiles/rawfiles.cpp \ + ./devices/rawfiles/raw-reader.cpp \ ./devices/wavfiles/wavfiles.cpp \ + ./devices/wavfiles/wav-reader.cpp \ ./spectrum-viewer/spectrum-viewer.cpp \ ./impulse-viewer/impulse-viewer.cpp \ ./tii-viewer/tii-viewer.cpp @@ -270,7 +274,7 @@ #CONFIG += datastreamer #to handle output of embedded an IP data stream, uncomment -#CONFIG += send_datagram +CONFIG += send_datagram #if you want to listen remote, uncomment #CONFIG += tcp-streamer # use for remote listening @@ -440,7 +444,7 @@ send_datagram { DEFINES += _SEND_DATAGRAM_ - Qt += network + QT += network } elad_s1 {
View file
qt-dab-2.0git20181009.tar.gz/radio.cpp -> qt-dab-2.0git20181030.tar.gz/radio.cpp
Changed
@@ -138,9 +138,9 @@ dabSettings -> value ("diff_length", DIFF_LENGTH). toInt (); tii_delay = - dabSettings -> value ("tii_delay", 20). toInt (); - if (tii_delay < 20) - tii_delay = 20; + dabSettings -> value ("tii_delay", 5). toInt (); + if (tii_delay < 5) + tii_delay = 5; dataBuffer = new RingBuffer<uint8_t>(32768); /// The default, most likely to be overruled @@ -734,10 +734,12 @@ } dataBuffer -> getDataFromBuffer (localBuffer, length); #ifdef _SEND_DATAGRAM_ - if (running. load ()) + if (running. load ()) { dataOut_socket. writeDatagram ((const char *)localBuffer, length, QHostAddress (ipAddress), port); + } + #endif } //
View file
qt-dab-2.0git20181009.tar.gz/src/backend/data/data-processor.cpp -> qt-dab-2.0git20181030.tar.gz/src/backend/data/data-processor.cpp
Changed
@@ -133,8 +133,8 @@ if (address == 0) return; // padding packet // - if (packetAddress != address) // sorry - return; +// if (packetAddress != address) // sorry +// return; // assemble the full MSC datagroup
View file
qt-dab-2.0git20181009.tar.gz/src/backend/data/ip-datahandler.cpp -> qt-dab-2.0git20181030.tar.gz/src/backend/data/ip-datahandler.cpp
Changed
@@ -101,7 +101,6 @@ return; } - fprintf (stderr, "sending udp"); switch (protocol) { case 17: // UDP protocol process_udpVector (&data [4 * headerSize], ipSize - 4 * headerSize);
View file
qt-dab-2.0git20181009.tar.gz/src/ofdm/phasereference.cpp -> qt-dab-2.0git20181030.tar.gz/src/ofdm/phasereference.cpp
Changed
@@ -178,6 +178,7 @@ return index - T_u; } // + // NOT USED, just for some tests // An alternative way to compute the small frequency offset // is to look at the phase offset of subsequent carriers
View file
qt-dab-2.0git20181009.tar.gz/src/ofdm/tii_detector.cpp -> qt-dab-2.0git20181030.tar.gz/src/ofdm/tii_detector.cpp
Changed
@@ -24,25 +24,17 @@ #include <stdio.h> #include <inttypes.h> // -// Transmitter Identification Info is carrier in the null period -// of a DAB frame. In case the FIB's carry information on the -// set of transmitters used in the SFN, an attempt is made -// to identify the transmitter by inspecting the null period. // The information in the null-period is encoded in a "p" // a "pattern" and a "c", a "carrier" -// value. The "p" value, derived from the FIB, defines the +// value. The "p" value defines the // pattern within the null-period as well as a set of // startcarriers, i.e. carrier numbers where the pattern // could start. -// The start carrier itself determined the "c" value. +// The start carrier itself determines the "c" value. // Basically, within an SFN the "p" is fixed for all transmitters, // while the latter show the pattern on different positions in // the carriers of the null-period. // -// Matching the position of the pattern is relatively easy, since -// the standard defines the signals (i.e. phase and amplitude) of -// the carriers in the pattern. -// // As it turns out, the pattern is represented by a sequence // consisting of elements with two subsequent bins with the same // value, followed by a "gap" of K * 48 (-1) bins. @@ -78,12 +70,16 @@ refTable [T_u / 2 - i] = std::complex<float> (cos (Phi_k), sin (Phi_k)); } - createPattern (dabMode); + initInvTable (); + createPattern (); +// for (i = 0; i < 70; i ++) +// printOverlap (i, 15); } TII_Detector::~TII_Detector (void) { } + // Zm (0, k) is a function of the P and the C, together forming the key to // the database where he transmitter locations are described. // @@ -174,8 +170,17 @@ 0360 // 1 1 1 1 0 0 0 0 69 }; + +void TII_Detector::initInvTable() { + int i; + for (i = 0; i < 256; ++i) + invTable [i] = -1; + for (i = 0; i < 70; ++i) + invTable [table [i]] = i; +} + static -uint8_t bits [] = {128, 64, 32, 16, 8, 4, 2, 1}; +uint8_t bits [] = {0x80, 0x40, 0x20, 0x10 , 0x08, 0x04, 0x02, 0x01}; static inline uint8_t getbit (uint8_t value, int16_t bitPos) { return value & bits [bitPos] ? 1 : 0; @@ -190,31 +195,7 @@ // creating the patterns above can be done more efficient, however // this approach feels more readable, while initialization, i.e. // executing the constructor, is done once -int16_t TII_Detector::A (uint8_t dabMode, uint8_t c, uint8_t p, int16_t k) { - if (dabMode == 2) - return A_mode_2 (c, p, k); - if (dabMode == 4) - return A_mode_4 (c, p, k); - return A_mode_1 (c, p, k); -} - -int16_t TII_Detector::A_mode_2 (uint8_t c, uint8_t p, int16_t k) { -int16_t res = 0; -int16_t b; - - if ((-192 <= k) && (k < - 191)) { - for (b = 0; b <= 3; b ++) - res += delta (k, -192 + 2 * c + 48 * b) * getbit (table [p], b); - for (b = 4; b <= 7; b ++) - res += delta (k, -191 + 2 * c + 48 * b) * getbit (table [p], b); - } - return res; -} - -int16_t TII_Detector::A_mode_4 (uint8_t c, uint8_t p, int16_t k) { -} - -int16_t TII_Detector::A_mode_1 (uint8_t c, uint8_t p, int16_t k) { +int16_t TII_Detector::A (uint8_t c, uint8_t p, int16_t k) { int16_t b; int16_t res = 0; @@ -239,8 +220,6 @@ return res; } // -// If we know the "mainId" from the FIG0/22, we can try to locate -// the pattern and compute the C void TII_Detector::reset (void) { memset (theBuffer. data (), 0, T_u * sizeof (std::complex<float>)); @@ -260,192 +239,159 @@ cmul (fft_buffer [i], 0.1); } -// We collected some "spectra', and start correlating the -// combined spectrum with the pattern defined by the mainId +void TII_Detector::collapse (std::complex<float> *inVec, float *outVec) { +int i; -int16_t TII_Detector::find_C (int16_t mainId, int offset) { -int16_t i; -int16_t startCarrier = theTable [mainId]. carrier + offset; -uint64_t pattern = theTable [mainId]. pattern; -float maxCorr = -1; -int maxIndex = -1; -float avg = 0; -float corrTable [24]; + for (i = 0; i < carriers / 8; i ++) { + int carr = - carriers / 2 + 2 * i; + outVec [i] = abs (real (inVec [(T_u + carr) % T_u] * + conj (inVec [(T_u + carr + 1) % T_u]))); - if (mainId < 0) - return - 1; + carr = - carriers / 2 + 1 * carriers / 4 + 2 * i; + outVec [i] += abs (real (inVec [(T_u + carr) % T_u] * + conj (inVec [(T_u + carr + 1) % T_u]))); -// fprintf (stderr, "the carrier is %d\n", startCarrier); -// -// The "c" value is in the range 1 .. 23 - for (i = 1; i < 24; i ++) { - corrTable [i] = correlate (theBuffer, - startCarrier + 2 * i, - pattern, 2); - } + carr = - carriers / 2 + 2 * carriers / 4 + 2 * i + 1; + outVec [i] += abs (real (inVec [(T_u + carr) % T_u] * + conj (inVec [(T_u + carr + 1) % T_u]))); - for (i = 1; i < 24; i ++) { - avg += corrTable [i]; - if (corrTable [i] > maxCorr) { - maxCorr = corrTable [i]; - maxIndex = i; - } + carr = - carriers / 2 + 3 * carriers / 4 + 2 * i + 1; + outVec [i] += abs (real (inVec [(T_u + carr) % T_u] * + conj (inVec [(T_u + carr + 1) % T_u]))); } - - avg /= 23; - if (maxCorr < 2 * avg) - maxIndex = -1; - - return maxIndex; } -#define MAX_TABLE 4 -// The difficult one: guessing for Mode 1 only + +#define NUM_GROUPS 8 +#define GROUPSIZE 24 void TII_Detector::processNULL (int16_t *mainId, int16_t *subId) { int i, j; -float avg = 0; -int16_t startCarrier = -1; -int maxTable [MAX_TABLE]; -float maxValues [MAX_TABLE]; - +float hulpTable [NUM_GROUPS * GROUPSIZE]; +float C_table [GROUPSIZE]; // contains the values +int D_table [GROUPSIZE]; // count of indices in C_table with data +float avgTable [NUM_GROUPS]; +float minTable [NUM_GROUPS]; +// +// defaults: *mainId = -1; *subId = -1; - for (i = 0; i < MAX_TABLE; i ++) { - maxTable [i] = 0; - maxValues [i] = 0; - } - for (i = -carriers / 2; i < -carriers / 4; i += 2) { - float temp = abs (real (theBuffer [(T_u + i) % T_u] * - conj (theBuffer [(T_u + i + 1) % T_u]))); - avg += temp; - int k; - for (j = 0; j < MAX_TABLE; j ++) { - if (maxValues [j] < temp) { - for (k = MAX_TABLE - 1; k > j; k --) { - if (k > 0) { - maxTable [k] = maxTable [k - 1]; - maxValues [k] = maxValues [k - 1]; - } - } - maxValues [j] = temp; - maxTable [j] = i; - break; - } +// we map the "carriers" carriers (complex values) onto +// a collapsed vector of "carriers / 8" length, +// considered to consist of 8 segments of 24 values +// Each "value" is the sum of 4 pairs of subsequent carriers, +// taken from the 4 quadrants -768 .. 385, 384 .. -1, 1 .. 384, 385 .. 768 + + collapse (theBuffer. data (), hulpTable); +// +// since the "energy levels" in the different GROUPSIZE'd values +// may differ, we compute an average for each of the +// NUM_GROUPS GROUPSIZE-value groups. + + memset (avgTable, 0, NUM_GROUPS * sizeof (float)); + for (i = 0; i < NUM_GROUPS; i ++) { + minTable [i] = hulpTable [i * GROUPSIZE + 0]; + avgTable [i] = 0; + for (j = 0; j < GROUPSIZE; j ++) { + avgTable [i] += hulpTable [i * GROUPSIZE + j]; + if (hulpTable [i * GROUPSIZE + j] < minTable [i]) + minTable [i] = hulpTable [i * GROUPSIZE + j]; } + avgTable [i] /= GROUPSIZE; } - avg /= (carriers / 4); - -// for (j = 0; j < MAX_TABLE; j ++) -// fprintf (stderr, "%d -> %f\n", maxTable [j], maxValues [j]); -// fprintf (stderr, "avg -> %f\n", avg); - for (j = 0; j < MAX_TABLE; j ++) { - startCarrier = maxTable [j]; - int index = (T_u + startCarrier) % T_u; - int main_1 = -1, main_2 = -1; - int subId_1 = -1, subId_2 = 1; // -// 5 * avg is a rather arbitrary threshold, sometimes we see -// values of 100 * avg - if (abs (real (theBuffer [index] * - conj (theBuffer [index + 1]))) < 10 * avg) - continue; - - float maxCorr = 0; - int pattern = 0; - for (i = 0; i < 70; i ++) { - if ((startCarrier < theTable [i]. carrier) || - (theTable [i]. carrier + 48 <= startCarrier)) - continue; - float corr = correlate (theBuffer, - startCarrier, - theTable [i]. pattern, 2); - if (corr > maxCorr) { - maxCorr = corr; - main_1 = i; - subId_1 = (startCarrier - theTable [i]. carrier) / 2; - pattern = i; +// +// Determining the offset is then easy, look at the corresponding +// elements in the NUM_GROUPS sections and mark the highest ones +// The summation of the high values are stored in the C_table, +// the number of times the limit is reached in the group +// is recorded in the D_table +// +// Threshold 4 * avgTable is 6dB, we consider that a minimum +// measurement shows that that is a reasonable value, +// alternatively, we could take the "minValue" as reference +// and "raise" the threshold. However, while that might be +// too much for 8-bit incoming values + memset (D_table, 0, GROUPSIZE * sizeof (int)); + memset (C_table, 0, GROUPSIZE * sizeof (float)); +// + for (j = 0; j < NUM_GROUPS; j ++) { + for (i = 0; i < GROUPSIZE; i ++) { + if (hulpTable [j * GROUPSIZE + i] > 4 * avgTable [j]) { +// fprintf (stderr, "index (%d, %d) -> %f (%f)\n", +// i, j, +// 10 * log10 (hulpTable [j * GROUPSIZE + i] / avgTable [j]), +// 10 * log10 (hulpTable [j * GROUPSIZE + i] / minTable [j])); + C_table [i] += hulpTable [j * GROUPSIZE + i]; + D_table [i] ++; } } + } -// if (main_1 > 0) -// fprintf (stderr, "we found pattern %d, startCarrier %d\n", -// pattern, theTable [pattern]. carrier); -// we might have found a (mainId, subId) pair, -// verification is by looking two segments further for a match - if ((main_1 != -1) && (subId_1 != -1)) { - int subId_2 = find_C (main_1, carriers / 2); -// fprintf (stderr, "we find %d and %d\n", subId_1, subId_2); - if (subId_1 == subId_2) { - *mainId = main_1; - *subId = subId_1; - return; - } +// +// we extract from this result the two highest values that +// meet the constraint of 4 values being sufficiently high + float Max_1 = 0; + int ind1 = -1; + float Max_2 = 0; + int ind2 = -1; + + for (j = 0; j < GROUPSIZE; j ++) { + if ((D_table [j] >= 4) && (C_table [j] > Max_1)) { + Max_2 = Max_1; + ind1 = ind2; + Max_1 = C_table [j]; + ind1 = j; + } + else + if ((D_table [j] >= 4) && (C_table [j] > Max_2)) { + Max_2 = C_table [j]; + ind2 = j; } } -} - // +// The - almost - final step is then to figure out which +// groups contributed, obviously only where ind1 > 0 +// we start with collecting the values of the correct +// elements of the NUM_GROUPS groups // -// It turns out that the location "startIndex + k * 48" -// and "startIndex + k * 48 + 1" both contain the refTable -// value from "startIndex + k * 48" (where k is 1 .. 5, determined -// by the pattern). Since there might be a pretty large -// phase difference between the values in the spectrum of the -// null period here and the values in the predefined refTable, -// we just correlate here over the values here +// for the qt-dab, we only need the "top" performer + if (ind1 > 0) { + uint16_t pattern = 0; + float x [NUM_GROUPS]; + for (i = 0; i < NUM_GROUPS; i ++) + x [i] = hulpTable [ind1 + GROUPSIZE * i]; // -float TII_Detector::correlate (std::vector<complex<float>> v, - int16_t startCarrier, - uint64_t pattern, int segments) { -static bool flag = true; -int16_t realIndex; -int16_t i; -int16_t carrier; -float s1 = 0; -float avg = 0; - - if (pattern == 0) - return 0; - - carrier = startCarrier; - s1 = abs (real (v [(T_u + startCarrier) % T_u] * - conj (v [(T_u + startCarrier + 1) % T_u]))); - for (i = 0; i < 4 * segments; i ++) { -// for (i = 0; i < 15; i ++) { - carrier += ((pattern >> 56) & 0xF) * 48; - realIndex = carrier < 0 ? T_u + carrier : carrier + 1; - float x = abs (real (v [realIndex] * - conj (v [realIndex + 1]))); - s1 += x; - pattern <<= 4; +// we extract the four max values (it is known that they exist) + for (i = 0; i < 4; i ++) { + float mmax = 0; + int ind = -1; + for (j = 0; j < NUM_GROUPS; j ++) { + if (x [j] > mmax) { + mmax = x [j]; + ind = j; + } + } + if (ind != -1) { + int index = ind; + x [ind] = 0; + pattern |= bits [ind]; + } + } +// +// The final step is then to do the mapping of the bits +// The mainId is found using the match with the invTable + *mainId = int (invTable [pattern]); + *subId = ind1; + return; } - - return s1 / 15; } -void TII_Detector:: createPattern (uint8_t dabMode) { - switch (dabMode) { - default: - case 1: - createPattern_1 (); - break; - - case 2: - createPattern_2 (); - break; - - case 4: - createPattern_4 (); - break; - } -} -void TII_Detector::createPattern_1 (void) { +void TII_Detector:: createPattern (void) { int p, k, c; -uint8_t dabMode = 1; for (p = 0; p < 70; p ++) { int16_t digits = 0; @@ -454,7 +400,7 @@ bool first = true; int lastOne = 0; for (k = -carriers / 2; k < -carriers / 4; k ++) { - if (A (dabMode, c, p, k) > 0) { + if (A (c, p, k) > 0) { if (first) { first = false; theTable [p]. carrier = k; @@ -470,7 +416,7 @@ } for (k = -carriers / 4; k < 0; k ++) { - if (A (dabMode, c, p, k) > 0) { + if (A (c, p, k) > 0) { theTable [p]. pattern <<= 4; theTable [p]. pattern |= (k - lastOne) / 48; lastOne = k; @@ -479,7 +425,7 @@ } for (k = 1; k <= carriers / 4; k ++) { - if (A (dabMode, c, p, k) > 0) { + if (A (c, p, k) > 0) { theTable [p]. pattern <<= 4; theTable [p]. pattern |= (k - lastOne) / 48; lastOne = k; @@ -488,7 +434,7 @@ } for (k = carriers / 4 + 1; k <= carriers / 2; k ++) { - if (A (dabMode, c, p, k) > 0) { + if (A (c, p, k) > 0) { theTable [p]. pattern <<= 4; theTable [p]. pattern |= (k - lastOne) / 48; lastOne = k; @@ -502,10 +448,42 @@ } } - -void TII_Detector::createPattern_2 (void) { +int shorten (int carrier) { + if (carrier > 1 + 384) + carrier = carrier - 1 - 3 * 384; + if (carrier > 0) + carrier = carrier - 1 - 2 * 384; + if (carrier > -384) + carrier = carrier - 384; + return carrier; } -void TII_Detector::createPattern_4 (void) { +void TII_Detector::printOverlap (int pNum, int cNum) { +int i, j; +int carrier = theTable [pNum]. carrier + cNum * 2; +uint64_t pattern = theTable [pNum]. pattern; +int list [16]; +int list_2 [16]; +bool changes; + + fprintf (stderr, "p (%d) %d:\t", pNum, theTable [pNum]. carrier); + + for (i = 0; i < 15; i ++) { + + carrier += ((pattern >> 56) & 0xF) * 48; + list [i] = carrier; + if (list [i] >= 0) list [i] ++; + pattern <<= 4; + list_2 [i] = shorten (list [i]); + } + +// for (i = 0; i < 15; i ++) +// fprintf (stderr, " %d", list [i]); + fprintf (stderr, " || "); + for (i = 0; i < 15; i ++) + fprintf (stderr, " %d", list_2 [i]); + + fprintf (stderr, "\n"); } +
View file
qt-dab-2.0git20181030.tar.gz/tii_detection.txt
Added
@@ -0,0 +1,60 @@ + + +tii_detection always was found to be a problem. In fact it is +trivial to solve, but due to an error in a generating program +I missed that. + +The way tii is encoded is simple, it is a 4 out of 8 code for the +mainId, and a 1 .. 23 offset for the subId. + +The code maps by assigning bit values to the positions in the +8 bits. The first bit has a value of 0x80, the seconds 0x40 etc. + +The 4/8 code is implemented in 8 0/1 values with corresponding indices +each in a segment of 24 values. So, an encoded value is represented +in the fft by 4 non-null values, appearing at a distance of N * 24 +elements. + +Note 1: + null value not to be taken to litterally, there is noise +Note 2: + elements consists of two subsequent bins (carriers) in the fft + +The offset indicates the position in the 24 value segments, and is +- obviously - the same for all four high values in the set of 8 values. + +Decoding is then straight forward, it is restricted to DAB Mode 1. + +The carriers, -768 .. 768, are collapsed onto a vector of 192 (8 * 24) +length. The transmitted pattern is repeated, it occurs 4 times, +and each offset value takes 2 carriers. + +After collapsing, the 192 value vector is considered to consist +of 6 segments of 24 values. +A search is made in these 8 segments to locate the elements with the highest +(or high-enough) values, and the number of times these elements +are detected is maintained in a separate 24 bit element vector. + +The sum of the high values determines the offset, the pattern seen +in the corresponding elements in the 8 24 value segments determine +a pattern. + +The "value" of the pattern - bit encoded as stated above - +is used in an index table to locate the corresponding 'P' value + + +============================================================================ + +What was I doing wrong: + +Using a simple generator I had the - erroneous - impression that +the pattern that could occur were NOT unique. Apparently an error +in my generator. By the search to patters starting and stopping with +a "1", patterns were not unique, of course by looking at the patters +consisting of the full 8 0/1 values they are unique. + +Assuming the pattern were NOT unique, a search had to be +made to allowable patterns for each starting position in the +transmitted null period. + +
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.