mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
FileSource: calculate file record length down to the microsecond. Implements #614
This commit is contained in:
parent
47a1eeaedc
commit
096dd0d2b0
@ -464,7 +464,7 @@ void FileSource::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& respon
|
||||
quint64 samplesCount = m_basebandSource->getSamplesCount();
|
||||
uint32_t fileSampleRate = m_basebandSource->getFileSampleRate();
|
||||
quint64 startingTimeStamp = m_basebandSource->getStartingTimeStamp();
|
||||
quint64 fileRecordLength = m_basebandSource->getRecordLength();
|
||||
quint64 fileRecordLength = m_basebandSource->getRecordLengthMuSec() / 1000000UL;
|
||||
quint32 fileSampleSize = m_basebandSource->getFileSampleSize();
|
||||
|
||||
if (fileSampleRate > 0)
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
|
||||
uint32_t getFileSampleRate() const { return m_source.getFileSampleRate(); }
|
||||
quint64 getStartingTimeStamp() const { return m_source.getStartingTimeStamp(); }
|
||||
quint64 getRecordLength() const { return m_source.getRecordLength(); }
|
||||
quint64 getRecordLengthMuSec() const { return m_source.getRecordLengthMuSec(); }
|
||||
quint32 getFileSampleSize() const { return m_source.getFileSampleSize(); }
|
||||
|
||||
void getMagSqLevels(double& avg, double& peak, int& nbSamples) const
|
||||
|
@ -117,7 +117,7 @@ bool FileSourceGUI::handleMessage(const Message& message)
|
||||
m_fileSampleRate = ((FileSourceReport::MsgReportFileSourceStreamData&)message).getSampleRate();
|
||||
m_fileSampleSize = ((FileSourceReport::MsgReportFileSourceStreamData&)message).getSampleSize();
|
||||
m_startingTimeStamp = ((FileSourceReport::MsgReportFileSourceStreamData&)message).getStartingTimeStamp();
|
||||
m_recordLength = ((FileSourceReport::MsgReportFileSourceStreamData&)message).getRecordLength();
|
||||
m_recordLengthMuSec = ((FileSourceReport::MsgReportFileSourceStreamData&)message).getRecordLengthMuSec();
|
||||
updateWithStreamData();
|
||||
return true;
|
||||
}
|
||||
@ -188,7 +188,7 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
|
||||
m_shiftFrequencyFactor(0.0),
|
||||
m_fileSampleRate(0),
|
||||
m_fileSampleSize(0),
|
||||
m_recordLength(0),
|
||||
m_recordLengthMuSec(0),
|
||||
m_startingTimeStamp(0),
|
||||
m_samplesCount(0),
|
||||
m_acquisition(false),
|
||||
@ -277,8 +277,8 @@ void FileSourceGUI::updateWithStreamData()
|
||||
ui->sampleRateText->setText(tr("%1k").arg((float) m_fileSampleRate / 1000));
|
||||
ui->sampleSizeText->setText(tr("%1b").arg(m_fileSampleSize));
|
||||
QTime recordLength(0, 0, 0, 0);
|
||||
recordLength = recordLength.addSecs(m_recordLength);
|
||||
QString s_time = recordLength.toString("HH:mm:ss");
|
||||
recordLength = recordLength.addMSecs(m_recordLengthMuSec/1000UL);
|
||||
QString s_time = recordLength.toString("HH:mm:ss.zzz");
|
||||
ui->recordLengthText->setText(s_time);
|
||||
updateWithStreamTime();
|
||||
}
|
||||
@ -309,7 +309,7 @@ void FileSourceGUI::updateWithStreamTime()
|
||||
|
||||
if (!m_enableNavTime)
|
||||
{
|
||||
float posRatio = (float) t_sec / (float) m_recordLength;
|
||||
float posRatio = (float) (t_sec*1000000L + t_msec*1000L) / (float) m_recordLengthMuSec;
|
||||
ui->navTime->setValue((int) (posRatio * 1000.0));
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
QString m_fileName;
|
||||
int m_fileSampleRate;
|
||||
quint32 m_fileSampleSize;
|
||||
quint64 m_recordLength;
|
||||
quint64 m_recordLengthMuSec;
|
||||
quint64 m_startingTimeStamp;
|
||||
quint64 m_samplesCount;
|
||||
bool m_acquisition;
|
||||
|
@ -641,7 +641,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -649,7 +649,7 @@
|
||||
<string>Total record time</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00:00:00</string>
|
||||
<string>00:00:00.000</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -52,15 +52,15 @@ public:
|
||||
quint32 getSampleSize() const { return m_sampleSize; }
|
||||
quint64 getCenterFrequency() const { return m_centerFrequency; }
|
||||
quint64 getStartingTimeStamp() const { return m_startingTimeStamp; }
|
||||
quint64 getRecordLength() const { return m_recordLength; }
|
||||
quint64 getRecordLengthMuSec() const { return m_recordLengthMuSec; }
|
||||
|
||||
static MsgReportFileSourceStreamData* create(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
quint64 recordLength)
|
||||
quint64 recordLengthMuSec)
|
||||
{
|
||||
return new MsgReportFileSourceStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLength);
|
||||
return new MsgReportFileSourceStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLengthMuSec);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -68,19 +68,19 @@ public:
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
quint64 m_startingTimeStamp;
|
||||
quint64 m_recordLength;
|
||||
quint64 m_recordLengthMuSec;
|
||||
|
||||
MsgReportFileSourceStreamData(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
quint64 recordLength) :
|
||||
quint64 recordLengthMuSec) :
|
||||
Message(),
|
||||
m_sampleRate(sampleRate),
|
||||
m_sampleSize(sampleSize),
|
||||
m_centerFrequency(centerFrequency),
|
||||
m_startingTimeStamp(startingTimeStamp),
|
||||
m_recordLength(recordLength)
|
||||
m_recordLengthMuSec(recordLengthMuSec)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ FileSourceSource::FileSourceSource() :
|
||||
m_samplesCount(0),
|
||||
m_sampleRate(0),
|
||||
m_deviceSampleRate(0),
|
||||
m_recordLength(0),
|
||||
m_recordLengthMuSec(0),
|
||||
m_startingTimeStamp(0),
|
||||
m_running(false),
|
||||
m_guiMessageQueue(nullptr)
|
||||
@ -187,12 +187,12 @@ void FileSourceSource::openFileStream(const QString& fileName)
|
||||
if (crcOK)
|
||||
{
|
||||
qDebug("FileSourceSource::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / ((m_sampleSize == 24 ? 8 : 4) * m_fileSampleRate);
|
||||
m_recordLengthMuSec = ((fileSize - sizeof(FileRecord::Header)) * 1000000UL) / ((m_sampleSize == 24 ? 8 : 4) * m_fileSampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical("FileSourceSource::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = 0;
|
||||
m_recordLengthMuSec = 0;
|
||||
}
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
@ -203,12 +203,12 @@ void FileSourceSource::openFileStream(const QString& fileName)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recordLength = 0;
|
||||
m_recordLengthMuSec = 0;
|
||||
}
|
||||
|
||||
qDebug() << "FileSourceSource::openFileStream: " << m_fileName.toStdString().c_str()
|
||||
<< " fileSize: " << fileSize << " bytes"
|
||||
<< " length: " << m_recordLength << " seconds"
|
||||
<< " length: " << m_recordLengthMuSec << " microseconds"
|
||||
<< " sample rate: " << m_fileSampleRate << " S/s"
|
||||
<< " center frequency: " << m_centerFrequency << " Hz"
|
||||
<< " sample size: " << m_sampleSize << " bits"
|
||||
@ -220,11 +220,11 @@ void FileSourceSource::openFileStream(const QString& fileName)
|
||||
m_sampleSize,
|
||||
m_centerFrequency,
|
||||
m_startingTimeStamp,
|
||||
m_recordLength); // file stream data
|
||||
m_recordLengthMuSec); // file stream data
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
if (m_recordLength == 0) {
|
||||
if (m_recordLengthMuSec == 0) {
|
||||
m_ifstream.close();
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,8 @@ void FileSourceSource::seekFileStream(int seekMillis)
|
||||
{
|
||||
if ((m_ifstream.is_open()) && !m_running)
|
||||
{
|
||||
quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_fileSampleRate;
|
||||
quint64 seekPoint = ((m_recordLengthMuSec * seekMillis) / 1000) * m_fileSampleRate;
|
||||
seekPoint /= 1000000UL;
|
||||
m_samplesCount = seekPoint;
|
||||
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileRecord::Header)
|
||||
m_ifstream.clear();
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
uint32_t getFileSampleRate() const { return m_fileSampleRate; }
|
||||
quint64 getStartingTimeStamp() const { return m_startingTimeStamp; }
|
||||
quint64 getRecordLength() const { return m_recordLength; }
|
||||
quint64 getRecordLengthMuSec() const { return m_recordLengthMuSec; }
|
||||
quint32 getFileSampleSize() const { return m_sampleSize; }
|
||||
|
||||
private:
|
||||
@ -105,7 +105,7 @@ private:
|
||||
quint64 m_samplesCount;
|
||||
uint32_t m_sampleRate;
|
||||
uint32_t m_deviceSampleRate;
|
||||
quint64 m_recordLength; //!< record length in seconds computed from file size
|
||||
quint64 m_recordLengthMuSec; //!< record length in microseconds computed from file size
|
||||
quint64 m_startingTimeStamp;
|
||||
QTimer m_masterTimer;
|
||||
bool m_running;
|
||||
|
Loading…
Reference in New Issue
Block a user