From f32aeb01bfc905ce2fdbc5b2f79e6f91a3f7b769 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 6 Jan 2010 20:24:56 +0000 Subject: Add a constructor to Timestamp, which allows for specifying seconds + start frames directly. svn-id: r47091 --- sound/timestamp.cpp | 9 +++++++++ sound/timestamp.h | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'sound') diff --git a/sound/timestamp.cpp b/sound/timestamp.cpp index f6ac56bfad..6cf0c8fa9f 100644 --- a/sound/timestamp.cpp +++ b/sound/timestamp.cpp @@ -46,6 +46,15 @@ Timestamp::Timestamp(uint32 ms, int fr) { _numberOfFrames = (ms % 1000) * _framerate / 1000; } +Timestamp::Timestamp(uint s, int frames, int fr) { + assert(fr > 0); + + _secs = s; + _framerateFactor = 1000 / gcd(1000, fr); + _framerate = fr * _framerateFactor; + _numberOfFrames = 0; + *this = addFrames(frames); +} Timestamp Timestamp::convertToFramerate(int newFramerate) const { Timestamp ts(*this); diff --git a/sound/timestamp.h b/sound/timestamp.h index fcfa8cf5fc..cf149a65d0 100644 --- a/sound/timestamp.h +++ b/sound/timestamp.h @@ -77,6 +77,14 @@ public: */ Timestamp(uint32 msecs, int framerate); + /** + * Set up a timestamp with a given time, frames and framerate. + * @param secs starting time in seconds + * @param frames starting frames + * @param framerate number of frames per second (must be > 0) + */ + Timestamp(uint secs, int frames, int framerate); + /** * Return a timestamp which represents as closely as possible * the point in time describes by this timestamp, but with -- cgit v1.2.3