diff --git a/src/abstractreader.cpp b/src/abstractreader.cpp --- a/src/abstractreader.cpp +++ b/src/abstractreader.cpp @@ -24,4 +24,23 @@ AbstractReader::AbstractReader(QIODevice { _device = device; _channelMan = channelMan; + + // initialize sps counter + sampleCount = 0; + samplesPerSecond = 0; + QObject::connect(&spsTimer, &QTimer::timeout, + this, &AbstractReader::spsTimerTimeout); + // TODO: start sps timer when reader is enabled + spsTimer.start(SPS_UPDATE_TIMEOUT * 1000); } + +void AbstractReader::spsTimerTimeout() +{ + unsigned currentSps = samplesPerSecond; + samplesPerSecond = (sampleCount/numOfChannels())/SPS_UPDATE_TIMEOUT; + if (currentSps != samplesPerSecond) + { + emit samplesPerSecondChanged(samplesPerSecond); + } + sampleCount = 0; +}