revert patch for 2388 (from 2.0-ongoing)
[ardour.git] / libs / ardour / ardour / smpte.h
1 /*  Copyright (C) 2006 Paul Davis
2
3     This program is free software; you can redistribute it and/or modify it
4     under the terms of the GNU General Public License as published by the
5     Free Software Foundation; either version 2 of the License, or (at your
6     option) any later version.
7
8     This program is distributed in the hope that it will be useful, but WITHOUT
9     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11     for more details.
12
13     You should have received a copy of the GNU General Public License along
14     with this program; if not, write to the Free Software Foundation, Inc.,
15     51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifndef __ardour_smpte_h__
19 #define __ardour_smpte_h__
20
21 #include <inttypes.h>
22
23 namespace SMPTE {
24
25 enum Wrap {
26         NONE = 0,
27         FRAMES,
28         SECONDS,
29         MINUTES,
30         HOURS
31 };
32
33 /** SMPTE frame rate (in frames per second).
34  *
35  * This should be eliminated in favour of a float to support arbitrary rates.
36  */
37 enum FPS {
38     MTC_24_FPS = 0,
39     MTC_25_FPS = 1,
40     MTC_30_FPS_DROP = 2,
41     MTC_30_FPS = 3
42 };
43
44 struct Time {
45         bool       negative;
46         uint32_t   hours;
47         uint32_t   minutes;
48         uint32_t   seconds;
49         uint32_t   frames;       ///< SMPTE frames (not audio samples)
50         uint32_t   subframes;    ///< Typically unused
51         FPS        rate;         ///< Frame rate of this Time
52         static FPS default_rate; ///< Rate to use for default constructor
53
54         Time(FPS a_rate = default_rate) {
55                 negative = false;
56                 hours = 0;
57                 minutes = 0;
58                 seconds = 0;
59                 frames = 0;
60                 subframes = 0;
61                 rate = a_rate;
62         }
63 };
64
65 Wrap increment( Time& smpte );
66 Wrap decrement( Time& smpte );
67 Wrap increment_subframes( Time& smpte );
68 Wrap decrement_subframes( Time& smpte );
69 Wrap increment_seconds( Time& smpte );
70 Wrap increment_minutes( Time& smpte );
71 Wrap increment_hours( Time& smpte );
72 void frames_floor( Time& smpte );
73 void seconds_floor( Time& smpte );
74 void minutes_floor( Time& smpte );
75 void hours_floor( Time& smpte );
76
77 } // namespace SMPTE
78
79 #endif  // __ardour_smpte_h__