Ardour  9.0-rc2-38-g267efab6e8
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 #pragma once
32 
33 #include <bitset>
34 #include <cstdint>
35 #include <istream>
36 #include <map>
37 #include <memory>
38 #include <set>
39 #include <vector>
40 
41 #include <sys/types.h>
42 #include <pthread.h>
43 
44 #include <inttypes.h>
45 
46 #include "temporal/bbt_time.h"
47 #include "temporal/range.h"
48 #include "temporal/superclock.h"
49 #include "temporal/time.h"
50 #include "temporal/timeline.h"
51 #include "temporal/types.h"
52 
53 #include "pbd/id.h"
54 #include "pbd/microseconds.h"
55 
56 #include "ardour/chan_count.h"
57 #include "ardour/plugin_types.h"
58 
59 #include <map>
60 
63 
64 #if defined (__GNUC__) && (__GNUC__ < 3)
65 typedef int intptr_t;
66 #endif
67 
68 namespace ARDOUR {
69 
70 class Source;
71 class AudioSource;
72 class GraphNode;
73 class Route;
74 class RouteGroup;
75 class Region;
76 class Playlist;
77 class Stripable;
78 class Trigger;
79 class VCA;
80 class AutomationControl;
81 class SlavableAutomationControl;
82 
83 typedef float Sample;
84 typedef float pan_t;
85 typedef float gain_t;
86 typedef uint32_t layer_t;
87 typedef uint32_t pframes_t;
88 
89 /* rebind Temporal position types into ARDOUR namespace */
93 
97 
98 static const layer_t max_layer = UINT32_MAX;
99 
100 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
101 typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
102 // associate a set of intervals with regions (e.g. for silence detection)
103 typedef std::map<std::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
104 
105 typedef std::list<std::shared_ptr<Region> > RegionList;
106 typedef std::set<std::shared_ptr<Playlist> > PlaylistSet;
107 typedef std::list<std::shared_ptr<RouteGroup>> RouteGroupList;
108 
109 
110 struct IOChange {
111 
112  enum Type {
113  NoChange = 0,
115  ConnectionsChanged = 0x2
116  } type;
117 
119  IOChange (Type t) : type (t) {}
120 
125 };
126 
127 /* policies for inserting/pasting material where overlaps
128  might be an issue.
129 */
130 
138 };
139 
192 
193  /* used only by Controllable Descriptor to access send parameters */
194 
198 };
199 
200 enum AutoState {
201  Off = 0x00,
202  Write = 0x01,
203  Touch = 0x02,
204  Play = 0x04,
205  Latch = 0x08
206 };
207 
210 
214 };
215 
219  Automatic
220 };
221 
228 };
229 
231  DiskIOPreFader, /* after the trim control, but before other processors */
232  DiskIOPostFader, /* before the main outs, after other processors */
233  DiskIOCustom, /* up to the user. Caveat Emptor! */
234 };
235 
236 enum MeterType {
237  MeterMaxSignal = 0x0001,
238  MeterMaxPeak = 0x0002,
239  MeterPeak = 0x0004,
240  MeterKrms = 0x0008,
241  MeterK20 = 0x0010,
242  MeterK14 = 0x0020,
243  MeterIEC1DIN = 0x0040,
244  MeterIEC1NOR = 0x0080,
245  MeterIEC2BBC = 0x0100,
246  MeterIEC2EBU = 0x0200,
247  MeterVU = 0x0400,
248  MeterK12 = 0x0800,
249  MeterPeak0dB = 0x1000,
250  MeterMCP = 0x2000
251 };
252 
253 enum TrackMode {
256  /* No longer in use but kept to allow loading of older sessions */
258 };
259 
264 };
265 
271 };
272 
273 enum NoteMode {
275  Percussive
276 };
277 
281  ForceChannel
282 };
283 
284 enum ColorMode {
287  TrackColor
288 };
289 
290 enum SnapPref {
291  SnapToAny_Visual = 0,
295  SnapToGrid_Scaled = 1,
299  SnapToGrid_Unscaled = 2,
303 };
304 
305 class AnyTime {
306  public:
307  enum Type {
312  Seconds
313  };
314 
316 
318  union {
321  };
322 
323  union {
325  double seconds;
326  };
327 
328  AnyTime () : type (Samples), samples (0) {}
330  AnyTime (std::string const &);
331 
332  std::string str() const;
333 
334  bool operator== (AnyTime const & other) const {
335  if (type != other.type) { return false; }
336 
337  switch (type) {
338  case Timecode:
339  return timecode == other.timecode;
340  case BBT:
341  return bbt == other.bbt;
342  case BBT_Offset:
343  return bbt_offset == other.bbt_offset;
344  case Samples:
345  return samples == other.samples;
346  case Seconds:
347  return seconds == other.seconds;
348  }
349  return false; // get rid of warning
350  }
351 
352  bool not_zero() const
353  {
354  switch (type) {
355  case Timecode:
356  return timecode.hours != 0 || timecode.minutes != 0 ||
357  timecode.seconds != 0 || timecode.frames != 0;
358  case BBT:
359  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
360  case BBT_Offset:
361  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
362  case Samples:
363  return samples != 0;
364  case Seconds:
365  return seconds != 0;
366  }
367 
368  abort(); /* NOTREACHED */
369  return false;
370  }
371 };
372 
373 /* used for translating audio samples to an exact musical position using a note divisor.
374  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
375  musical accuracy we need to derive exact musical locations from a sample position
376  the division follows TempoMap::exact_beat_at_sample().
377  division
378  -1 musical location is the bar closest to sample
379  0 musical location is the musical position of the sample
380  1 musical location is the BBT beat closest to sample
381  n musical location is the quarter-note division n closest to sample
382 */
383 struct MusicSample {
385  int32_t division;
386 
387  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
388 
389  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
390 
391  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
392 };
393 
394 /* Just a Temporal::Range with an ID for identity
395  */
397 {
398  uint32_t id;
399 
400  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
401 
402  samplecnt_t length_samples() const { return length().samples(); }
403 
404  bool operator== (const TimelineRange& other) const {
405  return id == other.id && Temporal::TimeRange::operator== (other);
406  }
407 
408  bool equal (const TimelineRange& other) const {
409  return Temporal::TimeRange::operator== (other);
410  }
411 };
412 
413 class CueMarker {
414  public:
415  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
416 
417  std::string text() const { return _text; }
418  void set_text (std::string const & str) { _text = str; }
419 
420  timepos_t position() const { return _position; }
421  void set_position (timepos_t const & pos) { _position = pos; }
422 
423  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
424  bool operator< (CueMarker const & other) const { return _position < other.position(); }
425 
426  private:
427  std::string _text;
429 };
430 
431 typedef std::set<CueMarker> CueMarkers;
432 
433 /*
434  Slowest = 6.6dB/sec falloff at update rate of 40ms
435  Slow = 6.8dB/sec falloff at update rate of 40ms
436 */
437 
448 };
449 
450 enum MeterHold {
454  MeterHoldLong = 200
455 };
456 
457 enum EditMode {
460  Lock
461 };
462 
467 };
468 
473 };
474 
476  None = 0,
477  NewlyCreatedLeft = 1, // bit 0
478  NewlyCreatedRight = 2, // bit 1
480  Existing = 4, // bit 2
484 };
485 
487  ClearSel = 0,
488  PreserveSel = 1, // bit 0
489  ForceSel = 2 // bit 1
490 };
491 
497 };
498 
502  SyncPoint
503 };
504 
505 enum Placement {
507  PostFader
508 };
509 
514 };
515 
519  MonitorDisk = 0x2,
520  MonitorCue = 0x3,
521 };
522 
525  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
526  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
527 };
528 
534 };
535 
541 };
542 
548 };
549 
554 };
555 
561 };
562 
568 };
569 
574 };
575 
581 };
582 
585  Manual
586 };
587 
591 };
592 
596  AutoConnectMaster = 0x2
597 };
598 
601  NameAfterDriver = 0x2
602 };
603 
608 };
609 
611 
616  MP4Chaps
617 };
618 
630 };
631 
632 struct PeakData {
633  typedef Sample PeakDatum;
634 
637 };
638 
643 };
644 
646  /* The first two are "synonyms". It is important for JACK to be first
647  both here and in enums.cc, so that the string "JACK" is
648  correctly recognized in older session and preference files.
649  */
650  JACK = 0,
651  Engine = 0,
655 };
656 
664 };
665 
668  TR_Speed = 0x2,
669  TR_Locate = 0x4
670 };
671 
674  Semitones
675 };
676 
677 typedef std::vector<std::shared_ptr<Source> > SourceList;
678 
684  SrcFastest
685 };
686 
687 typedef std::list<samplepos_t> AnalysisFeatureList;
688 typedef std::vector<samplepos_t> XrunPositions;
689 
690 typedef std::list<std::shared_ptr<Route> > RouteList;
691 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
692 typedef std::list<std::shared_ptr<Stripable> > StripableList;
693 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
694 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
695 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
696 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
697 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
698 typedef std::set <AutomationType> AutomationTypeSet;
699 
700 typedef std::list<std::shared_ptr<VCA> > VCAList;
701 
702 class Bundle;
703 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
704 
705 class IOPlug;
706 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
707 
712  LayerTime
713 };
714 
718 };
719 
722  Rectified
723 };
724 
729 };
730 
732  CleanupReport () : space (0) {}
733  std::vector<std::string> paths;
734  size_t space;
735 };
736 
741 };
742 
747 };
748 
758  enum Type {
766  PortNameChange = 0x40
767  };
768 
770  {}
771 
773  {}
774 
776  {}
777 
782 };
783 
784 struct BusProfile {
786  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
787 };
788 
789 enum FadeShape {
795 };
796 
798  /* these values happen to match the constants used by JACK but
799  this equality cannot be assumed.
800  */
805 };
806 
807 enum PortFlags {
808  /* these values happen to match the constants used by JACK but
809  this equality cannot be assumed.
810  */
811  IsInput = 0x1,
812  IsOutput = 0x2,
813  IsPhysical = 0x4,
814  CanMonitor = 0x8,
815  IsTerminal = 0x10,
816 
817  /* non-JACK related flags */
818  Hidden = 0x20,
819  Shadow = 0x40,
820 
821  TransportMasterPort = 0x80, // incoming data, used by slaves
822  TransportGenerator = 0x100, // outgoing, timecode/clock generators
823  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
824 };
825 
830  MidiPortVirtual = 0x8
831 };
832 
833 struct LatencyRange {
834  LatencyRange () : min (0), max (0) {}
835  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
836 
837  uint32_t min; //< samples
838  uint32_t max; //< samples
839 
840  bool operator==(const LatencyRange& other) const {
841  return (min == other.min && max == other.max);
842  }
843 
845  min = other.min;
846  max = other.max;
847  return *this;
848  }
849 };
850 
856 };
857 
859  LastLocate = 0x1,
861  Loop = 0x4,
863 };
864 
869 };
870 
876 };
877 
881 };
882 
883 struct CaptureInfo {
888 };
889 
895 };
896 
898  PlaylistChanged = 0x1, // actual playlist was swapped/reset
899  PlaylistModified = 0x2, // contents of playlist changed
901  LoopChanged = 0x8,
902 };
903 
908 };
909 
911  FollowCues = 0x1,
913 };
914 
915 typedef std::vector<CaptureInfo*> CaptureInfos;
916 
917 struct FollowAction {
918  enum Type {
922  ForwardTrigger, /* any "next" skipping empties */
923  ReverseTrigger, /* any "prev" skipping empties */
927  };
928 
929  /* We could theoretically limit this to default_triggers_per_box but
930  * doing it this way makes it likely that this will not change. Could
931  * be worth a constexpr-style compile time assert to check
932  * default_triggers_per_box < 64
933  */
934 
935  typedef std::bitset<64> Targets;
936 
939 
941  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
942  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
943  FollowAction (std::string const &);
944 
945  static Targets target_any () { Targets t; t.set(); return t; }
946  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
947  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; }
948  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
949  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
950  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
951 
952  bool operator!= (FollowAction const & other) const {
953  return other.type != type || other.targets != targets;
954  }
955 
956  bool operator== (FollowAction const & other) const {
957  return other.type == type && other.targets == targets;
958  }
959 
960  bool is_arrangement() {
961  return (
962  (type==ForwardTrigger) ||
963  (type==ReverseTrigger) ||
964  (type==JumpTrigger) );
965  }
966 
967  std::string to_string() const;
968 };
969 
970 struct CueEvent {
971  int32_t cue;
973 
974  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
975 };
976 
977 typedef std::vector<CueEvent> CueEvents;
978 
979 /* Describes the one or two contiguous time ranges processsed by a process
980  * callback. The @param cnt member indicates if there are 1 or 2 valid
981  * elements; It will only be 2 if a locate-for-loop-end occured during the
982  * process cycle.
983  *
984  * Owned by Session. Readable ONLY within process context AFTER
985  * Session::process() has returned.
986  */
987 
991  uint32_t cnt;
992 
993  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
994 };
995 
1001  SelectionExtend /* UI only operation, not core */
1002 };
1003 
1006  Enabled = 1,
1007  Recording = 2
1008 };
1009 
1010 
1011 /* compare to IEditController */
1017 };
1018 
1019 } // namespace ARDOUR
1020 
1021 /* for now, break the rules and use "using" to make this "global" */
1022 
1023 using ARDOUR::samplepos_t;
1024 
void None
Definition: TypeList.h:49
Temporal::BBT_Time bbt
Temporal::BBT_Offset bbt_offset
AnyTime(std::string const &)
Timecode::Time timecode
bool operator==(AnyTime const &other) const
std::string str() const
AnyTime(Temporal::BBT_Offset bt)
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
bool operator==(Range const &other) const
timecnt_t length() const
int64_t samples() const
Definition: timeline.h:360
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
std::list< std::shared_ptr< RouteGroup > > RouteGroupList
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:42
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
@ VST3KnobRelativCircularMode
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:34
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:55
uint32_t minutes
Definition: time.h:56
uint32_t seconds
Definition: time.h:57
uint32_t frames
Timecode frames (not audio frames)
Definition: time.h:58