ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

timestamp.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef AUDIO_TIMESTAMP_H
00024 #define AUDIO_TIMESTAMP_H
00025 
00026 #include "common/scummsys.h"
00027 
00028 namespace Audio {
00029 
00079 class Timestamp {
00080 public:
00086     Timestamp(uint msecs = 0, uint framerate = 1);
00087 
00094     Timestamp(uint secs, uint frames, uint framerate);
00095 
00101     Timestamp convertToFramerate(uint newFramerate) const;
00102 
00108     bool operator==(const Timestamp &ts) const;
00109     bool operator!=(const Timestamp &ts) const;
00110     bool operator<(const Timestamp &ts) const;
00111     bool operator<=(const Timestamp &ts) const;
00112     bool operator>(const Timestamp &ts) const;
00113     bool operator>=(const Timestamp &ts) const;
00114 
00120     Timestamp addFrames(int frames) const;
00121 
00127     Timestamp addMsecs(int msecs) const;
00128 
00129 
00130     // unary minus
00131     Timestamp operator-() const;
00132 
00137     Timestamp operator+(const Timestamp &ts) const;
00138 
00143     Timestamp operator-(const Timestamp &ts) const;
00144 
00150     int frameDiff(const Timestamp &ts) const;
00151 
00153     int msecsDiff(const Timestamp &ts) const;
00154 
00159     int msecs() const;
00160 
00165     inline int secs() const {
00166         return _secs;
00167     }
00168 
00172     inline int totalNumberOfFrames() const {
00173         return _numFrames / (int)_framerateFactor + _secs * (int)(_framerate / _framerateFactor);
00174     }
00175 
00181     inline int numberOfFrames() const {
00182         return _numFrames / (int)_framerateFactor;
00183     }
00184 
00186     inline uint framerate() const { return _framerate / _framerateFactor; }
00187 
00188 protected:
00193     int cmp(const Timestamp &ts) const;
00194 
00199     void normalize();
00200 
00204     void addIntern(const Timestamp &ts);
00205 
00206 protected:
00213     int _secs;
00214 
00227     int _numFrames;
00228 
00236     uint _framerate;
00237 
00242     uint _framerateFactor;
00243 };
00244 
00245 
00246 } // End of namespace Audio
00247 
00248 #endif


Generated on Sat Mar 16 2019 05:01:56 for ResidualVM by doxygen 1.7.1
curved edge   curved edge