add slave,transport and event debugging traces
[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/timecode.h"
35 #include "pbd/id.h"
36
37 #include "ardour/bbt_time.h"
38
39 #include <map>
40
41 #if __GNUC__ < 3
42 typedef int intptr_t;
43 #endif
44
45 namespace ARDOUR {
46
47         class Source;
48         class AudioSource;
49         class Route;
50
51         typedef jack_default_audio_sample_t Sample;
52         typedef float                       pan_t;
53         typedef float                       gain_t;
54         typedef uint32_t                    layer_t;
55         typedef uint64_t                    microseconds_t;
56         typedef uint32_t                    nframes_t;
57         typedef int64_t                     nframes64_t;
58
59
60         /** "Session frames", frames relative to the session timeline.
61          * Everything related to transport position etc. should be of this type.
62          * We might want to make this a compile time option for 32-bitters who
63          * don't want to pay for extremely long session times they don't need...
64          */
65         typedef int64_t sframes_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         /** See parameter.h
85          * XXX: I don't think/hope these hex values matter anymore.
86          */
87         enum AutomationType {
88                 NullAutomation = 0x0,
89                 GainAutomation = 0x1,
90                 PanAutomation = 0x2,
91                 PluginAutomation = 0x4,
92                 SoloAutomation = 0x8,
93                 MuteAutomation = 0x10,
94                 MidiCCAutomation = 0x20,
95                 MidiPgmChangeAutomation = 0x21,
96                 MidiPitchBenderAutomation = 0x22,
97                 MidiChannelPressureAutomation = 0x23,
98                 MidiSystemExclusiveAutomation = 0x24,
99                 FadeInAutomation = 0x40,
100                 FadeOutAutomation = 0x80,
101                 EnvelopeAutomation = 0x100
102         };
103
104         enum AutoState {
105                 Off = 0x0,
106                 Write = 0x1,
107                 Touch = 0x2,
108                 Play = 0x4
109         };
110
111         std::string auto_state_to_string (AutoState);
112         AutoState string_to_auto_state (std::string);
113
114         enum AutoStyle {
115                 Absolute = 0x1,
116                 Trim = 0x2
117         };
118
119         std::string auto_style_to_string (AutoStyle);
120         AutoStyle string_to_auto_style (std::string);
121
122         enum AlignStyle {
123                 CaptureTime,
124                 ExistingMaterial
125         };
126
127         enum MeterPoint {
128                 MeterInput,
129                 MeterPreFader,
130                 MeterPostFader,
131                 MeterCustom
132         };
133
134         enum TrackMode {
135                 Normal,
136                 NonLayered,
137                 Destructive
138         };
139
140         enum NoteMode {
141                 Sustained,
142                 Percussive
143         };
144
145         enum ChannelMode {
146                 AllChannels = 0, ///< Pass through all channel information unmodified
147                 FilterChannels,  ///< Ignore events on certain channels
148                 ForceChannel     ///< Force all events to a certain channel
149         };
150
151         enum ColorMode {
152                 MeterColors = 0,
153                 ChannelColors,
154                 TrackColor
155         };
156
157         enum TimecodeFormat {
158                 timecode_23976,
159                 timecode_24,
160                 timecode_24976,
161                 timecode_25,
162                 timecode_2997,
163                 timecode_2997drop,
164                 timecode_30,
165                 timecode_30drop,
166                 timecode_5994,
167                 timecode_60
168         };
169
170         struct AnyTime {
171                 enum Type {
172                         Timecode,
173                         BBT,
174                         Frames,
175                         Seconds
176                 };
177
178                 Type type;
179
180                 Timecode::Time    timecode;
181                 BBT_Time       bbt;
182
183                 union {
184                         nframes_t      frames;
185                         double         seconds;
186                 };
187
188                 AnyTime() { type = Frames; frames = 0; }
189         };
190
191         struct AudioRange {
192                 nframes_t start;
193                 nframes_t end;
194                 uint32_t id;
195
196                 AudioRange (nframes_t s, nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
197
198                 nframes_t length() { return end - start + 1; }
199
200                 bool operator== (const AudioRange& other) const {
201                         return start == other.start && end == other.end && id == other.id;
202                 }
203
204                 bool equal (const AudioRange& other) const {
205                         return start == other.start && end == other.end;
206                 }
207
208                 OverlapType coverage (nframes_t s, nframes_t e) const {
209                         return ARDOUR::coverage (start, end, s, e);
210                 }
211         };
212
213         struct MusicRange {
214                 BBT_Time start;
215                 BBT_Time end;
216                 uint32_t id;
217
218                 MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
219                         : start (s), end (e), id (i) {}
220
221                 bool operator== (const MusicRange& other) const {
222                         return start == other.start && end == other.end && id == other.id;
223                 }
224
225                 bool equal (const MusicRange& other) const {
226                         return start == other.start && end == other.end;
227                 }
228         };
229
230         /*
231             Slowest = 6.6dB/sec falloff at update rate of 40ms
232             Slow    = 6.8dB/sec falloff at update rate of 40ms
233         */
234
235         enum MeterFalloff {
236                 MeterFalloffOff = 0,
237                 MeterFalloffSlowest = 1,
238                 MeterFalloffSlow = 2,
239                 MeterFalloffMedium = 3,
240                 MeterFalloffFast = 4,
241                 MeterFalloffFaster = 5,
242                 MeterFalloffFastest = 6
243         };
244
245         enum MeterHold {
246                 MeterHoldOff = 0,
247                 MeterHoldShort = 40,
248                 MeterHoldMedium = 100,
249                 MeterHoldLong = 200
250         };
251
252         enum EditMode {
253                 Slide,
254                 Splice,
255                 Lock
256         };
257
258         enum RegionPoint {
259                 Start,
260                 End,
261                 SyncPoint
262         };
263
264         enum Change {
265                 range_guarantee = ~0
266         };
267
268
269         enum Placement {
270                 PreFader,
271                 PostFader
272         };
273
274         enum MonitorModel {
275                 HardwareMonitoring,
276                 SoftwareMonitoring,
277                 ExternalMonitoring
278         };
279
280         enum DenormalModel {
281                 DenormalNone,
282                 DenormalFTZ,
283                 DenormalDAZ,
284                 DenormalFTZDAZ
285         };
286
287         enum RemoteModel {
288                 UserOrdered,
289                 MixerOrdered,
290                 EditorOrdered
291         };
292
293         enum CrossfadeModel {
294                 FullCrossfade,
295                 ShortCrossfade
296         };
297
298         enum LayerModel {
299                 LaterHigher,
300                 MoveAddHigher,
301                 AddHigher
302         };
303
304         enum ListenPosition {
305                 AfterFaderListen,
306                 PreFaderListen
307         };
308
309         enum AutoConnectOption {
310                 ManualConnect = 0x0,
311                 AutoConnectPhysical = 0x1,
312                 AutoConnectMaster = 0x2
313         };
314
315         struct InterThreadInfo {
316                 volatile bool  done;
317                 volatile bool  cancel;
318                 volatile float progress;
319                 pthread_t      thread;
320         };
321
322         enum SampleFormat {
323                 FormatFloat = 0,
324                 FormatInt24,
325                 FormatInt16
326         };
327
328         enum CDMarkerFormat {
329                 CDMarkerNone,
330                 CDMarkerCUE,
331                 CDMarkerTOC
332         };
333
334         enum HeaderFormat {
335                 BWF,
336                 WAVE,
337                 WAVE64,
338                 CAF,
339                 AIFF,
340                 iXML,
341                 RF64
342         };
343
344         struct PeakData {
345                 typedef Sample PeakDatum;
346
347                 PeakDatum min;
348                 PeakDatum max;
349         };
350
351         enum PluginType {
352                 AudioUnit,
353                 LADSPA,
354                 LV2,
355                 VST
356         };
357
358         enum RunContext {
359                 ButlerContext = 0,
360                 TransportContext,
361                 ExportContext
362         };
363
364         enum SyncSource {
365                 JACK,
366                 MTC,
367                 MIDIClock
368         };
369
370         enum ShuttleBehaviour {
371                 Sprung,
372                 Wheel
373         };
374
375         enum ShuttleUnits {
376                 Percentage,
377                 Semitones
378         };
379
380         typedef std::vector<boost::shared_ptr<Source> > SourceList;
381
382         enum SrcQuality {
383                 SrcBest,
384                 SrcGood,
385                 SrcQuick,
386                 SrcFast,
387                 SrcFastest
388         };
389
390         struct TimeFXRequest : public InterThreadInfo {
391                 TimeFXRequest()
392                         : time_fraction(0), pitch_fraction(0),
393                         quick_seek(false), antialias(false),  opts(0) {}
394                 float time_fraction;
395                 float pitch_fraction;
396                 /* SoundTouch */
397                 bool  quick_seek;
398                 bool  antialias;
399                 /* RubberBand */
400                 int   opts; // really RubberBandStretcher::Options
401         };
402
403         typedef std::list<nframes64_t> AnalysisFeatureList;
404
405         typedef std::list<boost::shared_ptr<Route> >      RouteList;
406
407         class Bundle;
408         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
409
410         enum WaveformScale {
411                 Linear,
412                 Logarithmic
413         };
414
415         enum WaveformShape {
416                 Traditional,
417                 Rectified
418         };
419
420         enum QuantizeType {
421                 Plain,
422                 Legato,
423                 Groove
424         };
425
426         struct CleanupReport {
427                 std::vector<std::string> paths;
428                 int64_t                  space;
429         };
430
431 } // namespace ARDOUR
432
433
434 /* these cover types declared above in this header. See enums.cc
435    for the definitions.
436 */
437
438 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
439 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
440 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
441 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
442 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
443 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
444 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
445 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
446 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
447 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
448 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
449 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
450 std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf);
451 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
452 std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
453 std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
454
455 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
456 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
457 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
458 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
459 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
460 std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
461 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
462 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
463 std::ostream& operator<<(std::ostream& o, const ARDOUR::CrossfadeModel& sf);
464 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
465 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
466 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
467 std::ostream& operator<<(std::ostream& o, const ARDOUR::TimecodeFormat& sf);
468 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
469 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
470 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
471
472 static inline ARDOUR::nframes64_t
473 session_frame_to_track_frame (ARDOUR::nframes64_t session_frame, double speed)
474 {
475         return (ARDOUR::nframes64_t)( (double)session_frame * speed );
476 }
477
478 static inline ARDOUR::nframes64_t
479 track_frame_to_session_frame (ARDOUR::nframes64_t track_frame, double speed)
480 {
481         return (ARDOUR::nframes64_t)( (double)track_frame / speed );
482 }
483
484 /* for now, break the rules and use "using" to make these "global" */
485
486 using ARDOUR::nframes_t;
487 using ARDOUR::nframes64_t;
488
489
490 #endif /* __ardour_types_h__ */
491