diff --git a/README.md b/README.md index fcb31d99..4244849e 100755 --- a/README.md +++ b/README.md @@ -265,7 +265,7 @@ The device widget gives information what the "type" of the file is (RIFF or BW64 ![6.8](/res/read_me/riff-reader-small.png?raw=true) When reading input from an ".sdr" file that was **generated by Qt-DAB** -the channel frequency of the reception is displayed as shown in the pictures above. +both the name of the SDR device as well as the channel frequency of the reception is displayed as shown in the pictures above. * reading prerecorded dump rtlsdr type "raw" (8 bits) files. The RTLSDR device handlers show a button "dump" for dumping the raw input into a ".raw" file. diff --git a/res/read_me/riff-reader-large.png b/res/read_me/riff-reader-large.png index e8872511..e10d71a6 100644 Binary files a/res/read_me/riff-reader-large.png and b/res/read_me/riff-reader-large.png differ diff --git a/res/read_me/riff-reader-small.png b/res/read_me/riff-reader-small.png index f8690350..1c076986 100644 Binary files a/res/read_me/riff-reader-small.png and b/res/read_me/riff-reader-small.png differ diff --git a/sources/devices/filereaders/filereader-widget.h b/sources/devices/filereaders/filereader-widget.h index 4c8e5755..e77d1a33 100644 --- a/sources/devices/filereaders/filereader-widget.h +++ b/sources/devices/filereaders/filereader-widget.h @@ -37,6 +37,8 @@ public: QLCDNumber *currentTime; QLabel *seconds; QLCDNumber *totalTime; + QLabel *deviceLabel; + QLabel *theDevice; QLabel *typeLabel; QLabel *typeOfFile; QLabel *amountLabel; @@ -48,6 +50,8 @@ public: void setupUi (QWidget *qw) { titleLabel = new QLabel ("Playing pre-recorded file"); nameofFile = new QLabel (); + deviceLabel = new QLabel (); + theDevice = new QLabel (); typeLabel = new QLabel ("filetype "); typeOfFile = new QLabel (); amountLabel = new QLabel (" nr samples "); @@ -64,11 +68,14 @@ void setupUi (QWidget *qw) { totalTime -> setFrameShape (QFrame::NoFrame); totalTime -> setSegmentStyle (QLCDNumber::Flat); QHBoxLayout *line_2 = new QHBoxLayout (); - line_2 -> addWidget (typeLabel); - line_2 -> addWidget (typeOfFile); - line_2 -> addWidget (amountLabel); - line_2 -> addWidget (sampleCount); - line_2 -> addWidget (frequencyLabel); + line_2 -> addWidget (deviceLabel); + line_2 -> addWidget (theDevice); + QHBoxLayout *line_3 = new QHBoxLayout (); + line_3 -> addWidget (typeLabel); + line_3 -> addWidget (typeOfFile); + line_3 -> addWidget (amountLabel); + line_3 -> addWidget (sampleCount); + line_3 -> addWidget (frequencyLabel); QHBoxLayout *bottom = new QHBoxLayout (); bottom -> addWidget (currentTime); bottom -> addWidget (seconds); @@ -78,6 +85,7 @@ void setupUi (QWidget *qw) { base -> addWidget (titleLabel); base -> addWidget (nameofFile); base -> addItem (line_2); + base -> addItem (line_3); base -> addWidget (fileProgress); base -> addItem (bottom); diff --git a/sources/devices/filereaders/new-reader/newfiles.cpp b/sources/devices/filereaders/new-reader/newfiles.cpp index e45de150..3ddd1ff9 100644 --- a/sources/devices/filereaders/new-reader/newfiles.cpp +++ b/sources/devices/filereaders/new-reader/newfiles.cpp @@ -40,6 +40,7 @@ newFilesSettings = s; setupUi (&myFrame); setPositionAndSize (s, &myFrame, WAVSETTINGS); + myFrame. setWindowTitle ("BW64/RIFF reader"); myFrame. show (); this -> fileName = fileName; @@ -48,7 +49,12 @@ currentTime -> display (0); int64_t fileLength = theReader. elementCount (); QString fileType = theReader. fileType (); + QString deviceName = theReader. getDevice (); totalTime -> display ((float)fileLength / SAMPLERATE); + if (deviceName != "") { + deviceLabel -> setText ("Generating device: "); + theDevice -> setText (deviceName); + } typeOfFile -> setText (fileType); sampleCount -> setText (QString::number (fileLength)); int32_t Freq = theReader. getVFOFrequency (); diff --git a/sources/devices/filereaders/new-reader/riff-reader.cpp b/sources/devices/filereaders/new-reader/riff-reader.cpp index 9f915cea..7cbcb0d0 100644 --- a/sources/devices/filereaders/new-reader/riff-reader.cpp +++ b/sources/devices/filereaders/new-reader/riff-reader.cpp @@ -44,9 +44,10 @@ uint32_t segmentSize; char header [5]; header [4] = 0; - bitDepth = 15; // default + bitDepth = 0; // i.e. unknown tunedFrequency = -1; denominator = 0; + theDevice = ""; filePointer = fopen (fileName. toLatin1 (). data (), "rb"); if (filePointer == nullptr) { QString val = @@ -173,6 +174,12 @@ char header [5]; else if (QString (header) == "bits") fread (&bitDepth, 1, 4, filePointer); + else + if (QString (header) == "sys ") { + char temp [255]; + fread (temp, 1, segmentSize, filePointer); + theDevice = QString (temp); + } else fseek (filePointer, segmentSize, SEEK_CUR); fread (header, 1, 4, filePointer); @@ -184,7 +191,7 @@ char header [5]; } } - denominator = value_for (bitDepth); + denominator = bitDepth != 0 ? value_for (bitDepth) : 32768; if (QString (header) != "data") { // should not happen QString val = QString ("File '%1' is no valid SDR file").arg(fileName); @@ -298,6 +305,12 @@ char header [5]; else if (QString (header) == "bits") fread (&bitDepth, 1, 4, filePointer); + else + if (QString (header) == "sys ") { + char temp [255]; + fread (temp, 1, segmentSize, filePointer); + theDevice = QString (temp); + } else fseek (filePointer, segmentSize, SEEK_CUR); fread (header, 1, 4, filePointer); @@ -309,7 +322,7 @@ char header [5]; } } - denominator = value_for (bitDepth); + denominator = bitDepth != 0 ? value_for (bitDepth): 32768; if (QString (header) != "data") { // should not happen QString val = QString ("File '%1' is no valid SDR file").arg(fileName); @@ -405,3 +418,7 @@ int riffReader::getVFOFrequency () { return tunedFrequency; } +QString riffReader::getDevice () { + return theDevice; +} + diff --git a/sources/devices/filereaders/new-reader/riff-reader.h b/sources/devices/filereaders/new-reader/riff-reader.h index 03b8b8bb..ff99a366 100644 --- a/sources/devices/filereaders/new-reader/riff-reader.h +++ b/sources/devices/filereaders/new-reader/riff-reader.h @@ -37,11 +37,12 @@ public: uint64_t elementCount (); QString fileType (); uint64_t currentPos (); - int getVFOFrequency (); + QString getDevice (); private: QString fileName; + QString theDevice; uint16_t formatTag; uint16_t nrChannels; uint32_t samplingRate; diff --git a/sources/devices/filereaders/rawfiles-new/rawfiles.cpp b/sources/devices/filereaders/rawfiles-new/rawfiles.cpp index 5d6428d8..d5f43c50 100644 --- a/sources/devices/filereaders/rawfiles-new/rawfiles.cpp +++ b/sources/devices/filereaders/rawfiles-new/rawfiles.cpp @@ -48,6 +48,7 @@ this -> fileName = fileName; setupUi (&myFrame); setPositionAndSize (s, &myFrame, RAWSETTINGS); + myFrame. setWindowTitle ("Reader for raw (8 bit osmocom type) files"); myFrame. show (); filePointer = fopen (fileName. toUtf8 (). data (), "rb"); diff --git a/sources/frontend/fib-decoder.cpp b/sources/frontend/fib-decoder.cpp index 317d4993..9561b350 100644 --- a/sources/frontend/fib-decoder.cpp +++ b/sources/frontend/fib-decoder.cpp @@ -923,7 +923,17 @@ const int16_t Length = getBits_5 (d, 3); const uint8_t CN_bit = getBits_1 (d, 8 + 0); const uint8_t OE_bit = getBits_1 (d, 8 + 1); const uint8_t PD_bit = getBits_1 (d, 8 + 2); - fprintf (stderr, "Fig20\n"); +#ifndef __MINGW32__ + static bool shown = false; + if (!shown) { + if (theEnsemble. namePresent) { + fprintf (stderr, "FIG0/20 appears in %s\n", + theEnsemble. ensembleName. + toLatin1 (). data ()); + shown = true; + } + } +#endif return; while (used < Length) used = HandleFIG0Extension21 (d, used, CN_bit, OE_bit, PD_bit); diff --git a/sources/frontend/ofdm-handler.cpp b/sources/frontend/ofdm-handler.cpp index adf13e86..8085eaf1 100644 --- a/sources/frontend/ofdm-handler.cpp +++ b/sources/frontend/ofdm-handler.cpp @@ -643,8 +643,8 @@ bool ofdmHandler::setDataChannel (packetdata &d, } void ofdmHandler::startDumping (const QString &f, int freq, - int bitDepth) { - theReader. startDumping (f, freq, bitDepth); + int bitDepth, const QString creator) { + theReader. startDumping (f, freq, bitDepth, creator); } void ofdmHandler::stopDumping() { diff --git a/sources/frontend/ofdm-handler.h b/sources/frontend/ofdm-handler.h index 0800d5bb..d7b271d8 100644 --- a/sources/frontend/ofdm-handler.h +++ b/sources/frontend/ofdm-handler.h @@ -62,7 +62,8 @@ public: void stop (); void selectTII (uint8_t); - void startDumping (const QString &, int, int); + void startDumping (const QString &, int, + int, const QString); void stopDumping (); bool startEtiGenerator (const QString &); void stopEtiGenerator (); diff --git a/sources/frontend/sample-reader.cpp b/sources/frontend/sample-reader.cpp index cdf0f99e..22f0ef4e 100644 --- a/sources/frontend/sample-reader.cpp +++ b/sources/frontend/sample-reader.cpp @@ -185,8 +185,10 @@ auto *buffer = dynVec (std::complex, nrSamples); } void sampleReader::startDumping (const QString &fileName, - int freq, int bitDepth) { - sourceDumper. init (fileName, SAMPLERATE, freq, bitDepth); + int freq, int bitDepth, + const QString deviceName) { + sourceDumper. init (fileName, SAMPLERATE, + freq, bitDepth, deviceName); } void sampleReader::stopDumping() { diff --git a/sources/frontend/sample-reader.h b/sources/frontend/sample-reader.h index 781f5876..dfcc7d13 100644 --- a/sources/frontend/sample-reader.h +++ b/sources/frontend/sample-reader.h @@ -55,7 +55,7 @@ public: void getSamples (std::vector &v, int index, int32_t n, int32_t phase, bool saving); - void startDumping (const QString &, int, int); + void startDumping (const QString &, int, int, const QString); void stopDumping (); private: riffWriter sourceDumper; diff --git a/sources/main/radio.cpp b/sources/main/radio.cpp index 158b0fa4..38b412e8 100644 --- a/sources/main/radio.cpp +++ b/sources/main/radio.cpp @@ -3476,7 +3476,9 @@ QString channelName = channel. channelName; deviceName, channelName); configHandler_p -> mark_dumpButton (true); theOFDMHandler -> startDumping (rawDumpName, - channel. tunedFrequency, bitDepth); + channel. tunedFrequency, + bitDepth, + inputDevice_p -> deviceName ()); sourceDumping = true; } diff --git a/sources/support/riffWriter.cpp b/sources/support/riffWriter.cpp index 1762fb88..77c1bd5a 100644 --- a/sources/support/riffWriter.cpp +++ b/sources/support/riffWriter.cpp @@ -43,6 +43,8 @@ const char * aux1 = "freq"; static const char * aux2 = "bits"; static +const char * aux3 = "sys "; +static const char * data = "data"; riffWriter::riffWriter () { @@ -52,7 +54,8 @@ const char * data = "data"; riffWriter::~riffWriter () {} bool riffWriter::init (const QString &fileName, const int sampleRate, - const int frequency, const int bitDepth) { + const int frequency, const int bitDepth, + QString creatorText) { isValid = false; filePointer = fopen (fileName. toUtf8 (). data (), "wb"); if (filePointer == nullptr) @@ -123,6 +126,17 @@ bool riffWriter::init (const QString &fileName, const int sampleRate, fwrite (&bitDepth, 1, 4, filePointer); locationCounter += 4; } +// the "creator" chunk + if (bitDepth > 0) { + fwrite (aux3, 1, 4, filePointer); + locationCounter += 4; + int size = strlen (creatorText. toLatin1 (). data ()); + locationCounter += 4; + fwrite (&size, 1, 4, filePointer); + locationCounter += 4; + fwrite (creatorText. toLatin1 (). data (), 1, size, filePointer); + locationCounter += size; + } // // start of the "data" chunk fwrite (data, 1, 4, filePointer); diff --git a/sources/support/riffWriter.h b/sources/support/riffWriter.h index 0163d587..cb2a5d0b 100644 --- a/sources/support/riffWriter.h +++ b/sources/support/riffWriter.h @@ -32,7 +32,8 @@ public: riffWriter (); ~riffWriter (); bool init (const QString &, int, - int bitDepth = 0, int frequency = 0); + int bitDepth = 0, int frequency = 0, + QString creator = "Qt-DAB-6.9.3"); void write (int16_t *buff, uint64_t samples); void close (); bool isActive ();