change the use of "SMPTE" to "Timecode" to reflect the global economy and the end...
[ardour.git] / libs / surfaces / control_protocol / control_protocol / timecode.h
1 /*
2         Copyright (C) 2006 Paul Davis
3         
4         This program is free software; you can redistribute it and/or modify it
5         under the terms of the GNU Lesser General Public License as published
6         by the Free Software Foundation; either version 2 of the License, or
7         (at your option) any later version.
8         
9         This program is distributed in the hope that it will be useful, but WITHOUT
10         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12         for more details.
13         
14         You should have received a copy of the GNU General Public License along
15         with this program; if not, write to the Free Software Foundation, Inc.,
16         675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_timecode_h__
20 #define __ardour_timecode_h__
21
22 #include <inttypes.h>
23
24 namespace Timecode {
25
26 enum Wrap {
27         NONE = 0,
28         FRAMES,
29         SECONDS,
30         MINUTES,
31         HOURS
32 };
33
34 struct Time {
35         bool       negative;
36         uint32_t   hours;
37         uint32_t   minutes;
38         uint32_t   seconds;
39         uint32_t   frames;        ///< Timecode frames (not audio samples)
40         uint32_t   subframes;     ///< Typically unused
41         float      rate;          ///< Frame rate of this Time
42         static float default_rate;///< Rate to use for default constructor
43         bool       drop;          ///< Whether this Time uses dropframe Timecode
44
45         Time(float a_rate = default_rate) {
46                 negative = false;
47                 hours = 0;
48                 minutes = 0;
49                 seconds = 0;
50                 frames = 0;
51                 subframes = 0;
52                 rate = a_rate;
53         }
54 };
55
56 Wrap increment( Time& timecode, uint32_t );
57 Wrap decrement( Time& timecode, uint32_t );
58 Wrap increment_subframes( Time& timecode, uint32_t );
59 Wrap decrement_subframes( Time& timecode, uint32_t );
60 Wrap increment_seconds( Time& timecode, uint32_t );
61 Wrap increment_minutes( Time& timecode, uint32_t );
62 Wrap increment_hours( Time& timecode, uint32_t );
63 void frames_floor( Time& timecode );
64 void seconds_floor( Time& timecode );
65 void minutes_floor( Time& timecode );
66 void hours_floor( Time& timecode );
67
68 } // namespace Timecode
69
70 #endif  // __ardour_timecode_h__