summaryrefslogtreecommitdiffstats
path: root/demos/spectrum/app/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'demos/spectrum/app/utils.cpp')
-rw-r--r--demos/spectrum/app/utils.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/demos/spectrum/app/utils.cpp b/demos/spectrum/app/utils.cpp
index 4ead6c2..49a7626 100644
--- a/demos/spectrum/app/utils.cpp
+++ b/demos/spectrum/app/utils.cpp
@@ -49,8 +49,10 @@ qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
qint64 audioLength(const QAudioFormat &format, qint64 microSeconds)
{
- return (format.frequency() * format.channels() * (format.sampleSize() / 8))
+ qint64 result = (format.frequency() * format.channels() * (format.sampleSize() / 8))
* microSeconds / 1000000;
+ result -= result % (format.channelCount() * format.sampleSize());
+ return result;
}
qreal nyquistFrequency(const QAudioFormat &format)