Ardour  9.2-541-gc1841a13dd
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 AudioTrack;
73 class GraphNode;
74 class Route;
75 class RouteGroup;
76 class Region;
77 class Playlist;
78 class Stripable;
79 class Trigger;
80 class VCA;
81 class AutomationControl;
82 class SlavableAutomationControl;
83 
84 typedef float Sample;
85 typedef float pan_t;
86 typedef float gain_t;
87 typedef uint32_t layer_t;
88 typedef uint32_t pframes_t;
89 
90 /* rebind Temporal position types into ARDOUR namespace */
94 
98 
99 static const layer_t max_layer = UINT32_MAX;
100 
101 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
102 typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
103 // associate a set of intervals with regions (e.g. for silence detection)
104 typedef std::map<std::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
105 
106 typedef std::list<std::shared_ptr<Region> > RegionList;
107 typedef std::set<std::shared_ptr<Playlist> > PlaylistSet;
108 typedef std::list<std::shared_ptr<RouteGroup>> RouteGroupList;
109 
110 
111 struct IOChange {
112 
113  enum Type {
114  NoChange = 0,
116  ConnectionsChanged = 0x2
117  } type;
118 
120  IOChange (Type t) : type (t) {}
121 
126 };
127 
128 /* policies for inserting/pasting material where overlaps
129  might be an issue.
130 */
131 
139 };
140 
193 
194  /* used only by Controllable Descriptor to access send parameters */
195 
199 };
200 
201 enum AutoState {
202  Off = 0x00,
203  Write = 0x01,
204  Touch = 0x02,
205  Play = 0x04,
206  Latch = 0x08
207 };
208 
211 
215 };
216 
220  Automatic
221 };
222 
229 };
230 
232  DiskIOPreFader, /* after the trim control, but before other processors */
233  DiskIOPostFader, /* before the main outs, after other processors */
234  DiskIOCustom, /* up to the user. Caveat Emptor! */
235 };
236 
237 enum MeterType {
238  MeterMaxSignal = 0x0001,
239  MeterMaxPeak = 0x0002,
240  MeterPeak = 0x0004,
241  MeterKrms = 0x0008,
242  MeterK20 = 0x0010,
243  MeterK14 = 0x0020,
244  MeterIEC1DIN = 0x0040,
245  MeterIEC1NOR = 0x0080,
246  MeterIEC2BBC = 0x0100,
247  MeterIEC2EBU = 0x0200,
248  MeterVU = 0x0400,
249  MeterK12 = 0x0800,
250  MeterPeak0dB = 0x1000,
251  MeterMCP = 0x2000
252 };
253 
254 enum TrackMode {
257  /* No longer in use but kept to allow loading of older sessions */
259 };
260 
265 };
266 
272 };
273 
274 enum NoteMode {
276  Percussive
277 };
278 
282  ForceChannel
283 };
284 
285 enum ColorMode {
290 };
291 
292 enum SnapPref {
293  SnapToAny_Visual = 0,
297  SnapToGrid_Scaled = 1,
301  SnapToGrid_Unscaled = 2,
305 };
306 
307 class AnyTime {
308  public:
309  enum Type {
314  Seconds
315  };
316 
318 
320  union {
323  };
324 
325  union {
327  double seconds;
328  };
329 
330  AnyTime () : type (Samples), samples (0) {}
332  AnyTime (std::string const &);
333 
334  std::string str() const;
335 
336  bool operator== (AnyTime const & other) const {
337  if (type != other.type) { return false; }
338 
339  switch (type) {
340  case Timecode:
341  return timecode == other.timecode;
342  case BBT:
343  return bbt == other.bbt;
344  case BBT_Offset:
345  return bbt_offset == other.bbt_offset;
346  case Samples:
347  return samples == other.samples;
348  case Seconds:
349  return seconds == other.seconds;
350  }
351  return false; // get rid of warning
352  }
353 
354  bool not_zero() const
355  {
356  switch (type) {
357  case Timecode:
358  return timecode.hours != 0 || timecode.minutes != 0 ||
359  timecode.seconds != 0 || timecode.frames != 0;
360  case BBT:
361  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
362  case BBT_Offset:
363  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
364  case Samples:
365  return samples != 0;
366  case Seconds:
367  return seconds != 0;
368  }
369 
370  abort(); /* NOTREACHED */
371  return false;
372  }
373 };
374 
375 /* used for translating audio samples to an exact musical position using a note divisor.
376  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
377  musical accuracy we need to derive exact musical locations from a sample position
378  the division follows TempoMap::exact_beat_at_sample().
379  division
380  -1 musical location is the bar closest to sample
381  0 musical location is the musical position of the sample
382  1 musical location is the BBT beat closest to sample
383  n musical location is the quarter-note division n closest to sample
384 */
385 struct MusicSample {
387  int32_t division;
388 
389  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
390 
391  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
392 
393  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
394 };
395 
396 /* Just a Temporal::Range with an ID for identity
397  */
399 {
400  uint32_t id;
401 
402  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
403 
404  samplecnt_t length_samples() const { return length().samples(); }
405 
406  bool operator== (const TimelineRange& other) const {
407  return id == other.id && Temporal::TimeRange::operator== (other);
408  }
409 
410  bool equal (const TimelineRange& other) const {
411  return Temporal::TimeRange::operator== (other);
412  }
413 };
414 
415 class CueMarker {
416  public:
417  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
418 
419  std::string text() const { return _text; }
420  void set_text (std::string const & str) { _text = str; }
421 
422  timepos_t position() const { return _position; }
423  void set_position (timepos_t const & pos) { _position = pos; }
424 
425  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
426  bool operator< (CueMarker const & other) const { return _position < other.position(); }
427 
428  private:
429  std::string _text;
431 };
432 
433 typedef std::set<CueMarker> CueMarkers;
434 
435 /*
436  Slowest = 6.6dB/sec falloff at update rate of 40ms
437  Slow = 6.8dB/sec falloff at update rate of 40ms
438 */
439 
450 };
451 
452 enum MeterHold {
456  MeterHoldLong = 200
457 };
458 
459 enum EditMode {
462  Lock
463 };
464 
469 };
470 
475 };
476 
478  None = 0,
479  NewlyCreatedLeft = 1, // bit 0
480  NewlyCreatedRight = 2, // bit 1
482  Existing = 4, // bit 2
486 };
487 
489  ClearSel = 0,
490  PreserveSel = 1, // bit 0
491  ForceSel = 2 // bit 1
492 };
493 
499 };
500 
504  SyncPoint
505 };
506 
507 enum Placement {
509  PostFader
510 };
511 
516 };
517 
521  MonitorDisk = 0x2,
522  MonitorCue = 0x3,
523 };
524 
527  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
528  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
529 };
530 
536 };
537 
543 };
544 
550 };
551 
556 };
557 
563 };
564 
570 };
571 
576 };
577 
583 };
584 
587  Manual
588 };
589 
593 };
594 
598  AutoConnectMaster = 0x2
599 };
600 
603  NameAfterDriver = 0x2
604 };
605 
610 };
611 
613 
618  MP4Chaps
619 };
620 
632 };
633 
634 struct PeakData {
635  typedef Sample PeakDatum;
636 
639 };
640 
645 };
646 
648  /* The first two are "synonyms". It is important for JACK to be first
649  both here and in enums.cc, so that the string "JACK" is
650  correctly recognized in older session and preference files.
651  */
652  JACK = 0,
653  Engine = 0,
657 };
658 
666 };
667 
670  TR_Speed = 0x2,
671  TR_Locate = 0x4
672 };
673 
676  Semitones
677 };
678 
679 typedef std::vector<std::shared_ptr<Source> > SourceList;
680 
686  SrcFastest
687 };
688 
689 typedef std::list<samplepos_t> AnalysisFeatureList;
690 typedef std::vector<samplepos_t> XrunPositions;
691 
692 typedef std::list<std::shared_ptr<Route> > RouteList;
693 typedef std::list<std::shared_ptr<AudioTrack> > AudioTrackList;
694 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
695 typedef std::list<std::shared_ptr<Stripable> > StripableList;
696 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
697 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
698 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
699 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
700 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
701 typedef std::set <AutomationType> AutomationTypeSet;
702 
703 typedef std::list<std::shared_ptr<VCA> > VCAList;
704 
705 class Bundle;
706 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
707 
708 class IOPlug;
709 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
710 
715  LayerTime
716 };
717 
721 };
722 
725  Rectified
726 };
727 
732 };
733 
735  CleanupReport () : space (0) {}
736  std::vector<std::string> paths;
737  size_t space;
738 };
739 
744 };
745 
750 };
751 
761  enum Type {
769  PortNameChange = 0x40
770  };
771 
773  {}
774 
776  {}
777 
779  {}
780 
785 };
786 
787 struct BusProfile {
789  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
790 };
791 
792 enum FadeShape {
798 };
799 
801  /* these values happen to match the constants used by JACK but
802  this equality cannot be assumed.
803  */
808 };
809 
810 enum PortFlags {
811  /* these values happen to match the constants used by JACK but
812  this equality cannot be assumed.
813  */
814  IsInput = 0x1,
815  IsOutput = 0x2,
816  IsPhysical = 0x4,
817  CanMonitor = 0x8,
818  IsTerminal = 0x10,
819 
820  /* non-JACK related flags */
821  Hidden = 0x20,
822  Shadow = 0x40,
823 
824  TransportMasterPort = 0x80, // incoming data, used by slaves
825  TransportGenerator = 0x100, // outgoing, timecode/clock generators
826  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
827 };
828 
833  MidiPortVirtual = 0x8
834 };
835 
836 struct LatencyRange {
837  LatencyRange () : min (0), max (0) {}
838  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
839 
840  uint32_t min; //< samples
841  uint32_t max; //< samples
842 
843  bool operator==(const LatencyRange& other) const {
844  return (min == other.min && max == other.max);
845  }
846 
848  min = other.min;
849  max = other.max;
850  return *this;
851  }
852 };
853 
859 };
860 
862  LastLocate = 0x1,
864  Loop = 0x4,
866 };
867 
872 };
873 
879 };
880 
884 };
885 
886 struct CaptureInfo {
891 };
892 
897 };
898 
904 };
905 
907  PlaylistChanged = 0x1, // actual playlist was swapped/reset
908  PlaylistModified = 0x2, // contents of playlist changed
910  LoopChanged = 0x8,
911 };
912 
917 };
918 
920  FollowCues = 0x1,
922 };
923 
924 typedef std::vector<CaptureInfo*> CaptureInfos;
925 
926 struct FollowAction {
927  enum Type {
931  ForwardTrigger, /* any "next" skipping empties */
932  ReverseTrigger, /* any "prev" skipping empties */
936  };
937 
938  /* We could theoretically limit this to default_triggers_per_box but
939  * doing it this way makes it likely that this will not change. Could
940  * be worth a constexpr-style compile time assert to check
941  * default_triggers_per_box < 64
942  */
943 
944  typedef std::bitset<64> Targets;
945 
948 
950  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
951  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
952  FollowAction (std::string const &);
953 
954  static Targets target_any () { Targets t; t.set(); return t; }
955  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
956  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; }
957  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
958  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
959  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
960 
961  bool operator!= (FollowAction const & other) const {
962  return other.type != type || other.targets != targets;
963  }
964 
965  bool operator== (FollowAction const & other) const {
966  return other.type == type && other.targets == targets;
967  }
968 
969  bool is_arrangement() {
970  return (
971  (type==ForwardTrigger) ||
972  (type==ReverseTrigger) ||
973  (type==JumpTrigger) );
974  }
975 
976  std::string to_string() const;
977 };
978 
979 struct CueEvent {
980  int32_t cue;
982 
983  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
984 };
985 
986 typedef std::vector<CueEvent> CueEvents;
987 
988 /* Describes the one or two contiguous time ranges processsed by a process
989  * callback. The @param cnt member indicates if there are 1 or 2 valid
990  * elements; It will only be 2 if a locate-for-loop-end occured during the
991  * process cycle.
992  *
993  * Owned by Session. Readable ONLY within process context AFTER
994  * Session::process() has returned.
995  */
996 
1000  uint32_t cnt;
1001 
1002  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
1003 };
1004 
1010  SelectionExtend /* UI only operation, not core */
1011 };
1012 
1015  Enabled = 1,
1016  Recording = 2
1017 };
1018 
1019 
1020 /* compare to IEditController */
1026 };
1027 
1028 } // namespace ARDOUR
1029 
1030 /* for now, break the rules and use "using" to make this "global" */
1031 
1032 using ARDOUR::samplepos_t;
1033 
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
std::list< std::shared_ptr< AudioTrack > > AudioTrackList
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