the BIG CONFIG patch
[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 <istream>
29 #include <vector>
30 #include <boost/shared_ptr.hpp>
31
32 #include <inttypes.h>
33 #include <jack/types.h>
34 #include <control_protocol/smpte.h>
35 #include <pbd/id.h>
36
37 #include <map>
38
39 #if __GNUC__ < 3
40
41 typedef int intptr_t;
42 #endif
43
44 namespace ARDOUR {
45
46         class Source;
47         class AudioSource;
48
49         typedef jack_default_audio_sample_t Sample;
50         typedef float                       pan_t;
51         typedef float                       gain_t;
52         typedef uint32_t                    layer_t;
53         typedef uint64_t                    microseconds_t;
54
55         enum IOChange {
56                 NoChange = 0,
57                 ConfigurationChanged = 0x1,
58                 ConnectionsChanged = 0x2
59         };
60
61         enum OverlapType {
62                 OverlapNone,      // no overlap
63                 OverlapInternal,  // the overlap is 100% with the object
64                 OverlapStart,     // overlap covers start, but ends within
65                 OverlapEnd,       // overlap begins within and covers end 
66                 OverlapExternal   // overlap extends to (at least) begin+end
67         };
68
69         OverlapType coverage (jack_nframes_t start_a, jack_nframes_t end_a,
70                               jack_nframes_t start_b, jack_nframes_t end_b);
71
72         enum AutomationType {
73                 GainAutomation = 0x1,
74                 PanAutomation = 0x2,
75                 PluginAutomation = 0x4,
76                 SoloAutomation = 0x8,
77                 MuteAutomation = 0x10
78         };
79
80         enum AutoState {
81                 Off = 0x0,
82                 Write = 0x1,
83                 Touch = 0x2,
84                 Play = 0x4
85         };
86
87         enum AutoStyle {
88                 Absolute = 0x1,
89                 Trim = 0x2
90         };
91
92         enum AlignStyle {
93                 CaptureTime,
94                 ExistingMaterial
95         };
96
97         enum MeterPoint {
98                 MeterInput,
99                 MeterPreFader,
100                 MeterPostFader
101         };
102
103         enum TrackMode {
104                 Normal,
105                 Destructive
106         };
107         
108         struct BBT_Time {
109             uint32_t bars;
110             uint32_t beats;
111             uint32_t ticks;
112
113             BBT_Time() {
114                     bars = 1;
115                     beats = 1;
116                     ticks = 0;
117             }
118
119             /* we can't define arithmetic operators for BBT_Time, because
120                the results depend on a TempoMap, but we can define 
121                a useful check on the less-than condition.
122             */
123
124             bool operator< (const BBT_Time& other) const {
125                     return bars < other.bars || 
126                             (bars == other.bars && beats < other.beats) ||
127                             (bars == other.bars && beats == other.beats && ticks < other.ticks);
128             }
129
130             bool operator== (const BBT_Time& other) const {
131                     return bars == other.bars && beats == other.beats && ticks == other.ticks;
132             }
133             
134         };
135
136         struct AnyTime {
137             enum Type {
138                     SMPTE,
139                     BBT,
140                     Frames,
141                     Seconds
142             };
143
144             Type type;
145
146             SMPTE::Time    smpte;
147             BBT_Time       bbt;
148
149             union { 
150                 jack_nframes_t frames;
151                 double         seconds;
152             };
153
154             AnyTime() { type = Frames; frames = 0; }
155         };
156
157         struct AudioRange {
158             jack_nframes_t start;
159             jack_nframes_t end;
160             uint32_t id;
161             
162             AudioRange (jack_nframes_t s, jack_nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
163             
164             jack_nframes_t length() { return end - start + 1; } 
165
166             bool operator== (const AudioRange& other) const {
167                     return start == other.start && end == other.end && id == other.id;
168             }
169
170             bool equal (const AudioRange& other) const {
171                     return start == other.start && end == other.end;
172             }
173
174             OverlapType coverage (jack_nframes_t s, jack_nframes_t e) const {
175                     return ARDOUR::coverage (start, end, s, e);
176             }
177         };
178         
179         struct MusicRange {
180             BBT_Time start;
181             BBT_Time end;
182             uint32_t id;
183             
184             MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
185                     : start (s), end (e), id (i) {}
186
187             bool operator== (const MusicRange& other) const {
188                     return start == other.start && end == other.end && id == other.id;
189             }
190
191             bool equal (const MusicRange& other) const {
192                     return start == other.start && end == other.end;
193             }
194         };
195
196         enum EditMode {
197                 Slide,
198                 Splice
199         };
200
201         enum RegionPoint { 
202             Start,
203             End,
204             SyncPoint
205         };
206
207         enum Change {
208                 range_guarantee = ~0
209         };
210
211
212         enum Placement {
213                 PreFader,
214                 PostFader
215         };
216
217         enum CrossfadeModel {
218                 FullCrossfade,
219                 ShortCrossfade
220         };
221         
222         enum LayerModel {
223                 LaterHigher,
224                 MoveAddHigher,
225                 AddHigher
226         };
227
228         enum SoloModel {
229                 InverseMute,
230                 SoloBus
231         };
232
233         enum AutoConnectOption {
234                 AutoConnectPhysical = 0x1,
235                 AutoConnectMaster = 0x2
236         };
237
238         struct InterThreadInfo {
239             volatile bool  done;
240             volatile bool  cancel;
241             volatile float progress;
242             pthread_t      thread;
243         };
244
245         enum SampleFormat {
246                 FormatFloat = 0,
247                 FormatInt24
248         };
249
250
251         enum HeaderFormat {
252                 BWF,
253                 WAVE,
254                 WAVE64,
255                 CAF,
256                 AIFF,
257                 iXML,
258                 RF64
259         };
260
261         struct PeakData {
262             typedef Sample PeakDatum;
263             
264             PeakDatum min;
265             PeakDatum max;
266         };
267         
268         enum PluginType {
269                 AudioUnit,
270                 LADSPA,
271                 VST
272         };
273
274         enum SlaveSource {
275                 None = 0,
276                 MTC,
277                 JACK
278         };
279
280         enum ShuttleBehaviour {
281                 Sprung,
282                 Wheel
283         };
284
285         enum ShuttleUnits {
286                 Percentage,
287                 Semitones
288         };
289
290         typedef std::vector<boost::shared_ptr<AudioSource> > SourceList;
291
292 } // namespace ARDOUR
293
294 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
295 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
296 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
297 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
298 std::istream& operator>>(std::istream& o, ARDOUR::SoloModel& sf);
299 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
300 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
301 std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& sf);
302 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
303 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
304
305 static inline jack_nframes_t
306 session_frame_to_track_frame (jack_nframes_t session_frame, double speed)
307 {
308         return (jack_nframes_t)( (double)session_frame * speed );
309 }
310
311 static inline jack_nframes_t
312 track_frame_to_session_frame (jack_nframes_t track_frame, double speed)
313 {
314         return (jack_nframes_t)( (double)track_frame / speed );
315 }
316
317
318 #endif /* __ardour_types_h__ */
319