Ardour  8.12
ardour/ardour/types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2018 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2008-2009 Hans Baier <hansfbaier@googlemail.com>
6  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2010-2011 Sakari Bergen <sakari.bergen@beatwaves.net>
8  * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
9  * Copyright (C) 2013-2015 Tim Mayberry <mojofunk@gmail.com>
10  * Copyright (C) 2013-2017 Nick Mainsbridge <mainsbridge@gmail.com>
11  * Copyright (C) 2013-2018 Colin Fletcher <colin.m.fletcher@googlemail.com>
12  * Copyright (C) 2014-2015 John Emmas <john@creativepost.co.uk>
13  * Copyright (C) 2015 Len Ovens <len@ovenwerks.net>
14  * Copyright (C) 2017-2019 Ben Loftis <ben@harrisonconsoles.com>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, write to the Free Software Foundation, Inc.,
28  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29  */
30 
31 #ifndef __ardour_types_h__
32 #define __ardour_types_h__
33 
34 #include <bitset>
35 #include <cstdint>
36 #include <istream>
37 #include <map>
38 #include <memory>
39 #include <set>
40 #include <vector>
41 
42 #include <sys/types.h>
43 #include <pthread.h>
44 
45 #include <inttypes.h>
46 
47 #include "temporal/bbt_time.h"
48 #include "temporal/range.h"
49 #include "temporal/superclock.h"
50 #include "temporal/time.h"
51 #include "temporal/timeline.h"
52 #include "temporal/types.h"
53 
54 #include "pbd/id.h"
55 #include "pbd/microseconds.h"
56 
57 #include "ardour/chan_count.h"
58 #include "ardour/plugin_types.h"
59 
60 #include <map>
61 
64 
65 #if defined (__GNUC__) && (__GNUC__ < 3)
66 typedef int intptr_t;
67 #endif
68 
69 namespace ARDOUR {
70 
71 class Source;
72 class AudioSource;
73 class GraphNode;
74 class Route;
75 class Region;
76 class Playlist;
77 class Stripable;
78 class VCA;
79 class AutomationControl;
80 class SlavableAutomationControl;
81 
82 typedef float Sample;
83 typedef float pan_t;
84 typedef float gain_t;
85 typedef uint32_t layer_t;
86 typedef uint32_t pframes_t;
87 
88 /* rebind Temporal position types into ARDOUR namespace */
92 
96 
97 static const layer_t max_layer = UINT32_MAX;
98 
99 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
100 typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
101 // associate a set of intervals with regions (e.g. for silence detection)
102 typedef std::map<std::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
103 
104 typedef std::list<std::shared_ptr<Region> > RegionList;
105 typedef std::set<std::shared_ptr<Playlist> > PlaylistSet;
106 
107 struct IOChange {
108 
109  enum Type {
110  NoChange = 0,
112  ConnectionsChanged = 0x2
113  } type;
114 
116  IOChange (Type t) : type (t) {}
117 
122 };
123 
124 /* policies for inserting/pasting material where overlaps
125  might be an issue.
126 */
127 
135 };
136 
189 
190  /* used only by Controllable Descriptor to access send parameters */
191 
195 };
196 
197 enum AutoState {
198  Off = 0x00,
199  Write = 0x01,
200  Touch = 0x02,
201  Play = 0x04,
202  Latch = 0x08
203 };
204 
207 
211 };
212 
216  Automatic
217 };
218 
225 };
226 
228  DiskIOPreFader, /* after the trim control, but before other processors */
229  DiskIOPostFader, /* before the main outs, after other processors */
230  DiskIOCustom, /* up to the user. Caveat Emptor! */
231 };
232 
233 enum MeterType {
234  MeterMaxSignal = 0x0001,
235  MeterMaxPeak = 0x0002,
236  MeterPeak = 0x0004,
237  MeterKrms = 0x0008,
238  MeterK20 = 0x0010,
239  MeterK14 = 0x0020,
240  MeterIEC1DIN = 0x0040,
241  MeterIEC1NOR = 0x0080,
242  MeterIEC2BBC = 0x0100,
243  MeterIEC2EBU = 0x0200,
244  MeterVU = 0x0400,
245  MeterK12 = 0x0800,
246  MeterPeak0dB = 0x1000,
247  MeterMCP = 0x2000
248 };
249 
250 enum TrackMode {
253  /* No longer in use but kept to allow loading of older sessions */
255 };
256 
261 };
262 
268 };
269 
270 enum NoteMode {
272  Percussive
273 };
274 
278  ForceChannel
279 };
280 
281 enum ColorMode {
284  TrackColor
285 };
286 
287 enum SnapPref {
288  SnapToAny_Visual = 0,
292  SnapToGrid_Scaled = 1,
296  SnapToGrid_Unscaled = 2,
300 };
301 
302 class AnyTime {
303  public:
304  enum Type {
308  Seconds
309  };
310 
312 
315 
316  union {
318  double seconds;
319  };
320 
321  AnyTime() { type = Samples; samples = 0; }
322 
323  bool operator== (AnyTime const & other) const {
324  if (type != other.type) { return false; }
325 
326  switch (type) {
327  case Timecode:
328  return timecode == other.timecode;
329  case BBT:
330  return bbt == other.bbt;
331  case Samples:
332  return samples == other.samples;
333  case Seconds:
334  return seconds == other.seconds;
335  }
336  return false; // get rid of warning
337  }
338 
339  bool not_zero() const
340  {
341  switch (type) {
342  case Timecode:
343  return timecode.hours != 0 || timecode.minutes != 0 ||
344  timecode.seconds != 0 || timecode.frames != 0;
345  case BBT:
346  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
347  case Samples:
348  return samples != 0;
349  case Seconds:
350  return seconds != 0;
351  }
352 
353  abort(); /* NOTREACHED */
354  return false;
355  }
356 };
357 
358 /* used for translating audio samples to an exact musical position using a note divisor.
359  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
360  musical accuracy we need to derive exact musical locations from a sample position
361  the division follows TempoMap::exact_beat_at_sample().
362  division
363  -1 musical location is the bar closest to sample
364  0 musical location is the musical position of the sample
365  1 musical location is the BBT beat closest to sample
366  n musical location is the quarter-note division n closest to sample
367 */
368 struct MusicSample {
370  int32_t division;
371 
372  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
373 
374  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
375 
376  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
377 };
378 
379 /* Just a Temporal::Range with an ID for identity
380  */
382 {
383  uint32_t id;
384 
385  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
386 
387  samplecnt_t length_samples() const { return length().samples(); }
388 
389  bool operator== (const TimelineRange& other) const {
390  return id == other.id && Temporal::TimeRange::operator== (other);
391  }
392 
393  bool equal (const TimelineRange& other) const {
394  return Temporal::TimeRange::operator== (other);
395  }
396 };
397 
398 class CueMarker {
399  public:
400  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
401 
402  std::string text() const { return _text; }
403  void set_text (std::string const & str) { _text = str; }
404 
405  timepos_t position() const { return _position; }
406  void set_position (timepos_t const & pos) { _position = pos; }
407 
408  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
409  bool operator< (CueMarker const & other) const { return _position < other.position(); }
410 
411  private:
412  std::string _text;
414 };
415 
416 typedef std::set<CueMarker> CueMarkers;
417 
418 /*
419  Slowest = 6.6dB/sec falloff at update rate of 40ms
420  Slow = 6.8dB/sec falloff at update rate of 40ms
421 */
422 
433 };
434 
435 enum MeterHold {
439  MeterHoldLong = 200
440 };
441 
442 enum EditMode {
445  Lock
446 };
447 
452 };
453 
458 };
459 
461  None = 0,
462  NewlyCreatedLeft = 1, // bit 0
463  NewlyCreatedRight = 2, // bit 1
465  Existing = 4, // bit 2
469 };
470 
472  ClearSel = 0,
473  PreserveSel = 1, // bit 0
474  ForceSel = 2 // bit 1
475 };
476 
482 };
483 
487  SyncPoint
488 };
489 
490 enum Placement {
492  PostFader
493 };
494 
499 };
500 
504  MonitorDisk = 0x2,
505  MonitorCue = 0x3,
506 };
507 
510  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
511  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
512 };
513 
519 };
520 
526 };
527 
533 };
534 
539 };
540 
546 };
547 
553 };
554 
559 };
560 
566 };
567 
570  Manual
571 };
572 
576 };
577 
581  AutoConnectMaster = 0x2
582 };
583 
586  NameAfterDriver = 0x2
587 };
588 
593 };
594 
596 
601  MP4Chaps
602 };
603 
615 };
616 
617 struct PeakData {
618  typedef Sample PeakDatum;
619 
622 };
623 
628 };
629 
631  /* The first two are "synonyms". It is important for JACK to be first
632  both here and in enums.cc, so that the string "JACK" is
633  correctly recognized in older session and preference files.
634  */
635  JACK = 0,
636  Engine = 0,
640 };
641 
649 };
650 
653  TR_Speed = 0x2,
654  TR_Locate = 0x4
655 };
656 
659  Semitones
660 };
661 
662 typedef std::vector<std::shared_ptr<Source> > SourceList;
663 
669  SrcFastest
670 };
671 
672 typedef std::list<samplepos_t> AnalysisFeatureList;
673 typedef std::vector<samplepos_t> XrunPositions;
674 
675 typedef std::list<std::shared_ptr<Route> > RouteList;
676 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
677 typedef std::list<std::shared_ptr<Stripable> > StripableList;
678 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
679 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
680 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
681 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
682 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
683 typedef std::set <AutomationType> AutomationTypeSet;
684 
685 typedef std::list<std::shared_ptr<VCA> > VCAList;
686 
687 class Bundle;
688 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
689 
690 class IOPlug;
691 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
692 
697  LayerTime
698 };
699 
703 };
704 
707  Rectified
708 };
709 
714 };
715 
717  CleanupReport () : space (0) {}
718  std::vector<std::string> paths;
719  size_t space;
720 };
721 
726 };
727 
732 };
733 
743  enum Type {
749  CustomPinChange = 0x10
750  };
751 
753  {}
754 
756  {}
757 
759  {}
760 
765 };
766 
767 struct BusProfile {
769  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
770 };
771 
772 enum FadeShape {
778 };
779 
781  /* these values happen to match the constants used by JACK but
782  this equality cannot be assumed.
783  */
788 };
789 
790 enum PortFlags {
791  /* these values happen to match the constants used by JACK but
792  this equality cannot be assumed.
793  */
794  IsInput = 0x1,
795  IsOutput = 0x2,
796  IsPhysical = 0x4,
797  CanMonitor = 0x8,
798  IsTerminal = 0x10,
799 
800  /* non-JACK related flags */
801  Hidden = 0x20,
802  Shadow = 0x40,
803 
804  TransportMasterPort = 0x80, // incoming data, used by slaves
805  TransportGenerator = 0x100, // outgoing, timecode/clock generators
806  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
807 };
808 
813  MidiPortVirtual = 0x8
814 };
815 
816 struct LatencyRange {
817  LatencyRange () : min (0), max (0) {}
818  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
819 
820  uint32_t min; //< samples
821  uint32_t max; //< samples
822 
823  bool operator==(const LatencyRange& other) const {
824  return (min == other.min && max == other.max);
825  }
826 
828  min = other.min;
829  max = other.max;
830  return *this;
831  }
832 };
833 
839 };
840 
842  LastLocate = 0x1,
844  Loop = 0x4,
846 };
847 
852 };
853 
859 };
860 
864 };
865 
866 struct CaptureInfo {
871 };
872 
878 };
879 
881  PlaylistChanged = 0x1, // actual playlist was swapped/reset
882  PlaylistModified = 0x2, // contents of playlist changed
884  LoopChanged = 0x8,
885 };
886 
891 };
892 
894  FollowCues = 0x1,
896 };
897 
898 typedef std::vector<CaptureInfo*> CaptureInfos;
899 
900 struct FollowAction {
901  enum Type {
905  ForwardTrigger, /* any "next" skipping empties */
906  ReverseTrigger, /* any "prev" skipping empties */
910  };
911 
912  /* We could theoretically limit this to default_triggers_per_box but
913  * doing it this way makes it likely that this will not change. Could
914  * be worth a constexpr-style compile time assert to check
915  * default_triggers_per_box < 64
916  */
917 
918  typedef std::bitset<64> Targets;
919 
922 
924  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
925  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
926  FollowAction (std::string const &);
927 
928  static Targets target_any () { Targets t; t.set(); return t; }
929  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
930  static Targets target_next_wrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } else { t.set (0); } return t; }
931  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
932  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
933  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
934 
935  bool operator!= (FollowAction const & other) const {
936  return other.type != type || other.targets != targets;
937  }
938 
939  bool operator== (FollowAction const & other) const {
940  return other.type == type && other.targets == targets;
941  }
942 
943  bool is_arrangement() {
944  return (
945  (type==ForwardTrigger) ||
946  (type==ReverseTrigger) ||
947  (type==JumpTrigger) );
948  }
949 
950  std::string to_string() const;
951 };
952 
953 struct CueEvent {
954  int32_t cue;
956 
957  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
958 };
959 
960 typedef std::vector<CueEvent> CueEvents;
961 
962 /* Describes the one or two contiguous time ranges processsed by a process
963  * callback. The @param cnt member indicates if there are 1 or 2 valid
964  * elements; It will only be 2 if a locate-for-loop-end occured during the
965  * process cycle.
966  *
967  * Owned by Session. Readable ONLY within process context AFTER
968  * Session::process() has returned.
969  */
970 
974  uint32_t cnt;
975 
976  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
977 };
978 
984  SelectionExtend /* UI only operation, not core */
985 };
986 
987 
988 } // namespace ARDOUR
989 
990 /* for now, break the rules and use "using" to make this "global" */
991 
992 using ARDOUR::samplepos_t;
993 
994 #endif /* __ardour_types_h__ */
void None
Definition: TypeList.h:49
Temporal::BBT_Time bbt
Timecode::Time timecode
bool operator==(AnyTime const &other) const
CueMarker(std::string const &text, timepos_t const &position)
timepos_t position() const
void set_position(timepos_t const &pos)
bool operator<(CueMarker const &other) const
std::string text() const
void set_text(std::string const &str)
bool operator==(CueMarker const &other) const
A node in the hierarchical graph that represents a multiplicatable export item.
bool operator==(Range const &other) const
timecnt_t length() const
int64_t samples() const
Definition: timeline.h:361
std::string auto_state_to_string(AutoState)
std::list< std::pair< sampleoffset_t, sampleoffset_t > > AudioIntervalResult
@ HardwareMonitoring
JACK does monitoring.
@ SoftwareMonitoring
Ardour does monitoring.
@ ExternalMonitoring
we leave monitoring to the audio hardware
AutoState string_to_auto_state(std::string)
std::list< samplepos_t > AnalysisFeatureList
std::set< CueMarker > CueMarkers
uint32_t pframes_t
std::vector< std::shared_ptr< Source > > SourceList
uint64_t superclock_t
Definition: beatbox.h:43
TimeSelectionAfterSectionPaste
@ SectionSelectRetainAndMovePlayhead
@ MeteringVUstandard
0VU = +4dBu
@ MeteringVUeight
0VU = +8dBu
@ MeteringVUfrench
0VU = -2dBu
@ MeteringVUamerican
0VU = 0dBu
std::list< std::shared_ptr< AutomationControl > > AutomationControlList
std::vector< CueEvent > CueEvents
@ InsertMergeTruncateExisting
shorten existing to avoid overlap
@ InsertMergeReject
no overlaps allowed
@ InsertMergeRelax
we just don't care about overlaps
@ InsertMergeExtend
extend new (or old) to the range of old+new
@ InsertMergeTruncateAddition
shorten new to avoid overlap
@ InsertMergeReplace
replace old with new
std::list< std::shared_ptr< Stripable > > StripableList
std::set< AutomationType > AutomationTypeSet
Temporal::samplecnt_t samplecnt_t
@ ExistingNewlyCreatedLeft
@ ExistingNewlyCreatedBoth
@ ExistingNewlyCreatedRight
static const layer_t max_layer
@ AllChannels
Pass through all channel information unmodified.
@ ForceChannel
Force all events to a certain channel.
@ FilterChannels
Ignore events on certain channels.
std::vector< samplepos_t > XrunPositions
std::vector< CaptureInfo * > CaptureInfos
std::map< std::shared_ptr< ARDOUR::Region >, AudioIntervalResult > AudioIntervalMap
std::list< std::shared_ptr< Region > > RegionList
std::vector< std::shared_ptr< Bundle > > BundleList
int format_data_width(ARDOUR::SampleFormat)
Temporal::timecnt_t timecnt_t
std::set< std::shared_ptr< Playlist > > PlaylistSet
std::list< std::shared_ptr< SlavableAutomationControl > > SlavableAutomationControlList
std::list< std::shared_ptr< VCA > > VCAList
std::vector< std::shared_ptr< IOPlug > > IOPlugList
Temporal::timepos_t timepos_t
std::list< std::weak_ptr< Stripable > > WeakStripableList
Temporal::sampleoffset_t sampleoffset_t
std::list< std::shared_ptr< GraphNode > > GraphNodeList
std::list< std::shared_ptr< Route > > RouteList
std::list< std::weak_ptr< AutomationControl > > WeakAutomationControlList
@ MidiNotePressureAutomation
@ MidiSystemExclusiveAutomation
@ PluginPropertyAutomation
@ MidiPitchBenderAutomation
@ MidiChannelPressureAutomation
@ PanSurroundElevationEnable
Temporal::samplepos_t samplepos_t
uint32_t layer_t
std::list< std::weak_ptr< Route > > WeakRouteList
DebugBits VCA
static const samplecnt_t max_samplecnt
static const samplepos_t max_samplepos
int64_t superclock_t
Definition: superclock.h:35
std::vector< std::string > paths
CueEvent(int32_t c, samplepos_t t)
FollowAction(std::string const &)
static Targets target_next_nowrap(uint8_t from)
FollowAction(Type t, Targets const &tgts=Targets())
static Targets target_next_wrap(uint8_t from)
static Targets target_any()
std::string to_string() const
FollowAction(Type t, std::string const &bitstring)
std::bitset< 64 > Targets
static Targets target_other(uint8_t skip)
bool operator==(FollowAction const &other) const
static Targets target_prev_wrap(uint8_t from)
bool operator!=(FollowAction const &other) const
static Targets target_prev_nowrap(uint8_t from)
ARDOUR::ChanCount before
ARDOUR::ChanCount after
enum ARDOUR::IOChange::Type type
LatencyRange & operator=(const LatencyRange &other)
LatencyRange(const LatencyRange &other)
bool operator==(const LatencyRange &other) const
MusicSample operator-(MusicSample other)
void set(samplepos_t f, int32_t d)
MusicSample(samplepos_t f, int32_t d)
bool equal(const TimelineRange &other) const
TimelineRange(Temporal::timepos_t const &s, Temporal::timepos_t e, uint32_t i)
samplecnt_t length_samples() const
bool operator==(const TimelineRange &other) const
uint32_t hours
Definition: time.h:56
uint32_t minutes
Definition: time.h:57
uint32_t seconds
Definition: time.h:58
uint32_t frames
Timecode frames (not audio frames)
Definition: time.h:59