libardour added.
[ardour.git] / libs / ardour / ardour / types.h
1 /*
2     Copyright (C) 2002 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     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,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #ifndef __ardour_types_h__
22 #define __ardour_types_h__
23
24 #ifndef __STDC_FORMAT_MACROS
25 #define __STDC_FORMAT_MACROS /* PRI<foo>; C++ requires explicit requesting of these */
26 #endif
27
28 #include <inttypes.h>
29 #include <jack/types.h>
30 #include <map>
31
32 #if __GNUC__ < 3
33
34 typedef int intptr_t;
35 #endif
36
37 namespace ARDOUR {
38
39         class Source;
40
41         typedef jack_default_audio_sample_t Sample;
42         typedef float                       pan_t;
43         typedef float                       gain_t;
44         typedef uint32_t                    layer_t;
45         typedef uint64_t                    id_t;
46
47         enum IOChange {
48                 NoChange = 0,
49                 ConfigurationChanged = 0x1,
50                 ConnectionsChanged = 0x2
51         };
52
53         enum OverlapType {
54                 OverlapNone,      // no overlap
55                 OverlapInternal,  // the overlap is 100% with the object
56                 OverlapStart,     // overlap covers start, but ends within
57                 OverlapEnd,       // overlap begins within and covers end 
58                 OverlapExternal   // overlap extends to (at least) begin+end
59         };
60
61         OverlapType coverage (jack_nframes_t start_a, jack_nframes_t end_a,
62                               jack_nframes_t start_b, jack_nframes_t end_b);
63
64         enum AutomationType {
65                 GainAutomation = 0x1,
66                 PanAutomation = 0x2,
67                 PluginAutomation = 0x4,
68                 SoloAutomation = 0x8,
69                 MuteAutomation = 0x10,
70         };
71
72         enum AutoState {
73                 Off = 0x0,
74                 Write = 0x1,
75                 Touch = 0x2,
76                 Play = 0x4
77         };
78
79         enum AutoStyle {
80                 Absolute = 0x1,
81                 Trim = 0x2
82         };
83
84         enum AlignStyle {
85                 CaptureTime,
86                 ExistingMaterial
87         };
88
89         enum MeterPoint {
90                 MeterInput,
91                 MeterPreFader,
92                 MeterPostFader
93         };
94
95         enum smpte_wrap_t {
96                 smpte_wrap_none = 0,
97                 smpte_wrap_frames,
98                 smpte_wrap_seconds,
99                 smpte_wrap_minutes,
100                 smpte_wrap_hours
101         };
102   
103         struct SMPTE_Time {
104                 bool negative;
105                 long hours;
106                 long minutes;
107                 long seconds;
108                 long frames;
109                 long subframes; // mostly not used
110
111                 SMPTE_Time() {
112                         negative = false;
113                         hours = 0;
114                         minutes = 0;
115                         seconds = 0;
116                         frames = 0;
117                         subframes = 0;
118                 }
119                 
120         };
121
122         struct BBT_Time {
123             uint32_t bars;
124             uint32_t beats;
125             uint32_t ticks;
126
127             BBT_Time() {
128                     bars = 1;
129                     beats = 1;
130                     ticks = 0;
131             }
132
133             /* we can't define arithmetic operators for BBT_Time, because
134                the results depend on a TempoMap, but we can define 
135                a useful check on the less-than condition.
136             */
137
138             bool operator< (const BBT_Time& other) const {
139                     return bars < other.bars || 
140                             (bars == other.bars && beats < other.beats) ||
141                             (bars == other.bars && beats == other.beats && ticks < other.ticks);
142             }
143
144             bool operator== (const BBT_Time& other) const {
145                     return bars == other.bars && beats == other.beats && ticks == other.ticks;
146             }
147             
148         };
149
150         struct AnyTime {
151             enum Type {
152                     SMPTE,
153                     BBT,
154                     Frames,
155                     Seconds
156             };
157
158             Type type;
159
160             SMPTE_Time     smpte;
161             BBT_Time       bbt;
162
163             union { 
164                 jack_nframes_t frames;
165                 double         seconds;
166             };
167         };
168
169         struct AudioRange {
170             jack_nframes_t start;
171             jack_nframes_t end;
172             uint32_t id;
173             
174             AudioRange (jack_nframes_t s, jack_nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
175             
176             jack_nframes_t length() { return end - start + 1; } 
177
178             bool operator== (const AudioRange& other) const {
179                     return start == other.start && end == other.end && id == other.id;
180             }
181
182             bool equal (const AudioRange& other) const {
183                     return start == other.start && end == other.end;
184             }
185
186             OverlapType coverage (jack_nframes_t s, jack_nframes_t e) const {
187                     return ARDOUR::coverage (start, end, s, e);
188             }
189         };
190         
191         struct MusicRange {
192             BBT_Time start;
193             BBT_Time end;
194             uint32_t id;
195             
196             MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
197                     : start (s), end (e), id (i) {}
198
199             bool operator== (const MusicRange& other) const {
200                     return start == other.start && end == other.end && id == other.id;
201             }
202
203             bool equal (const MusicRange& other) const {
204                     return start == other.start && end == other.end;
205             }
206         };
207
208         enum EditMode {
209                 Slide,
210                 Splice,
211         };
212
213         enum RegionPoint { 
214             Start,
215             End,
216             SyncPoint
217         };
218
219         enum Change {
220                 range_guarantee = ~0
221         };
222
223
224         enum Placement {
225                 PreFader,
226                 PostFader
227         };
228
229         enum CrossfadeModel {
230                 FullCrossfade,
231                 ShortCrossfade
232         };
233
234         struct InterThreadInfo {
235             volatile bool  done;
236             volatile bool  cancel;
237             volatile float progress;
238             pthread_t      thread;
239         };
240 };
241
242 #endif /* __ardour_types_h__ */
243