From 13449c1926a14db8df6c6127ba2446490a6fc518 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Tue, 3 Nov 2026 20:01:49 -0500 Subject: [PATCH] wavfilerecord: Add software identification to recorded WAV files Write application name and version to the RIFF LIST/INFO/ISFT chunk in recorded WAV files. Skip LIST chunks when reading WAV files to avoid warnings for files containing metadata. Signed-off-by: Robin Getz --- sdrbase/dsp/wavfilerecord.cpp | 52 +++++++++++++++++++++++++++++++++++ sdrbase/dsp/wavfilerecord.h | 5 ++++ 2 files changed, 57 insertions(+) diff --git a/sdrbase/dsp/wavfilerecord.cpp b/sdrbase/dsp/wavfilerecord.cpp index 099ef8dd4..d470b46c9 100644 --- a/sdrbase/dsp/wavfilerecord.cpp +++ b/sdrbase/dsp/wavfilerecord.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -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 } 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(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; diff --git a/sdrbase/dsp/wavfilerecord.h b/sdrbase/dsp/wavfilerecord.h index 4dd6f6393..8188cdaa2 100644 --- a/sdrbase/dsp/wavfilerecord.h +++ b/sdrbase/dsp/wavfilerecord.h @@ -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;