1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef SOUND_TIMESTAMP_H
27 #define SOUND_TIMESTAMP_H
29 #include "common/scummsys.h"
34 * Timestamps allow measuring times with a sub-millisecond granularity,
35 * and without rounding losses. This is achieved by measuring frames
36 * instead of milliseconds: Specify an initial time in milliseconds
37 * plus framerate (in frames per second).
44 /* Total time: msecs + frame_offset/frame_rate */
50 * Set up a timestamp with a given time and framerate.
51 * @param msecs staring time in milliseconds
52 * @param frameRate number of frames per second
54 Timestamp(uint32 msecs
, int frameRate
);
56 /** Adds a number of frames to a timestamp. */
57 Timestamp
addFrames(int frames
) const;
59 /** Adds a number of milliseconds to a timestamp. */
60 Timestamp
addMsecs(int ms
) const;
62 /** Computes the difference (# of frames) between this timestamp and b. */
63 int frameDiff(const Timestamp
&b
) const;
65 /** Computes the difference (# of milliseconds) between this timestamp and b. */
66 int msecsDiff(const Timestamp
&b
) const;
68 /** Determines the time in milliseconds described by this timestamp. */
73 } // End of namespace Audio