Moved SMPTE type/functions into SMPTE namespace;
[ardour.git] / libs / surfaces / control_protocol / control_protocol / smpte.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_smpte_h__
20 #define __ardour_smpte_h__
21
22 #include <inttypes.h>
23
24 namespace SMPTE {
25
26 enum Wrap {
27         NONE = 0,
28         FRAMES,
29         SECONDS,
30         MINUTES,
31         HOURS
32 };
33
34 /** SMPTE frame rate (in frames per second).
35  *
36  * This should be eliminated in favour of a float to support arbitrary rates.
37  */
38 enum FPS {
39     MTC_24_FPS = 0,
40     MTC_25_FPS = 1,
41     MTC_30_FPS_DROP = 2,
42     MTC_30_FPS = 3
43 };
44
45 struct Time {
46         bool       negative;
47         uint32_t   hours;
48         uint32_t   minutes;
49         uint32_t   seconds;
50         uint32_t   frames;       ///< SMPTE frames (not audio samples)
51         uint32_t   subframes;    ///< Typically unused
52         FPS        rate;         ///< Frame rate of this Time
53         static FPS default_rate; ///< Rate to use for default constructor
54
55         Time(FPS a_rate = default_rate) {
56                 negative = false;
57                 hours = 0;
58                 minutes = 0;
59                 seconds = 0;
60                 frames = 0;
61                 subframes = 0;
62                 rate = a_rate;
63         }
64 };
65
66 Wrap increment( Time& smpte );
67 Wrap decrement( Time& smpte );
68 Wrap increment_subframes( Time& smpte );
69 Wrap decrement_subframes( Time& smpte );
70 Wrap increment_seconds( Time& smpte );
71 Wrap increment_minutes( Time& smpte );
72 Wrap increment_hours( Time& smpte );
73 void frames_floor( Time& smpte );
74 void seconds_floor( Time& smpte );
75 void minutes_floor( Time& smpte );
76 void hours_floor( Time& smpte );
77
78 } // namespace SMPTE
79
80 #endif  // __ardour_smpte_h__