Trim include dependency graph, especially for io.h and session.h.
[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 <jack/midiport.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 /* eventually, we'd like everything (including JACK) to
45    move to this. for now, its a dedicated type.
46 */
47
48 typedef int64_t                    nframes64_t;
49
50 namespace ARDOUR {
51
52         class Source;
53         class AudioSource;
54         class Route;
55
56         typedef jack_default_audio_sample_t Sample;
57         typedef float                       pan_t;
58         typedef float                       gain_t;
59         typedef uint32_t                    layer_t;
60         typedef uint64_t                    microseconds_t;
61         typedef uint32_t                    nframes_t;
62
63         enum IOChange {
64                 NoChange = 0,
65                 ConfigurationChanged = 0x1,
66                 ConnectionsChanged = 0x2
67         };
68
69         enum OverlapType {
70                 OverlapNone,      // no overlap
71                 OverlapInternal,  // the overlap is 100% with the object
72                 OverlapStart,     // overlap covers start, but ends within
73                 OverlapEnd,       // overlap begins within and covers end
74                 OverlapExternal   // overlap extends to (at least) begin+end
75         };
76
77         OverlapType coverage (nframes_t start_a, nframes_t end_a,
78                               nframes_t start_b, nframes_t end_b);
79
80         /** See parameter.h
81          * XXX: I don't think/hope these hex values matter anymore.
82          */
83         enum AutomationType {
84                 NullAutomation = 0x0,
85                 GainAutomation = 0x1,
86                 PanAutomation = 0x2,
87                 PluginAutomation = 0x4,
88                 SoloAutomation = 0x8,
89                 MuteAutomation = 0x10,
90                 MidiCCAutomation = 0x20,
91                 MidiPgmChangeAutomation = 0x21,
92                 MidiPitchBenderAutomation = 0x22,
93                 MidiChannelPressureAutomation = 0x23,
94                 FadeInAutomation = 0x40,
95                 FadeOutAutomation = 0x80,
96                 EnvelopeAutomation = 0x100
97         };
98
99         enum AutoState {
100                 Off = 0x0,
101                 Write = 0x1,
102                 Touch = 0x2,
103                 Play = 0x4
104         };
105
106         std::string auto_state_to_string (AutoState);
107         AutoState string_to_auto_state (std::string);
108
109         enum AutoStyle {
110                 Absolute = 0x1,
111                 Trim = 0x2
112         };
113
114         std::string auto_style_to_string (AutoStyle);
115         AutoStyle string_to_auto_style (std::string);
116
117         enum AlignStyle {
118                 CaptureTime,
119                 ExistingMaterial
120         };
121
122         enum MeterPoint {
123                 MeterInput,
124                 MeterPreFader,
125                 MeterPostFader
126         };
127
128         enum TrackMode {
129                 Normal,
130                 Destructive
131         };
132
133         enum NoteMode {
134                 Sustained,
135                 Percussive
136         };
137
138         enum ChannelMode {
139                 AllChannels = 0, ///< Pass through all channel information unmodified
140                 FilterChannels,  ///< Ignore events on certain channels
141                 ForceChannel     ///< Force all events to a certain channel
142         };
143         
144         enum ColorMode {
145                 MeterColors = 0,
146                 ChannelColors,
147                 TrackColor
148         };
149
150         enum EventTimeUnit {
151                 Frames,
152                 Beats
153         };
154
155         struct BBT_Time {
156             uint32_t bars;
157             uint32_t beats;
158             uint32_t ticks;
159
160             BBT_Time() {
161                     bars = 1;
162                     beats = 1;
163                     ticks = 0;
164             }
165
166             /* we can't define arithmetic operators for BBT_Time, because
167                the results depend on a TempoMap, but we can define
168                a useful check on the less-than condition.
169             */
170
171             bool operator< (const BBT_Time& other) const {
172                     return bars < other.bars ||
173                             (bars == other.bars && beats < other.beats) ||
174                             (bars == other.bars && beats == other.beats && ticks < other.ticks);
175             }
176
177             bool operator== (const BBT_Time& other) const {
178                     return bars == other.bars && beats == other.beats && ticks == other.ticks;
179             }
180
181         };
182         enum SmpteFormat {
183                 smpte_23976,
184                 smpte_24,
185                 smpte_24976,
186                 smpte_25,
187                 smpte_2997,
188                 smpte_2997drop,
189                 smpte_30,
190                 smpte_30drop,
191                 smpte_5994,
192                 smpte_60
193         };
194
195         struct AnyTime {
196             enum Type {
197                     SMPTE,
198                     BBT,
199                     Frames,
200                     Seconds
201             };
202
203             Type type;
204
205             SMPTE::Time    smpte;
206             BBT_Time       bbt;
207
208             union {
209                 nframes_t      frames;
210                 double         seconds;
211             };
212
213             AnyTime() { type = Frames; frames = 0; }
214         };
215
216         struct AudioRange {
217             nframes_t start;
218             nframes_t end;
219             uint32_t id;
220
221             AudioRange (nframes_t s, nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
222
223             nframes_t length() { return end - start + 1; }
224
225             bool operator== (const AudioRange& other) const {
226                     return start == other.start && end == other.end && id == other.id;
227             }
228
229             bool equal (const AudioRange& other) const {
230                     return start == other.start && end == other.end;
231             }
232
233             OverlapType coverage (nframes_t s, nframes_t e) const {
234                     return ARDOUR::coverage (start, end, s, e);
235             }
236         };
237
238         struct MusicRange {
239             BBT_Time start;
240             BBT_Time end;
241             uint32_t id;
242
243             MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
244                     : start (s), end (e), id (i) {}
245
246             bool operator== (const MusicRange& other) const {
247                     return start == other.start && end == other.end && id == other.id;
248             }
249
250             bool equal (const MusicRange& other) const {
251                     return start == other.start && end == other.end;
252             }
253         };
254
255         /*
256             Slowest = 6.6dB/sec falloff at update rate of 40ms
257             Slow    = 6.8dB/sec falloff at update rate of 40ms
258         */
259
260         enum MeterFalloff {
261                 MeterFalloffOff = 0,
262                 MeterFalloffSlowest = 1,
263                 MeterFalloffSlow = 2,
264                 MeterFalloffMedium = 3,
265                 MeterFalloffFast = 4,
266                 MeterFalloffFaster = 5,
267                 MeterFalloffFastest = 6
268         };
269
270         enum MeterHold {
271                 MeterHoldOff = 0,
272                 MeterHoldShort = 40,
273                 MeterHoldMedium = 100,
274                 MeterHoldLong = 200
275         };
276
277         enum EditMode {
278                 Slide,
279                 Splice,
280                 Lock
281         };
282
283         enum RegionPoint {
284             Start,
285             End,
286             SyncPoint
287         };
288
289         enum Change {
290                 range_guarantee = ~0
291         };
292
293
294         enum Placement {
295                 PreFader,
296                 PostFader
297         };
298
299         enum MonitorModel {
300                 HardwareMonitoring,
301                 SoftwareMonitoring,
302                 ExternalMonitoring
303         };
304
305         enum DenormalModel {
306                 DenormalNone,
307                 DenormalFTZ,
308                 DenormalDAZ,
309                 DenormalFTZDAZ
310         };
311
312         enum RemoteModel {
313                 UserOrdered,
314                 MixerOrdered,
315                 EditorOrdered
316         };
317
318         enum CrossfadeModel {
319                 FullCrossfade,
320                 ShortCrossfade
321         };
322
323         enum LayerModel {
324                 LaterHigher,
325                 MoveAddHigher,
326                 AddHigher
327         };
328
329         enum SoloModel {
330                 InverseMute,
331                 SoloBus
332         };
333
334         enum AutoConnectOption {
335                 AutoConnectPhysical = 0x1,
336                 AutoConnectMaster = 0x2
337         };
338
339         struct InterThreadInfo {
340             volatile bool  done;
341             volatile bool  cancel;
342             volatile float progress;
343             pthread_t      thread;
344         };
345
346         enum SampleFormat {
347                 FormatFloat = 0,
348                 FormatInt24,
349                 FormatInt16
350         };
351
352         enum CDMarkerFormat {
353                 CDMarkerNone,
354                 CDMarkerCUE,
355                 CDMarkerTOC
356         };
357
358         enum HeaderFormat {
359                 BWF,
360                 WAVE,
361                 WAVE64,
362                 CAF,
363                 AIFF,
364                 iXML,
365                 RF64
366         };
367
368         struct PeakData {
369             typedef Sample PeakDatum;
370
371             PeakDatum min;
372             PeakDatum max;
373         };
374
375         enum PluginType {
376                 AudioUnit,
377                 LADSPA,
378                 LV2,
379                 VST
380         };
381         
382         enum RunContext {
383                 ButlerContext = 0,
384                 TransportContext,
385                 ExportContext
386         };
387
388         enum SlaveSource {
389                 None = 0,
390                 MTC,
391                 JACK,
392                 MIDIClock
393         };
394
395         enum ShuttleBehaviour {
396                 Sprung,
397                 Wheel
398         };
399
400         enum ShuttleUnits {
401                 Percentage,
402                 Semitones
403         };
404
405         typedef std::vector<boost::shared_ptr<Source> > SourceList;
406
407         enum SrcQuality {
408                 SrcBest,
409                 SrcGood,
410                 SrcQuick,
411                 SrcFast,
412                 SrcFastest
413         };
414
415         struct TimeFXRequest : public InterThreadInfo {
416                 TimeFXRequest() : time_fraction(0), pitch_fraction(0),
417                         quick_seek(false), antialias(false),  opts(0) {}
418             float time_fraction;
419             float pitch_fraction;
420             /* SoundTouch */
421             bool  quick_seek;
422             bool  antialias;
423             /* RubberBand */
424             int   opts; // really RubberBandStretcher::Options
425         };
426
427         typedef std::list<nframes64_t> AnalysisFeatureList;
428
429         typedef std::list<boost::shared_ptr<Route> >      RouteList;
430
431         class Bundle;
432         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
433
434 } // namespace ARDOUR
435
436 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
437 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
438 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
439 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
440 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
441 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
442 std::istream& operator>>(std::istream& o, ARDOUR::SoloModel& sf);
443 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
444 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
445 std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& sf);
446 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
447 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
448 std::istream& operator>>(std::istream& o, ARDOUR::SmpteFormat& sf);
449 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
450
451 using ARDOUR::nframes_t;
452
453 static inline nframes_t
454 session_frame_to_track_frame (nframes_t session_frame, double speed)
455 {
456         return (nframes_t)( (double)session_frame * speed );
457 }
458
459 static inline nframes_t
460 track_frame_to_session_frame (nframes_t track_frame, double speed)
461 {
462         return (nframes_t)( (double)track_frame / speed );
463 }
464
465
466 #endif /* __ardour_types_h__ */
467