Make import GUI report if you are importing a file of a name that
[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 */
19
20 #ifndef __ardour_types_h__
21 #define __ardour_types_h__
22
23 #ifndef __STDC_FORMAT_MACROS
24 #define __STDC_FORMAT_MACROS /* PRI<foo>; C++ requires explicit requesting of these */
25 #endif
26
27 #include <istream>
28 #include <vector>
29 #include <boost/shared_ptr.hpp>
30
31 #include <inttypes.h>
32 #include <jack/types.h>
33 #include <control_protocol/smpte.h>
34 #include <pbd/id.h>
35
36 #include <map>
37
38 #if __GNUC__ < 3
39
40 typedef int intptr_t;
41 #endif
42
43 /* at some point move this into the ARDOUR namespace,
44    but for now its outside because it replaces the
45    old global "jack_nframes_t"
46 */
47
48 typedef uint32_t                    nframes_t;
49
50 /* eventually, we'd like everything (including JACK) to 
51    move to this. for now, its a dedicated type.
52 */
53
54 typedef int64_t                    nframes64_t;
55
56 namespace ARDOUR {
57
58         class Source;
59         class AudioSource;
60
61         typedef jack_default_audio_sample_t Sample;
62         typedef float                       pan_t;
63         typedef float                       gain_t;
64         typedef uint32_t                    layer_t;
65         typedef uint64_t                    microseconds_t;
66
67         enum IOChange {
68                 NoChange = 0,
69                 ConfigurationChanged = 0x1,
70                 ConnectionsChanged = 0x2
71         };
72
73         enum OverlapType {
74                 OverlapNone,      // no overlap
75                 OverlapInternal,  // the overlap is 100% with the object
76                 OverlapStart,     // overlap covers start, but ends within
77                 OverlapEnd,       // overlap begins within and covers end 
78                 OverlapExternal   // overlap extends to (at least) begin+end
79         };
80
81         OverlapType coverage (nframes_t start_a, nframes_t end_a,
82                               nframes_t start_b, nframes_t end_b);
83
84         enum AutomationType {
85                 GainAutomation = 0x1,
86                 PanAutomation = 0x2,
87                 PluginAutomation = 0x4,
88                 SoloAutomation = 0x8,
89                 MuteAutomation = 0x10
90         };
91
92         enum AutoState {
93                 Off = 0x0,
94                 Write = 0x1,
95                 Touch = 0x2,
96                 Play = 0x4
97         };
98
99         std::string auto_state_to_string (AutoState);
100         AutoState string_to_auto_state (std::string);
101
102         enum AutoStyle {
103                 Absolute = 0x1,
104                 Trim = 0x2
105         };
106
107         std::string auto_style_to_string (AutoStyle);
108         AutoStyle string_to_auto_style (std::string);
109
110         enum AlignStyle {
111                 CaptureTime,
112                 ExistingMaterial
113         };
114
115         enum MeterPoint {
116                 MeterInput,
117                 MeterPreFader,
118                 MeterPostFader
119         };
120
121         enum TrackMode {
122                 Normal,
123                 Destructive
124         };
125         
126         struct BBT_Time {
127             uint32_t bars;
128             uint32_t beats;
129             uint32_t ticks;
130
131             BBT_Time() {
132                     bars = 1;
133                     beats = 1;
134                     ticks = 0;
135             }
136
137             /* we can't define arithmetic operators for BBT_Time, because
138                the results depend on a TempoMap, but we can define 
139                a useful check on the less-than condition.
140             */
141
142             bool operator< (const BBT_Time& other) const {
143                     return bars < other.bars || 
144                             (bars == other.bars && beats < other.beats) ||
145                             (bars == other.bars && beats == other.beats && ticks < other.ticks);
146             }
147
148             bool operator== (const BBT_Time& other) const {
149                     return bars == other.bars && beats == other.beats && ticks == other.ticks;
150             }
151             
152         };
153         enum SmpteFormat {
154                 smpte_23976,
155                 smpte_24,
156                 smpte_24976,
157                 smpte_25,
158                 smpte_2997,
159                 smpte_2997drop,
160                 smpte_30,
161                 smpte_30drop,
162                 smpte_5994,
163                 smpte_60
164         };
165
166         struct AnyTime {
167             enum Type {
168                     SMPTE,
169                     BBT,
170                     Frames,
171                     Seconds
172             };
173
174             Type type;
175
176             SMPTE::Time    smpte;
177             BBT_Time       bbt;
178
179             union { 
180                 nframes_t frames;
181                 double         seconds;
182             };
183
184             AnyTime() { type = Frames; frames = 0; }
185         };
186
187         struct AudioRange {
188             nframes_t start;
189             nframes_t end;
190             uint32_t id;
191             
192             AudioRange (nframes_t s, nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
193             
194             nframes_t length() { return end - start + 1; } 
195
196             bool operator== (const AudioRange& other) const {
197                     return start == other.start && end == other.end && id == other.id;
198             }
199
200             bool equal (const AudioRange& other) const {
201                     return start == other.start && end == other.end;
202             }
203
204             OverlapType coverage (nframes_t s, nframes_t e) const {
205                     return ARDOUR::coverage (start, end, s, e);
206             }
207         };
208         
209         struct MusicRange {
210             BBT_Time start;
211             BBT_Time end;
212             uint32_t id;
213             
214             MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
215                     : start (s), end (e), id (i) {}
216
217             bool operator== (const MusicRange& other) const {
218                     return start == other.start && end == other.end && id == other.id;
219             }
220
221             bool equal (const MusicRange& other) const {
222                     return start == other.start && end == other.end;
223             }
224         };
225
226         /*
227             Slowest = 6.6dB/sec falloff at update rate of 40ms
228             Slow    = 6.8dB/sec falloff at update rate of 40ms
229         */
230
231         enum MeterFalloff {
232                 MeterFalloffOff = 0,
233                 MeterFalloffSlowest = 1,
234                 MeterFalloffSlow = 2,
235                 MeterFalloffMedium = 3,
236                 MeterFalloffFast = 4,
237                 MeterFalloffFaster = 5,
238                 MeterFalloffFastest = 6
239         };
240
241         enum MeterHold {
242                 MeterHoldOff = 0,
243                 MeterHoldShort = 40,
244                 MeterHoldMedium = 100,
245                 MeterHoldLong = 200
246         };
247
248         enum EditMode {
249                 Slide,
250                 Splice
251         };
252
253         enum RegionPoint { 
254             Start,
255             End,
256             SyncPoint
257         };
258
259         enum Change {
260                 range_guarantee = ~0
261         };
262
263
264         enum Placement {
265                 PreFader,
266                 PostFader
267         };
268
269         enum MonitorModel {
270                 HardwareMonitoring,
271                 SoftwareMonitoring,
272                 ExternalMonitoring,
273         };
274
275         enum DenormalModel {
276                 DenormalNone,
277                 DenormalFTZ,
278                 DenormalDAZ,
279                 DenormalFTZDAZ
280         };
281
282         enum RemoteModel {
283                 UserOrdered,
284                 MixerOrdered,
285                 EditorOrdered,
286         };
287
288         enum CrossfadeModel {
289                 FullCrossfade,
290                 ShortCrossfade
291         };
292         
293         enum LayerModel {
294                 LaterHigher,
295                 MoveAddHigher,
296                 AddHigher
297         };
298
299         enum SoloModel {
300                 InverseMute,
301                 SoloBus
302         };
303
304         enum AutoConnectOption {
305                 AutoConnectPhysical = 0x1,
306                 AutoConnectMaster = 0x2
307         };
308
309         struct InterThreadInfo {
310             volatile bool  done;
311             volatile bool  cancel;
312             volatile float progress;
313             pthread_t      thread;
314         };
315
316         enum SampleFormat {
317                 FormatFloat = 0,
318                 FormatInt24,
319                 FormatInt16
320         };
321
322
323         enum HeaderFormat {
324                 BWF,
325                 WAVE,
326                 WAVE64,
327                 CAF,
328                 AIFF,
329                 iXML,
330                 RF64
331         };
332
333         struct PeakData {
334             typedef Sample PeakDatum;
335             
336             PeakDatum min;
337             PeakDatum max;
338         };
339         
340         enum PluginType {
341                 AudioUnit,
342                 LADSPA,
343                 LV2,
344                 VST
345         };
346
347         enum SlaveSource {
348                 None = 0,
349                 MTC,
350                 JACK
351         };
352
353         enum ShuttleBehaviour {
354                 Sprung,
355                 Wheel
356         };
357
358         enum ShuttleUnits {
359                 Percentage,
360                 Semitones
361         };
362
363         typedef std::vector<boost::shared_ptr<AudioSource> > SourceList;
364
365         enum SrcQuality {
366                 SrcBest,
367                 SrcGood,
368                 SrcQuick,
369                 SrcFast,
370                 SrcFastest
371         };
372
373         struct TimeFXRequest : public InterThreadInfo {
374             float time_fraction;
375             float pitch_fraction;
376             /* SoundTouch */
377             bool  quick_seek; 
378             bool  antialias;  
379             /* RubberBand */
380             int   opts; // really RubberBandStretcher::Options
381         };
382
383         typedef std::list<nframes64_t> AnalysisFeatureList;
384
385 } // namespace ARDOUR
386
387 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
388 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
389 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
390 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
391 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
392 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
393 std::istream& operator>>(std::istream& o, ARDOUR::SoloModel& sf);
394 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
395 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
396 std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& sf);
397 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
398 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
399 std::istream& operator>>(std::istream& o, ARDOUR::SmpteFormat& sf);
400 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
401
402 static inline nframes_t
403 session_frame_to_track_frame (nframes_t session_frame, double speed)
404 {
405         return (nframes_t)( (double)session_frame * speed );
406 }
407
408 static inline nframes_t
409 track_frame_to_session_frame (nframes_t track_frame, double speed)
410 {
411         return (nframes_t)( (double)track_frame / speed );
412 }
413
414
415 #endif /* __ardour_types_h__ */
416