54c965ce67e4e954b44702dfa69845d0c1119405
[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         typedef int64_t framepos_t;
67         /* any offset from a framepos_t, measured in audio frames */
68         typedef int64_t frameoffset_t;
69         /* any count of audio frames */
70         typedef int64_t framecnt_t;
71
72         enum IOChange {
73                 NoChange = 0,
74                 ConfigurationChanged = 0x1,
75                 ConnectionsChanged = 0x2
76         };
77
78         enum OverlapType {
79                 OverlapNone,      // no overlap
80                 OverlapInternal,  // the overlap is 100% with the object
81                 OverlapStart,     // overlap covers start, but ends within
82                 OverlapEnd,       // overlap begins within and covers end
83                 OverlapExternal   // overlap extends to (at least) begin+end
84         };
85
86         OverlapType coverage (nframes_t start_a, nframes_t end_a,
87                               nframes_t start_b, nframes_t end_b);
88
89         /** See parameter.h
90          * XXX: I don't think/hope these hex values matter anymore.
91          */
92         enum AutomationType {
93                 NullAutomation = 0x0,
94                 GainAutomation = 0x1,
95                 PanAutomation = 0x2,
96                 PluginAutomation = 0x4,
97                 SoloAutomation = 0x8,
98                 MuteAutomation = 0x10,
99                 MidiCCAutomation = 0x20,
100                 MidiPgmChangeAutomation = 0x21,
101                 MidiPitchBenderAutomation = 0x22,
102                 MidiChannelPressureAutomation = 0x23,
103                 MidiSystemExclusiveAutomation = 0x24,
104                 FadeInAutomation = 0x40,
105                 FadeOutAutomation = 0x80,
106                 EnvelopeAutomation = 0x100
107         };
108
109         enum AutoState {
110                 Off = 0x0,
111                 Write = 0x1,
112                 Touch = 0x2,
113                 Play = 0x4
114         };
115
116         std::string auto_state_to_string (AutoState);
117         AutoState string_to_auto_state (std::string);
118
119         enum AutoStyle {
120                 Absolute = 0x1,
121                 Trim = 0x2
122         };
123
124         std::string auto_style_to_string (AutoStyle);
125         AutoStyle string_to_auto_style (std::string);
126
127         enum AlignStyle {
128                 CaptureTime,
129                 ExistingMaterial
130         };
131
132         enum MeterPoint {
133                 MeterInput,
134                 MeterPreFader,
135                 MeterPostFader,
136                 MeterCustom
137         };
138
139         enum TrackMode {
140                 Normal,
141                 NonLayered,
142                 Destructive
143         };
144
145         enum NoteMode {
146                 Sustained,
147                 Percussive
148         };
149
150         enum ChannelMode {
151                 AllChannels = 0, ///< Pass through all channel information unmodified
152                 FilterChannels,  ///< Ignore events on certain channels
153                 ForceChannel     ///< Force all events to a certain channel
154         };
155
156         enum ColorMode {
157                 MeterColors = 0,
158                 ChannelColors,
159                 TrackColor
160         };
161
162         enum TimecodeFormat {
163                 timecode_23976,
164                 timecode_24,
165                 timecode_24976,
166                 timecode_25,
167                 timecode_2997,
168                 timecode_2997drop,
169                 timecode_30,
170                 timecode_30drop,
171                 timecode_5994,
172                 timecode_60
173         };
174
175         struct AnyTime {
176                 enum Type {
177                         Timecode,
178                         BBT,
179                         Frames,
180                         Seconds
181                 };
182
183                 Type type;
184
185                 Timecode::Time    timecode;
186                 BBT_Time       bbt;
187
188                 union {
189                         nframes_t      frames;
190                         double         seconds;
191                 };
192
193                 AnyTime() { type = Frames; frames = 0; }
194         };
195
196         struct AudioRange {
197                 nframes_t start;
198                 nframes_t end;
199                 uint32_t id;
200
201                 AudioRange (nframes_t s, nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
202
203                 nframes_t length() { return end - start + 1; }
204
205                 bool operator== (const AudioRange& other) const {
206                         return start == other.start && end == other.end && id == other.id;
207                 }
208
209                 bool equal (const AudioRange& other) const {
210                         return start == other.start && end == other.end;
211                 }
212
213                 OverlapType coverage (nframes_t s, nframes_t e) const {
214                         return ARDOUR::coverage (start, end, s, e);
215                 }
216         };
217
218         struct MusicRange {
219                 BBT_Time start;
220                 BBT_Time end;
221                 uint32_t id;
222
223                 MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
224                         : start (s), end (e), id (i) {}
225
226                 bool operator== (const MusicRange& other) const {
227                         return start == other.start && end == other.end && id == other.id;
228                 }
229
230                 bool equal (const MusicRange& other) const {
231                         return start == other.start && end == other.end;
232                 }
233         };
234
235         /*
236             Slowest = 6.6dB/sec falloff at update rate of 40ms
237             Slow    = 6.8dB/sec falloff at update rate of 40ms
238         */
239
240         enum MeterFalloff {
241                 MeterFalloffOff = 0,
242                 MeterFalloffSlowest = 1,
243                 MeterFalloffSlow = 2,
244                 MeterFalloffMedium = 3,
245                 MeterFalloffFast = 4,
246                 MeterFalloffFaster = 5,
247                 MeterFalloffFastest = 6
248         };
249
250         enum MeterHold {
251                 MeterHoldOff = 0,
252                 MeterHoldShort = 40,
253                 MeterHoldMedium = 100,
254                 MeterHoldLong = 200
255         };
256
257         enum EditMode {
258                 Slide,
259                 Splice,
260                 Lock
261         };
262
263         enum RegionPoint {
264                 Start,
265                 End,
266                 SyncPoint
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         /** A struct used to describe changes to processors in a route.
432          *  This is useful because objects that respond to a change in processors
433          *  can optimise what work they do based on details of what has changed.
434         */
435         struct RouteProcessorChange {
436                 enum Type {
437                         GeneralChange = 0x0,
438                         MeterPointChange = 0x1
439                 };
440
441                 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
442                 {}
443
444                 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
445                 {}
446
447                 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
448                 {}
449
450                 /** type of change; "GeneralChange" means anything could have changed */
451                 Type type;
452                 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
453                 bool meter_visibly_changed;
454         };
455
456 } // namespace ARDOUR
457
458
459 /* these cover types declared above in this header. See enums.cc
460    for the definitions.
461 */
462
463 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
464 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
465 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
466 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
467 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
468 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
469 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
470 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
471 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
472 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
473 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
474 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
475 std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf);
476 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
477 std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
478 std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
479
480 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
481 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
482 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
483 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
484 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
485 std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
486 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
487 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
488 std::ostream& operator<<(std::ostream& o, const ARDOUR::CrossfadeModel& sf);
489 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
490 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
491 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
492 std::ostream& operator<<(std::ostream& o, const ARDOUR::TimecodeFormat& sf);
493 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
494 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
495 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
496
497 static inline ARDOUR::nframes64_t
498 session_frame_to_track_frame (ARDOUR::nframes64_t session_frame, double speed)
499 {
500         return (ARDOUR::nframes64_t)( (double)session_frame * speed );
501 }
502
503 static inline ARDOUR::nframes64_t
504 track_frame_to_session_frame (ARDOUR::nframes64_t track_frame, double speed)
505 {
506         return (ARDOUR::nframes64_t)( (double)track_frame / speed );
507 }
508
509 /* for now, break the rules and use "using" to make these "global" */
510
511 using ARDOUR::nframes_t;
512 using ARDOUR::nframes64_t;
513
514
515 #endif /* __ardour_types_h__ */
516