diff --git a/src/audio/AudioStreamSegment.cpp b/src/audio/AudioStreamSegment.cpp index 80fbfad..1b703a9 100644 --- a/src/audio/AudioStreamSegment.cpp +++ b/src/audio/AudioStreamSegment.cpp @@ -2,10 +2,10 @@ #include AudioStreamSegment::AudioStreamSegment(std::unique_ptr audioStream, const TimeRange& range) : - audioStream(std::move(audioStream)) + audioStream(std::move(audioStream)), + sampleOffset(static_cast(range.getStart().count()) * this->audioStream->getSampleRate() / 100), + sampleCount(static_cast(range.getLength().count()) * this->audioStream->getSampleRate() / 100) { - sampleOffset = range.getStart().count() * this->audioStream->getSampleRate() / 100; - sampleCount = range.getLength().count() * this->audioStream->getSampleRate() / 100; seek(0); if (sampleOffset < 0 || sampleOffset + sampleCount > this->audioStream->getSampleCount()) { diff --git a/src/audio/AudioStreamSegment.h b/src/audio/AudioStreamSegment.h index 3d0c553..07476ab 100644 --- a/src/audio/AudioStreamSegment.h +++ b/src/audio/AudioStreamSegment.h @@ -15,7 +15,7 @@ public: private: std::unique_ptr audioStream; - int64_t sampleOffset, sampleCount; + const int64_t sampleOffset, sampleCount; }; std::unique_ptr createSegment(std::unique_ptr audioStream, const TimeRange& range);