Ardour  9.0-pre0-384-ga76afae0e9
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 Region;
75 class Playlist;
76 class Stripable;
77 class Trigger;
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 {
309  Seconds
310  };
311 
313 
315  union {
318  };
319 
320  union {
322  double seconds;
323  };
324 
325  AnyTime () : type (Samples), samples (0) {}
327  AnyTime (std::string const &);
328 
329  std::string str() const;
330 
331  bool operator== (AnyTime const & other) const {
332  if (type != other.type) { return false; }
333 
334  switch (type) {
335  case Timecode:
336  return timecode == other.timecode;
337  case BBT:
338  return bbt == other.bbt;
339  case BBT_Offset:
340  return bbt_offset == other.bbt_offset;
341  case Samples:
342  return samples == other.samples;
343  case Seconds:
344  return seconds == other.seconds;
345  }
346  return false; // get rid of warning
347  }
348 
349  bool not_zero() const
350  {
351  switch (type) {
352  case Timecode:
353  return timecode.hours != 0 || timecode.minutes != 0 ||
354  timecode.seconds != 0 || timecode.frames != 0;
355  case BBT:
356  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
357  case BBT_Offset:
358  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
359  case Samples:
360  return samples != 0;
361  case Seconds:
362  return seconds != 0;
363  }
364 
365  abort(); /* NOTREACHED */
366  return false;
367  }
368 };
369 
370 /* used for translating audio samples to an exact musical position using a note divisor.
371  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
372  musical accuracy we need to derive exact musical locations from a sample position
373  the division follows TempoMap::exact_beat_at_sample().
374  division
375  -1 musical location is the bar closest to sample
376  0 musical location is the musical position of the sample
377  1 musical location is the BBT beat closest to sample
378  n musical location is the quarter-note division n closest to sample
379 */
380 struct MusicSample {
382  int32_t division;
383 
384  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
385 
386  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
387 
388  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
389 };
390 
391 /* Just a Temporal::Range with an ID for identity
392  */
394 {
395  uint32_t id;
396 
397  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
398 
399  samplecnt_t length_samples() const { return length().samples(); }
400 
401  bool operator== (const TimelineRange& other) const {
402  return id == other.id && Temporal::TimeRange::operator== (other);
403  }
404 
405  bool equal (const TimelineRange& other) const {
406  return Temporal::TimeRange::operator== (other);
407  }
408 };
409 
410 class CueMarker {
411  public:
412  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
413 
414  std::string text() const { return _text; }
415  void set_text (std::string const & str) { _text = str; }
416 
417  timepos_t position() const { return _position; }
418  void set_position (timepos_t const & pos) { _position = pos; }
419 
420  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
421  bool operator< (CueMarker const & other) const { return _position < other.position(); }
422 
423  private:
424  std::string _text;
426 };
427 
428 typedef std::set<CueMarker> CueMarkers;
429 
430 /*
431  Slowest = 6.6dB/sec falloff at update rate of 40ms
432  Slow = 6.8dB/sec falloff at update rate of 40ms
433 */
434 
445 };
446 
447 enum MeterHold {
451  MeterHoldLong = 200
452 };
453 
454 enum EditMode {
457  Lock
458 };
459 
464 };
465 
470 };
471 
473  None = 0,
474  NewlyCreatedLeft = 1, // bit 0
475  NewlyCreatedRight = 2, // bit 1
477  Existing = 4, // bit 2
481 };
482 
484  ClearSel = 0,
485  PreserveSel = 1, // bit 0
486  ForceSel = 2 // bit 1
487 };
488 
494 };
495 
499  SyncPoint
500 };
501 
502 enum Placement {
504  PostFader
505 };
506 
511 };
512 
516  MonitorDisk = 0x2,
517  MonitorCue = 0x3,
518 };
519 
522  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
523  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
524 };
525 
531 };
532 
538 };
539 
545 };
546 
551 };
552 
558 };
559 
565 };
566 
571 };
572 
578 };
579 
582  Manual
583 };
584 
588 };
589 
593  AutoConnectMaster = 0x2
594 };
595 
598  NameAfterDriver = 0x2
599 };
600 
605 };
606 
608 
613  MP4Chaps
614 };
615 
627 };
628 
629 struct PeakData {
630  typedef Sample PeakDatum;
631 
634 };
635 
640 };
641 
643  /* The first two are "synonyms". It is important for JACK to be first
644  both here and in enums.cc, so that the string "JACK" is
645  correctly recognized in older session and preference files.
646  */
647  JACK = 0,
648  Engine = 0,
652 };
653 
661 };
662 
665  TR_Speed = 0x2,
666  TR_Locate = 0x4
667 };
668 
671  Semitones
672 };
673 
674 typedef std::vector<std::shared_ptr<Source> > SourceList;
675 
681  SrcFastest
682 };
683 
684 typedef std::list<samplepos_t> AnalysisFeatureList;
685 typedef std::vector<samplepos_t> XrunPositions;
686 
687 typedef std::list<std::shared_ptr<Route> > RouteList;
688 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
689 typedef std::list<std::shared_ptr<Stripable> > StripableList;
690 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
691 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
692 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
693 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
694 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
695 typedef std::set <AutomationType> AutomationTypeSet;
696 
697 typedef std::list<std::shared_ptr<VCA> > VCAList;
698 
699 class Bundle;
700 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
701 
702 class IOPlug;
703 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
704 
709  LayerTime
710 };
711 
715 };
716 
719  Rectified
720 };
721 
726 };
727 
729  CleanupReport () : space (0) {}
730  std::vector<std::string> paths;
731  size_t space;
732 };
733 
738 };
739 
744 };
745 
755  enum Type {
761  CustomPinChange = 0x10
762  };
763 
765  {}
766 
768  {}
769 
771  {}
772 
777 };
778 
779 struct BusProfile {
781  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
782 };
783 
784 enum FadeShape {
790 };
791 
793  /* these values happen to match the constants used by JACK but
794  this equality cannot be assumed.
795  */
800 };
801 
802 enum PortFlags {
803  /* these values happen to match the constants used by JACK but
804  this equality cannot be assumed.
805  */
806  IsInput = 0x1,
807  IsOutput = 0x2,
808  IsPhysical = 0x4,
809  CanMonitor = 0x8,
810  IsTerminal = 0x10,
811 
812  /* non-JACK related flags */
813  Hidden = 0x20,
814  Shadow = 0x40,
815 
816  TransportMasterPort = 0x80, // incoming data, used by slaves
817  TransportGenerator = 0x100, // outgoing, timecode/clock generators
818  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
819 };
820 
825  MidiPortVirtual = 0x8
826 };
827 
828 struct LatencyRange {
829  LatencyRange () : min (0), max (0) {}
830  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
831 
832  uint32_t min; //< samples
833  uint32_t max; //< samples
834 
835  bool operator==(const LatencyRange& other) const {
836  return (min == other.min && max == other.max);
837  }
838 
840  min = other.min;
841  max = other.max;
842  return *this;
843  }
844 };
845 
851 };
852 
854  LastLocate = 0x1,
856  Loop = 0x4,
858 };
859 
864 };
865 
871 };
872 
876 };
877 
878 struct CaptureInfo {
883 };
884 
890 };
891 
893  PlaylistChanged = 0x1, // actual playlist was swapped/reset
894  PlaylistModified = 0x2, // contents of playlist changed
896  LoopChanged = 0x8,
897 };
898 
903 };
904 
906  FollowCues = 0x1,
908 };
909 
910 typedef std::vector<CaptureInfo*> CaptureInfos;
911 
912 struct FollowAction {
913  enum Type {
917  ForwardTrigger, /* any "next" skipping empties */
918  ReverseTrigger, /* any "prev" skipping empties */
922  };
923 
924  /* We could theoretically limit this to default_triggers_per_box but
925  * doing it this way makes it likely that this will not change. Could
926  * be worth a constexpr-style compile time assert to check
927  * default_triggers_per_box < 64
928  */
929 
930  typedef std::bitset<64> Targets;
931 
934 
936  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
937  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
938  FollowAction (std::string const &);
939 
940  static Targets target_any () { Targets t; t.set(); return t; }
941  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
942  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; }
943  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
944  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
945  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
946 
947  bool operator!= (FollowAction const & other) const {
948  return other.type != type || other.targets != targets;
949  }
950 
951  bool operator== (FollowAction const & other) const {
952  return other.type == type && other.targets == targets;
953  }
954 
955  bool is_arrangement() {
956  return (
957  (type==ForwardTrigger) ||
958  (type==ReverseTrigger) ||
959  (type==JumpTrigger) );
960  }
961 
962  std::string to_string() const;
963 };
964 
965 struct CueEvent {
966  int32_t cue;
968 
969  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
970 };
971 
972 typedef std::vector<CueEvent> CueEvents;
973 
974 /* Describes the one or two contiguous time ranges processsed by a process
975  * callback. The @param cnt member indicates if there are 1 or 2 valid
976  * elements; It will only be 2 if a locate-for-loop-end occured during the
977  * process cycle.
978  *
979  * Owned by Session. Readable ONLY within process context AFTER
980  * Session::process() has returned.
981  */
982 
986  uint32_t cnt;
987 
988  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
989 };
990 
996  SelectionExtend /* UI only operation, not core */
997 };
998 
1001  Enabled = 1,
1002  Recording = 2
1003 };
1004 
1005 
1006 } // namespace ARDOUR
1007 
1008 /* for now, break the rules and use "using" to make this "global" */
1009 
1010 using ARDOUR::samplepos_t;
1011 
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
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
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