Browse Source

Merge pull request #3060 from rgetz/rgetz-add-sdrangel-to-wave

Add software identification to recorded WAV files
chirpmodem-v8.1.0
Edouard Griffiths 3 weeks ago committed by GitHub
parent
commit
8dbeb0f1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 52
      sdrbase/dsp/wavfilerecord.cpp
  2. 5
      sdrbase/dsp/wavfilerecord.h

52
sdrbase/dsp/wavfilerecord.cpp

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
#include <cstddef>
#include <cstring>
#include <QCoreApplication>
#include <QDebug>
#include <QDateTime>
#include <QRegularExpression>
@ -509,6 +510,48 @@ void WavFileRecord::writeHeader() @@ -509,6 +510,48 @@ void WavFileRecord::writeHeader()
header.m_auxi.m_unused5 = 0;
memset(&header.m_auxi.m_nextFilename[0], 0, 96);
QString appName = QCoreApplication::applicationName();
if (appName.isEmpty()) {
#ifdef APPLICATION_NAME
appName = APPLICATION_NAME;
#else
appName = "SDRAngel";
#endif
}
QString appVersion = QCoreApplication::applicationVersion();
if (appVersion.isEmpty()) {
#ifdef SDRANGEL_VERSION
appVersion = SDRANGEL_VERSION;
#endif
}
QString softwareString = appVersion.isEmpty()
? appName
: QString("%1 %2").arg(appName, appVersion);
QByteArray softwareBytes = softwareString.toUtf8();
header.m_listHeader.m_id[0] = 'L';
header.m_listHeader.m_id[1] = 'I';
header.m_listHeader.m_id[2] = 'S';
header.m_listHeader.m_id[3] = 'T';
header.m_listHeader.m_size = sizeof(header.m_infoType) + sizeof(Chunk) + sizeof(header.m_isftData);
header.m_infoType[0] = 'I';
header.m_infoType[1] = 'N';
header.m_infoType[2] = 'F';
header.m_infoType[3] = 'O';
header.m_isftHeader.m_id[0] = 'I';
header.m_isftHeader.m_id[1] = 'S';
header.m_isftHeader.m_id[2] = 'F';
header.m_isftHeader.m_id[3] = 'T';
header.m_isftHeader.m_size = sizeof(header.m_isftData);
memset(header.m_isftData, 0, sizeof(header.m_isftData));
std::memcpy(header.m_isftData, softwareBytes.constData(), qMin(size_t(softwareBytes.length()), sizeof(header.m_isftData) - 1));
// Make sure the chunk size covers the entire fixed array buffer written by the struct
header.m_dataHeader.m_id[0] = 'd';
header.m_dataHeader.m_id[1] = 'a';
header.m_dataHeader.m_id[2] = 't';
@ -719,6 +762,15 @@ bool WavFileRecord::readHeaderInternal(File& sampleFile, Header& header, bool ch @@ -719,6 +762,15 @@ bool WavFileRecord::readHeaderInternal(File& sampleFile, Header& header, bool ch
}
gotData = true;
}
else if (!strncmp(chunkHeader.m_id, "LIST", 4))
{
// Safely skip LIST INFO chunks without printing an "unknown section" warning
if (!skipBytes(sampleFile, static_cast<qint64>(chunkHeader.m_size) + (chunkHeader.m_size & 1)))
{
qDebug() << "WavFileRecord::readHeader: Error while skipping LIST";
return false;
}
}
else
{
qDebug() << "WavFileRecord::readHeader: skipping unknown section :" << chunkHeader.m_id;

5
sdrbase/dsp/wavfilerecord.h

@ -91,6 +91,11 @@ public: @@ -91,6 +91,11 @@ public:
quint16 m_bitsPerSample;
Chunk m_auxiHeader;
Auxi m_auxi;
Chunk m_listHeader; // "LIST"
char m_infoType[4]; // "INFO"
Chunk m_isftHeader; // "ISFT"
char m_isftData[64]; // App Name + Version
Chunk m_dataHeader;
QDateTime getStartTime() const;

Loading…
Cancel
Save