Auto-monitor == Cue for MIDI tracks.
[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 <map>
26 #include <set>
27 #include <boost/shared_ptr.hpp>
28 #include <sys/types.h>
29 #include <stdint.h>
30 #include <pthread.h>
31
32 #include <inttypes.h>
33
34 #include "temporal/bbt_time.h"
35 #include "temporal/time.h"
36 #include "temporal/types.h"
37
38 #include "pbd/id.h"
39
40 #include "evoral/Range.hpp"
41
42 #include "ardour/chan_count.h"
43 #include "ardour/plugin_types.h"
44
45 #include <map>
46
47 using Temporal::max_samplepos;
48 using Temporal::max_samplecnt;
49
50 #if __GNUC__ < 3
51 typedef int intptr_t;
52 #endif
53
54 namespace ARDOUR {
55
56         class Source;
57         class AudioSource;
58         class Route;
59         class Region;
60         class Stripable;
61         class VCA;
62         class AutomationControl;
63         class SlavableAutomationControl;
64
65         typedef float    Sample;
66         typedef float    pan_t;
67         typedef float    gain_t;
68         typedef uint32_t layer_t;
69         typedef uint64_t microseconds_t;
70         typedef uint32_t pframes_t;
71
72         /* rebind Temporal position types into ARDOUR namespace */
73         typedef Temporal::samplecnt_t samplecnt_t;
74         typedef Temporal::samplepos_t samplepos_t;
75         typedef Temporal::sampleoffset_t sampleoffset_t;
76
77         static const layer_t    max_layer    = UINT32_MAX;
78
79         // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
80         typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
81         // associate a set of intervals with regions (e.g. for silence detection)
82         typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
83
84         typedef std::list<boost::shared_ptr<Region> > RegionList;
85
86         struct IOChange {
87
88                 enum Type {
89                         NoChange = 0,
90                         ConfigurationChanged = 0x1,
91                         ConnectionsChanged = 0x2
92                 } type;
93
94                 IOChange () : type (NoChange) {}
95                 IOChange (Type t) : type (t) {}
96
97                 /** channel count of IO before a ConfigurationChanged, if appropriate */
98                 ARDOUR::ChanCount before;
99                 /** channel count of IO after a ConfigurationChanged, if appropriate */
100                 ARDOUR::ChanCount after;
101         };
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 evoral/Parameter.hpp
117          *
118          * When you add things here, you REALLY SHOULD add a case clause to
119          * the constructor of ParameterDescriptor, unless the Controllables
120          * that the enum refers to are completely standard (0-1.0 range, 0.0 as
121          * normal, non-toggled, non-enumerated). Anything else needs to be
122          * added there so that things that try to represent them can do so
123          * with as much information as possible.
124          */
125         enum AutomationType {
126                 NullAutomation,
127                 GainAutomation,
128                 PanAzimuthAutomation,
129                 PanElevationAutomation,
130                 PanWidthAutomation,
131                 PanFrontBackAutomation,
132                 PanLFEAutomation,
133                 PluginAutomation,
134                 PluginPropertyAutomation,
135                 SoloAutomation,
136                 SoloIsolateAutomation,
137                 SoloSafeAutomation,
138                 MuteAutomation,
139                 MidiCCAutomation,
140                 MidiPgmChangeAutomation,
141                 MidiPitchBenderAutomation,
142                 MidiChannelPressureAutomation,
143                 MidiNotePressureAutomation,
144                 MidiSystemExclusiveAutomation,
145                 FadeInAutomation,
146                 FadeOutAutomation,
147                 EnvelopeAutomation,
148                 RecEnableAutomation,
149                 RecSafeAutomation,
150                 TrimAutomation,
151                 PhaseAutomation,
152                 MonitoringAutomation,
153                 BusSendLevel,
154                 BusSendEnable
155         };
156
157         enum AutoState {
158                 Off   = 0x00,
159                 Write = 0x01,
160                 Touch = 0x02,
161                 Play  = 0x04,
162                 Latch = 0x08
163         };
164
165         std::string auto_state_to_string (AutoState);
166         AutoState string_to_auto_state (std::string);
167
168         enum AlignStyle {
169                 CaptureTime,
170                 ExistingMaterial
171         };
172
173         enum AlignChoice {
174                 UseCaptureTime,
175                 UseExistingMaterial,
176                 Automatic
177         };
178
179         enum MeterPoint {
180                 MeterInput,
181                 MeterPreFader,
182                 MeterPostFader,
183                 MeterOutput,
184                 MeterCustom
185         };
186
187         enum DiskIOPoint {
188                 DiskIOPreFader,  /* after the trim control, but before other processors */
189                 DiskIOPostFader, /* before the main outs, after other processors */
190                 DiskIOCustom,   /* up to the user. Caveat Emptor! */
191         };
192
193         enum MeterType {
194                 MeterMaxSignal = 0x0001,
195                 MeterMaxPeak   = 0x0002,
196                 MeterPeak      = 0x0004,
197                 MeterKrms      = 0x0008,
198                 MeterK20       = 0x0010,
199                 MeterK14       = 0x0020,
200                 MeterIEC1DIN   = 0x0040,
201                 MeterIEC1NOR   = 0x0080,
202                 MeterIEC2BBC   = 0x0100,
203                 MeterIEC2EBU   = 0x0200,
204                 MeterVU        = 0x0400,
205                 MeterK12       = 0x0800,
206                 MeterPeak0dB   = 0x1000,
207                 MeterMCP       = 0x2000
208         };
209
210         enum TrackMode {
211                 Normal,
212                 NonLayered,
213                 Destructive
214         };
215
216         enum NoteMode {
217                 Sustained,
218                 Percussive
219         };
220
221         enum ChannelMode {
222                 AllChannels = 0, ///< Pass through all channel information unmodified
223                 FilterChannels,  ///< Ignore events on certain channels
224                 ForceChannel     ///< Force all events to a certain channel
225         };
226
227         enum ColorMode {
228                 MeterColors = 0,
229                 ChannelColors,
230                 TrackColor
231         };
232
233         enum RoundMode {
234                 RoundDownMaybe  = -2,  ///< Round down only if necessary
235                 RoundDownAlways = -1,  ///< Always round down, even if on a division
236                 RoundNearest    = 0,   ///< Round to nearest
237                 RoundUpAlways   = 1,   ///< Always round up, even if on a division
238                 RoundUpMaybe    = 2    ///< Round up only if necessary
239         };
240
241         enum SnapPref {
242                 SnapToAny    = 0,   ///< Snaps to the closest of ( snap prefs, grid quantization )
243                 SnapToGrid   = 1,   ///< Prefer snapping to the closest grid quantization, if a Grid selection is enabled
244         };
245
246         class AnyTime {
247         public:
248                 enum Type {
249                         Timecode,
250                         BBT,
251                         Samples,
252                         Seconds
253                 };
254
255                 Type type;
256
257                 Timecode::Time     timecode;
258                 Timecode::BBT_Time bbt;
259
260                 union {
261                         samplecnt_t     samples;
262                         double         seconds;
263                 };
264
265                 AnyTime() { type = Samples; samples = 0; }
266
267                 bool operator== (AnyTime const & other) const {
268                         if (type != other.type) { return false; }
269
270                         switch (type) {
271                           case Timecode:
272                                 return timecode == other.timecode;
273                           case BBT:
274                                 return bbt == other.bbt;
275                           case Samples:
276                                 return samples == other.samples;
277                           case Seconds:
278                                 return seconds == other.seconds;
279                         }
280                         return false; // get rid of warning
281                 }
282
283                 bool not_zero() const
284                 {
285                         switch (type) {
286                           case Timecode:
287                                 return timecode.hours != 0 || timecode.minutes != 0 ||
288                                        timecode.seconds != 0 || timecode.frames != 0;
289                           case BBT:
290                                 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
291                           case Samples:
292                                 return samples != 0;
293                           case Seconds:
294                                 return seconds != 0;
295                         }
296
297                         abort(); /* NOTREACHED */
298                         return false;
299                 }
300         };
301
302         /* used for translating audio samples to an exact musical position using a note divisor.
303            an exact musical position almost never falls exactly on an audio sample, but for sub-sample
304            musical accuracy we need to derive exact musical locations from a sample position
305            the division follows TempoMap::exact_beat_at_sample().
306            division
307            -1       musical location is the bar closest to sample
308             0       musical location is the musical position of the sample
309             1       musical location is the BBT beat closest to sample
310             n       musical location is the quarter-note division n closest to sample
311         */
312         struct MusicSample {
313                 samplepos_t sample;
314                 int32_t    division;
315
316                 MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
317
318                 void set (samplepos_t f, int32_t d) {sample = f; division = d; }
319
320                 MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
321         };
322
323         /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
324            but this has a uint32_t id which Evoral::Range<> does not.
325         */
326         struct AudioRange {
327                 samplepos_t start;
328                 samplepos_t end;
329                 uint32_t id;
330
331                 AudioRange (samplepos_t s, samplepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
332
333                 samplecnt_t length() const { return end - start + 1; }
334
335                 bool operator== (const AudioRange& other) const {
336                         return start == other.start && end == other.end && id == other.id;
337                 }
338
339                 bool equal (const AudioRange& other) const {
340                         return start == other.start && end == other.end;
341                 }
342
343                 Evoral::OverlapType coverage (samplepos_t s, samplepos_t e) const {
344                         return Evoral::coverage (start, end, s, e);
345                 }
346         };
347
348         struct MusicRange {
349                 Timecode::BBT_Time start;
350                 Timecode::BBT_Time end;
351                 uint32_t id;
352
353                 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
354                         : start (s), end (e), id (i) {}
355
356                 bool operator== (const MusicRange& other) const {
357                         return start == other.start && end == other.end && id == other.id;
358                 }
359
360                 bool equal (const MusicRange& other) const {
361                         return start == other.start && end == other.end;
362                 }
363         };
364
365         /*
366             Slowest = 6.6dB/sec falloff at update rate of 40ms
367             Slow    = 6.8dB/sec falloff at update rate of 40ms
368         */
369
370         enum MeterFalloff {
371                 MeterFalloffOff = 0,
372                 MeterFalloffSlowest = 1,
373                 MeterFalloffSlow = 2,
374                 MeterFalloffSlowish = 3,
375                 MeterFalloffModerate = 4,
376                 MeterFalloffMedium = 5,
377                 MeterFalloffFast = 6,
378                 MeterFalloffFaster = 7,
379                 MeterFalloffFastest = 8,
380         };
381
382         enum MeterHold {
383                 MeterHoldOff = 0,
384                 MeterHoldShort = 40,
385                 MeterHoldMedium = 100,
386                 MeterHoldLong = 200
387         };
388
389         enum EditMode {
390                 Slide,
391                 Splice,
392                 Ripple,
393                 Lock
394         };
395
396         enum RegionSelectionAfterSplit {
397                 None = 0,
398                 NewlyCreatedLeft = 1,  // bit 0
399                 NewlyCreatedRight = 2, // bit 1
400                 NewlyCreatedBoth = 3,
401                 Existing = 4,          // bit 2
402                 ExistingNewlyCreatedLeft = 5,
403                 ExistingNewlyCreatedRight = 6,
404                 ExistingNewlyCreatedBoth = 7
405         };
406
407         enum RegionPoint {
408                 Start,
409                 End,
410                 SyncPoint
411         };
412
413         enum Placement {
414                 PreFader,
415                 PostFader
416         };
417
418         enum MonitorModel {
419                 HardwareMonitoring, ///< JACK does monitoring
420                 SoftwareMonitoring, ///< Ardour does monitoring
421                 ExternalMonitoring  ///< we leave monitoring to the audio hardware
422         };
423
424         enum MonitorChoice {
425                 MonitorAuto = 0,
426                 MonitorInput = 0x1,
427                 MonitorDisk = 0x2,
428                 MonitorCue = 0x4,
429         };
430
431         enum MonitorState {
432                 MonitoringSilence = 0x1,
433                 MonitoringInput = 0x2,
434                 MonitoringDisk = 0x4,
435                 MonitoringCue = 0x6,
436         };
437
438         enum MeterState {
439                 MeteringInput, ///< meter the input IO, regardless of what is going through the route
440                 MeteringRoute  ///< meter what is going through the route
441         };
442
443         enum VUMeterStandard {
444                 MeteringVUfrench,   // 0VU = -2dBu
445                 MeteringVUamerican, // 0VU =  0dBu
446                 MeteringVUstandard, // 0VU = +4dBu
447                 MeteringVUeight     // 0VU = +8dBu
448         };
449
450         enum MeterLineUp {
451                 MeteringLineUp24,
452                 MeteringLineUp20,
453                 MeteringLineUp18,
454                 MeteringLineUp15
455         };
456
457         enum PFLPosition {
458                 /** PFL signals come from before pre-fader processors */
459                 PFLFromBeforeProcessors,
460                 /** PFL signals come pre-fader but after pre-fader processors */
461                 PFLFromAfterProcessors
462         };
463
464         enum AFLPosition {
465                 /** AFL signals come post-fader and before post-fader processors */
466                 AFLFromBeforeProcessors,
467                 /** AFL signals come post-fader but after post-fader processors */
468                 AFLFromAfterProcessors
469         };
470
471         enum ClockDeltaMode {
472                 NoDelta,
473                 DeltaEditPoint,
474                 DeltaOriginMarker
475         };
476
477         enum DenormalModel {
478                 DenormalNone,
479                 DenormalFTZ,
480                 DenormalDAZ,
481                 DenormalFTZDAZ
482         };
483
484         enum LayerModel {
485                 LaterHigher,
486                 Manual
487         };
488
489         enum ListenPosition {
490                 AfterFaderListen,
491                 PreFaderListen
492         };
493
494         enum AutoConnectOption {
495                 ManualConnect = 0x0,
496                 AutoConnectPhysical = 0x1,
497                 AutoConnectMaster = 0x2
498         };
499
500     enum TracksAutoNamingRule {
501         UseDefaultNames = 0x1,
502         NameAfterDriver = 0x2
503     };
504
505         enum SampleFormat {
506                 FormatFloat = 0,
507                 FormatInt24,
508                 FormatInt16
509         };
510
511         int format_data_width (ARDOUR::SampleFormat);
512
513         enum CDMarkerFormat {
514                 CDMarkerNone,
515                 CDMarkerCUE,
516                 CDMarkerTOC,
517                 MP4Chaps
518         };
519
520         enum HeaderFormat {
521                 BWF,
522                 WAVE,
523                 WAVE64,
524                 CAF,
525                 AIFF,
526                 iXML,
527                 RF64,
528                 RF64_WAV,
529                 MBWF,
530         };
531
532         struct PeakData {
533                 typedef Sample PeakDatum;
534
535                 PeakDatum min;
536                 PeakDatum max;
537         };
538
539         enum RunContext {
540                 ButlerContext = 0,
541                 TransportContext,
542                 ExportContext
543         };
544
545         enum SyncSource {
546                 /* These are "synonyms". It is important for JACK to be first
547                    both here and in enums.cc, so that the string "JACK" is
548                    correctly recognized in older session and preference files.
549                 */
550                 JACK = 0,
551                 Engine = 0,
552                 MTC,
553                 MIDIClock,
554                 LTC
555         };
556
557         enum ShuttleBehaviour {
558                 Sprung,
559                 Wheel
560         };
561
562         enum ShuttleUnits {
563                 Percentage,
564                 Semitones
565         };
566
567         typedef std::vector<boost::shared_ptr<Source> > SourceList;
568
569         enum SrcQuality {
570                 SrcBest,
571                 SrcGood,
572                 SrcQuick,
573                 SrcFast,
574                 SrcFastest
575         };
576
577         typedef std::list<samplepos_t> AnalysisFeatureList;
578
579         typedef std::list<boost::shared_ptr<Route> > RouteList;
580         typedef std::list<boost::shared_ptr<Stripable> > StripableList;
581         typedef std::list<boost::weak_ptr  <Route> > WeakRouteList;
582         typedef std::list<boost::weak_ptr  <Stripable> > WeakStripableList;
583         typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
584         typedef std::list<boost::shared_ptr<SlavableAutomationControl> > SlavableControlList;
585         typedef std::set <boost::shared_ptr<AutomationControl> > AutomationControlSet;
586
587         typedef std::list<boost::shared_ptr<VCA> > VCAList;
588
589         class Bundle;
590         typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
591
592         enum WaveformScale {
593                 Linear,
594                 Logarithmic
595         };
596
597         enum WaveformShape {
598                 Traditional,
599                 Rectified
600         };
601
602         struct CleanupReport {
603                 std::vector<std::string> paths;
604                 size_t                   space;
605         };
606
607         enum PositionLockStyle {
608                 AudioTime,
609                 MusicTime
610         };
611
612         /** A struct used to describe changes to processors in a route.
613          *  This is useful because objects that respond to a change in processors
614          *  can optimise what work they do based on details of what has changed.
615         */
616         struct RouteProcessorChange {
617                 enum Type {
618                         GeneralChange = 0x0,
619                         MeterPointChange = 0x1,
620                         RealTimeChange = 0x2
621                 };
622
623                 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
624                 {}
625
626                 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
627                 {}
628
629                 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
630                 {}
631
632                 /** type of change; "GeneralChange" means anything could have changed */
633                 Type type;
634                 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
635                 bool meter_visibly_changed;
636         };
637
638         struct BusProfile {
639                 uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
640         };
641
642         enum FadeShape {
643                 FadeLinear,
644                 FadeFast,
645                 FadeSlow,
646                 FadeConstantPower,
647                 FadeSymmetric,
648         };
649
650         enum TransportState {
651                 /* these values happen to match the constants used by JACK but
652                    this equality cannot be assumed.
653                 */
654                 TransportStopped = 0,
655                 TransportRolling = 1,
656                 TransportLooping = 2,
657                 TransportStarting = 3,
658         };
659
660         enum PortFlags {
661                 /* these values happen to match the constants used by JACK but
662                    this equality cannot be assumed.
663                 */
664                 IsInput = 0x1,
665                 IsOutput = 0x2,
666                 IsPhysical = 0x4,
667                 CanMonitor = 0x8,
668                 IsTerminal = 0x10,
669
670                 /* non-JACK related flags */
671                 Hidden = 0x20,
672                 Shadow = 0x40
673         };
674
675         enum MidiPortFlags {
676                 MidiPortMusic = 0x1,
677                 MidiPortControl = 0x2,
678                 MidiPortSelection = 0x4,
679                 MidiPortVirtual = 0x8
680         };
681
682         struct LatencyRange {
683             uint32_t min; //< samples
684             uint32_t max; //< samples
685         };
686
687         enum BufferingPreset {
688                 Small,
689                 Medium,
690                 Large,
691                 Custom,
692         };
693
694         enum AutoReturnTarget {
695                 LastLocate = 0x1,
696                 RangeSelectionStart = 0x2,
697                 Loop = 0x4,
698                 RegionSelectionStart = 0x8,
699         };
700
701         enum PlaylistDisposition {
702                 CopyPlaylist,
703                 NewPlaylist,
704                 SharePlaylist
705         };
706
707         enum MidiTrackNameSource {
708                 SMFTrackNumber,
709                 SMFTrackName,
710                 SMFInstrumentName
711         };
712
713         enum MidiTempoMapDisposition {
714                 SMFTempoIgnore,
715                 SMFTempoUse,
716         };
717
718         struct CaptureInfo {
719                 samplepos_t start;
720                 samplecnt_t samples;
721         };
722
723         typedef std::vector<CaptureInfo*> CaptureInfos;
724
725 } // namespace ARDOUR
726
727 /* for now, break the rules and use "using" to make this "global" */
728
729 using ARDOUR::samplepos_t;
730
731 #endif /* __ardour_types_h__ */