Improve GUI display during MIDI record in various ways.
[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 #include <istream>
24 #include <vector>
25 #include <boost/shared_ptr.hpp>
26 #include <sys/types.h>
27 #include <stdint.h>
28
29 #include <inttypes.h>
30 #include <jack/types.h>
31 #include <jack/midiport.h>
32 #include "control_protocol/timecode.h"
33 #include "pbd/id.h"
34
35 #include "ardour/bbt_time.h"
36 #include "ardour/chan_count.h"
37
38 #include <map>
39
40 #if __GNUC__ < 3
41 typedef int intptr_t;
42 #endif
43
44 namespace ARDOUR {
45
46         class Source;
47         class AudioSource;
48         class Route;
49
50         typedef jack_default_audio_sample_t Sample;
51         typedef float                       pan_t;
52         typedef float                       gain_t;
53         typedef uint32_t                    layer_t;
54         typedef uint64_t                    microseconds_t;
55         typedef uint32_t                    nframes_t;
56
57         /* Any position measured in audio frames.
58            Assumed to be non-negative but not enforced.
59          */
60         typedef int64_t framepos_t;
61
62         /* Any distance from a given framepos_t.
63            Maybe positive or negative.
64         */
65         typedef int64_t frameoffset_t;
66
67         /* Any count of audio frames. 
68            Assumed to be positive but not enforced.
69         */
70         typedef int64_t framecnt_t;
71
72         static const framepos_t max_framepos = INT64_MAX;
73         static const framecnt_t max_framecnt = INT64_MAX;
74
75         struct IOChange {
76
77                 enum Type {
78                         NoChange = 0,
79                         ConfigurationChanged = 0x1,
80                         ConnectionsChanged = 0x2
81                 } type;
82
83                 IOChange () : type (NoChange) {}
84                 IOChange (Type t) : type (t) {}
85
86                 /** channel count of IO before a ConfigurationChanged, if appropriate */
87                 ARDOUR::ChanCount before;
88                 /** channel count of IO after a ConfigurationChanged, if appropriate */
89                 ARDOUR::ChanCount after;
90         };
91
92         enum OverlapType {
93                 OverlapNone,      // no overlap
94                 OverlapInternal,  // the overlap is 100% with the object
95                 OverlapStart,     // overlap covers start, but ends within
96                 OverlapEnd,       // overlap begins within and covers end
97                 OverlapExternal   // overlap extends to (at least) begin+end
98         };
99         
100         ARDOUR::OverlapType coverage (framepos_t sa, framepos_t ea,
101                                       framepos_t sb, framepos_t eb);
102
103         /* policies for inserting/pasting material where overlaps
104            might be an issue.
105         */
106
107         enum InsertMergePolicy {
108                 InsertMergeReject,  // no overlaps allowed
109                 InsertMergeRelax,   // we just don't care about overlaps
110                 InsertMergeReplace, // replace old with new
111                 InsertMergeTruncateExisting, // shorten existing to avoid overlap
112                 InsertMergeTruncateAddition, // shorten new to avoid overlap
113                 InsertMergeExtend   // extend new (or old) to the range of old+new
114         };
115
116         /** See parameter.h
117          * XXX: I don't think/hope these hex values matter anymore.
118          */
119         enum AutomationType {
120                 NullAutomation = 0x0,
121                 GainAutomation = 0x1,
122                 PanAutomation = 0x2,
123                 PluginAutomation = 0x4,
124                 SoloAutomation = 0x8,
125                 MuteAutomation = 0x10,
126                 MidiCCAutomation = 0x20,
127                 MidiPgmChangeAutomation = 0x21,
128                 MidiPitchBenderAutomation = 0x22,
129                 MidiChannelPressureAutomation = 0x23,
130                 MidiSystemExclusiveAutomation = 0x24,
131                 FadeInAutomation = 0x40,
132                 FadeOutAutomation = 0x80,
133                 EnvelopeAutomation = 0x100
134         };
135
136         enum AutoState {
137                 Off = 0x0,
138                 Write = 0x1,
139                 Touch = 0x2,
140                 Play = 0x4
141         };
142
143         std::string auto_state_to_string (AutoState);
144         AutoState string_to_auto_state (std::string);
145
146         enum AutoStyle {
147                 Absolute = 0x1,
148                 Trim = 0x2
149         };
150
151         std::string auto_style_to_string (AutoStyle);
152         AutoStyle string_to_auto_style (std::string);
153
154         enum AlignStyle {
155                 CaptureTime,
156                 ExistingMaterial
157         };
158
159         enum MeterPoint {
160                 MeterInput,
161                 MeterPreFader,
162                 MeterPostFader,
163                 MeterCustom
164         };
165
166         enum TrackMode {
167                 Normal,
168                 NonLayered,
169                 Destructive
170         };
171
172         enum NoteMode {
173                 Sustained,
174                 Percussive
175         };
176
177         enum ChannelMode {
178                 AllChannels = 0, ///< Pass through all channel information unmodified
179                 FilterChannels,  ///< Ignore events on certain channels
180                 ForceChannel     ///< Force all events to a certain channel
181         };
182
183         enum ColorMode {
184                 MeterColors = 0,
185                 ChannelColors,
186                 TrackColor
187         };
188
189         enum TimecodeFormat {
190                 timecode_23976,
191                 timecode_24,
192                 timecode_24976,
193                 timecode_25,
194                 timecode_2997,
195                 timecode_2997drop,
196                 timecode_30,
197                 timecode_30drop,
198                 timecode_5994,
199                 timecode_60
200         };
201
202         struct AnyTime {
203                 enum Type {
204                         Timecode,
205                         BBT,
206                         Frames,
207                         Seconds
208                 };
209
210                 Type type;
211
212                 Timecode::Time    timecode;
213                 BBT_Time       bbt;
214
215                 union {
216                         nframes_t      frames;
217                         double         seconds;
218                 };
219
220                 AnyTime() { type = Frames; frames = 0; }
221         };
222
223         struct AudioRange {
224                 nframes_t start;
225                 nframes_t end;
226                 uint32_t id;
227
228                 AudioRange (nframes_t s, nframes_t e, uint32_t i) : start (s), end (e) , id (i) {}
229
230                 nframes_t length() { return end - start + 1; }
231
232                 bool operator== (const AudioRange& other) const {
233                         return start == other.start && end == other.end && id == other.id;
234                 }
235
236                 bool equal (const AudioRange& other) const {
237                         return start == other.start && end == other.end;
238                 }
239
240                 OverlapType coverage (nframes_t s, nframes_t e) const {
241                         return ARDOUR::coverage (start, end, s, e);
242                 }
243         };
244
245         struct MusicRange {
246                 BBT_Time start;
247                 BBT_Time end;
248                 uint32_t id;
249
250                 MusicRange (BBT_Time& s, BBT_Time& e, uint32_t i)
251                         : start (s), end (e), id (i) {}
252
253                 bool operator== (const MusicRange& other) const {
254                         return start == other.start && end == other.end && id == other.id;
255                 }
256
257                 bool equal (const MusicRange& other) const {
258                         return start == other.start && end == other.end;
259                 }
260         };
261
262         /*
263             Slowest = 6.6dB/sec falloff at update rate of 40ms
264             Slow    = 6.8dB/sec falloff at update rate of 40ms
265         */
266
267         enum MeterFalloff {
268                 MeterFalloffOff = 0,
269                 MeterFalloffSlowest = 1,
270                 MeterFalloffSlow = 2,
271                 MeterFalloffMedium = 3,
272                 MeterFalloffFast = 4,
273                 MeterFalloffFaster = 5,
274                 MeterFalloffFastest = 6
275         };
276
277         enum MeterHold {
278                 MeterHoldOff = 0,
279                 MeterHoldShort = 40,
280                 MeterHoldMedium = 100,
281                 MeterHoldLong = 200
282         };
283
284         enum EditMode {
285                 Slide,
286                 Splice,
287                 Lock
288         };
289
290         enum RegionPoint {
291                 Start,
292                 End,
293                 SyncPoint
294         };
295
296         enum Placement {
297                 PreFader,
298                 PostFader
299         };
300
301         enum MonitorModel {
302                 HardwareMonitoring,
303                 SoftwareMonitoring,
304                 ExternalMonitoring
305         };
306
307         enum DenormalModel {
308                 DenormalNone,
309                 DenormalFTZ,
310                 DenormalDAZ,
311                 DenormalFTZDAZ
312         };
313
314         enum RemoteModel {
315                 UserOrdered,
316                 MixerOrdered,
317                 EditorOrdered
318         };
319
320         enum CrossfadeModel {
321                 FullCrossfade,
322                 ShortCrossfade
323         };
324
325         enum LayerModel {
326                 LaterHigher,
327                 MoveAddHigher,
328                 AddHigher
329         };
330
331         enum ListenPosition {
332                 AfterFaderListen,
333                 PreFaderListen
334         };
335
336         enum AutoConnectOption {
337                 ManualConnect = 0x0,
338                 AutoConnectPhysical = 0x1,
339                 AutoConnectMaster = 0x2
340         };
341
342         struct InterThreadInfo {
343                 InterThreadInfo () : done (false), cancel (false), progress (0), thread (0) {}
344                         
345                 volatile bool  done;
346                 volatile bool  cancel;
347                 volatile float progress;
348                 pthread_t      thread;
349         };
350
351         enum SampleFormat {
352                 FormatFloat = 0,
353                 FormatInt24,
354                 FormatInt16
355         };
356
357         enum CDMarkerFormat {
358                 CDMarkerNone,
359                 CDMarkerCUE,
360                 CDMarkerTOC
361         };
362
363         enum HeaderFormat {
364                 BWF,
365                 WAVE,
366                 WAVE64,
367                 CAF,
368                 AIFF,
369                 iXML,
370                 RF64
371         };
372
373         struct PeakData {
374                 typedef Sample PeakDatum;
375
376                 PeakDatum min;
377                 PeakDatum max;
378         };
379
380         enum PluginType {
381                 AudioUnit,
382                 LADSPA,
383                 LV2,
384                 VST
385         };
386
387         enum RunContext {
388                 ButlerContext = 0,
389                 TransportContext,
390                 ExportContext
391         };
392
393         enum SyncSource {
394                 JACK,
395                 MTC,
396                 MIDIClock
397         };
398
399         enum ShuttleBehaviour {
400                 Sprung,
401                 Wheel
402         };
403
404         enum ShuttleUnits {
405                 Percentage,
406                 Semitones
407         };
408
409         typedef std::vector<boost::shared_ptr<Source> > SourceList;
410
411         enum SrcQuality {
412                 SrcBest,
413                 SrcGood,
414                 SrcQuick,
415                 SrcFast,
416                 SrcFastest
417         };
418
419         struct TimeFXRequest : public InterThreadInfo {
420                 TimeFXRequest()
421                         : time_fraction(0), pitch_fraction(0),
422                         quick_seek(false), antialias(false),  opts(0) {}
423                 float time_fraction;
424                 float pitch_fraction;
425                 /* SoundTouch */
426                 bool  quick_seek;
427                 bool  antialias;
428                 /* RubberBand */
429                 int   opts; // really RubberBandStretcher::Options
430         };
431
432         typedef std::list<framepos_t> AnalysisFeatureList;
433
434         typedef std::list<boost::shared_ptr<Route> >      RouteList;
435
436         class Bundle;
437         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
438
439         enum WaveformScale {
440                 Linear,
441                 Logarithmic
442         };
443
444         enum WaveformShape {
445                 Traditional,
446                 Rectified
447         };
448
449         enum QuantizeType {
450                 Plain,
451                 Legato,
452                 Groove
453         };
454
455         struct CleanupReport {
456                 std::vector<std::string> paths;
457                 size_t                   space;
458         };
459
460         enum PositionLockStyle {
461                 AudioTime,
462                 MusicTime
463         };
464
465         /** A struct used to describe changes to processors in a route.
466          *  This is useful because objects that respond to a change in processors
467          *  can optimise what work they do based on details of what has changed.
468         */
469         struct RouteProcessorChange {
470                 enum Type {
471                         GeneralChange = 0x0,
472                         MeterPointChange = 0x1
473                 };
474
475                 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
476                 {}
477
478                 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
479                 {}
480
481                 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
482                 {}
483
484                 /** type of change; "GeneralChange" means anything could have changed */
485                 Type type;
486                 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
487                 bool meter_visibly_changed;
488         };
489
490         struct BusProfile {
491             AutoConnectOption input_ac;      /* override the RC config for input auto-connection */
492             AutoConnectOption output_ac;     /* override the RC config for output auto-connection */
493             uint32_t master_out_channels;    /* how many channels for the master bus */
494             uint32_t requested_physical_in;  /* now many of the available physical inputs to consider usable */
495             uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
496         };
497
498         enum FadeShape {
499                 FadeLinear,
500                 FadeFast,
501                 FadeSlow,
502                 FadeLogA,
503                 FadeLogB
504         };
505
506 } // namespace ARDOUR
507
508
509 /* these cover types declared above in this header. See enums.cc
510    for the definitions.
511 */
512
513 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
514 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
515 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
516 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
517 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
518 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
519 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
520 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
521 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
522 std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
523 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
524 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
525 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
526 std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf);
527 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
528 std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
529 std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
530 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
531
532 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
533 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
534 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
535 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
536 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
537 std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
538 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
539 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
540 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
541 std::ostream& operator<<(std::ostream& o, const ARDOUR::CrossfadeModel& sf);
542 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
543 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
544 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
545 std::ostream& operator<<(std::ostream& o, const ARDOUR::TimecodeFormat& sf);
546 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
547 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
548 std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
549 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
550
551 static inline ARDOUR::framepos_t
552 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
553 {
554         return (ARDOUR::framepos_t)( (double)session_frame * speed );
555 }
556
557 static inline ARDOUR::framepos_t
558 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
559 {
560         return (ARDOUR::framepos_t)( (double)track_frame / speed );
561 }
562
563 /* for now, break the rules and use "using" to make these "global" */
564
565 using ARDOUR::nframes_t;
566 using ARDOUR::framepos_t;
567
568
569 #endif /* __ardour_types_h__ */
570