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