Ardour  9.10-18-gf99affa4f5
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 #if defined _MSC_VER
47 #ifndef NOMINMAX
48 #define NOMINMAX
49 #endif
50 #endif
51 
52 #include "temporal/bbt_time.h"
53 #include "temporal/range.h"
54 #include "temporal/superclock.h"
55 #include "temporal/time.h"
56 #include "temporal/timeline.h"
57 #include "temporal/types.h"
58 
59 #include "pbd/id.h"
60 #include "pbd/microseconds.h"
61 
62 #include "ardour/chan_count.h"
63 #include "ardour/plugin_types.h"
64 
65 #include <map>
66 
69 
70 #if defined (__GNUC__) && (__GNUC__ < 3)
71 typedef int intptr_t;
72 #endif
73 
74 namespace ARDOUR {
75 
76 class Source;
77 class AudioSource;
78 class AudioTrack;
79 class GraphNode;
80 class Route;
81 class RouteGroup;
82 class Region;
83 class Playlist;
84 class Stripable;
85 class Trigger;
86 class VCA;
87 class AutomationControl;
88 class SlavableAutomationControl;
89 
90 typedef float Sample;
91 typedef float pan_t;
92 typedef float gain_t;
93 typedef uint32_t layer_t;
94 typedef uint32_t pframes_t;
95 
96 /* rebind Temporal position types into ARDOUR namespace */
100 
104 
105 static const layer_t max_layer = UINT32_MAX;
106 
107 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
108 typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
109 // associate a set of intervals with regions (e.g. for silence detection)
110 typedef std::map<std::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
111 
112 typedef std::list<std::shared_ptr<Region> > RegionList;
113 typedef std::set<std::shared_ptr<Playlist> > PlaylistSet;
114 typedef std::list<std::shared_ptr<RouteGroup>> RouteGroupList;
115 
116 
117 struct IOChange {
118 
119  enum Type {
120  NoChange = 0,
122  ConnectionsChanged = 0x2
123  } type;
124 
126  IOChange (Type t) : type (t) {}
127 
132 };
133 
134 /* policies for inserting/pasting material where overlaps
135  might be an issue.
136 */
137 
145 };
146 
199 
200  /* used only by Controllable Descriptor to access send parameters */
201 
205 };
206 
207 enum AutoState {
208  Off = 0x00,
209  Write = 0x01,
210  Touch = 0x02,
211  Play = 0x04,
212  Latch = 0x08
213 };
214 
217 
221 };
222 
226  Automatic
227 };
228 
235 };
236 
238  DiskIOPreFader, /* after the trim control, but before other processors */
239  DiskIOPostFader, /* before the main outs, after other processors */
240  DiskIOCustom, /* up to the user. Caveat Emptor! */
241 };
242 
243 enum MeterType {
244  MeterMaxSignal = 0x0001,
245  MeterMaxPeak = 0x0002,
246  MeterPeak = 0x0004,
247  MeterKrms = 0x0008,
248  MeterK20 = 0x0010,
249  MeterK14 = 0x0020,
250  MeterIEC1DIN = 0x0040,
251  MeterIEC1NOR = 0x0080,
252  MeterIEC2BBC = 0x0100,
253  MeterIEC2EBU = 0x0200,
254  MeterVU = 0x0400,
255  MeterK12 = 0x0800,
256  MeterPeak0dB = 0x1000,
257  MeterMCP = 0x2000
258 };
259 
260 enum TrackMode {
263  /* No longer in use but kept to allow loading of older sessions */
265 };
266 
271 };
272 
278 };
279 
280 enum NoteMode {
282  Percussive
283 };
284 
288  ForceChannel
289 };
290 
291 enum ColorMode {
296 };
297 
298 enum SnapPref {
299  SnapToAny_Visual = 0,
303  SnapToGrid_Scaled = 1,
307  SnapToGrid_Unscaled = 2,
311 };
312 
313 class AnyTime {
314  public:
315  enum Type {
320  Seconds
321  };
322 
324 
326  union {
329  };
330 
331  union {
333  double seconds;
334  };
335 
336  AnyTime () : type (Samples), samples (0) {}
338  AnyTime (std::string const &);
339 
340  std::string str() const;
341 
342  bool operator== (AnyTime const & other) const {
343  if (type != other.type) { return false; }
344 
345  switch (type) {
346  case Timecode:
347  return timecode == other.timecode;
348  case BBT:
349  return bbt == other.bbt;
350  case BBT_Offset:
351  return bbt_offset == other.bbt_offset;
352  case Samples:
353  return samples == other.samples;
354  case Seconds:
355  return seconds == other.seconds;
356  }
357  return false; // get rid of warning
358  }
359 
360  bool not_zero() const
361  {
362  switch (type) {
363  case Timecode:
364  return timecode.hours != 0 || timecode.minutes != 0 ||
365  timecode.seconds != 0 || timecode.frames != 0;
366  case BBT:
367  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
368  case BBT_Offset:
369  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
370  case Samples:
371  return samples != 0;
372  case Seconds:
373  return seconds != 0;
374  }
375 
376  abort(); /* NOTREACHED */
377  return false;
378  }
379 };
380 
381 /* used for translating audio samples to an exact musical position using a note divisor.
382  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
383  musical accuracy we need to derive exact musical locations from a sample position
384  the division follows TempoMap::exact_beat_at_sample().
385  division
386  -1 musical location is the bar closest to sample
387  0 musical location is the musical position of the sample
388  1 musical location is the BBT beat closest to sample
389  n musical location is the quarter-note division n closest to sample
390 */
391 struct MusicSample {
393  int32_t division;
394 
395  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
396 
397  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
398 
399  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
400 };
401 
402 /* Just a Temporal::Range with an ID for identity
403  */
405 {
406  uint32_t id;
407 
408  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
409 
410  samplecnt_t length_samples() const { return length().samples(); }
411 
412  bool operator== (const TimelineRange& other) const {
413  return id == other.id && Temporal::TimeRange::operator== (other);
414  }
415 
416  bool equal (const TimelineRange& other) const {
417  return Temporal::TimeRange::operator== (other);
418  }
419 };
420 
421 class CueMarker {
422  public:
423  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
424 
425  std::string text() const { return _text; }
426  void set_text (std::string const & str) { _text = str; }
427 
428  timepos_t position() const { return _position; }
429  void set_position (timepos_t const & pos) { _position = pos; }
430 
431  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
432  bool operator< (CueMarker const & other) const { return _position < other.position(); }
433 
434  private:
435  std::string _text;
437 };
438 
439 typedef std::set<CueMarker> CueMarkers;
440 
441 /*
442  Slowest = 6.6dB/sec falloff at update rate of 40ms
443  Slow = 6.8dB/sec falloff at update rate of 40ms
444 */
445 
456 };
457 
458 enum MeterHold {
462  MeterHoldLong = 200
463 };
464 
465 enum EditMode {
468  Lock
469 };
470 
475 };
476 
481 };
482 
484  None = 0,
485  NewlyCreatedLeft = 1, // bit 0
486  NewlyCreatedRight = 2, // bit 1
488  Existing = 4, // bit 2
492 };
493 
495  ClearSel = 0,
496  PreserveSel = 1, // bit 0
497  ForceSel = 2 // bit 1
498 };
499 
505 };
506 
510  SyncPoint
511 };
512 
513 enum Placement {
515  PostFader
516 };
517 
522 };
523 
527  MonitorDisk = 0x2,
528  MonitorCue = 0x3,
529 };
530 
533  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
534  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
535 };
536 
542 };
543 
549 };
550 
556 };
557 
562 };
563 
569 };
570 
576 };
577 
582 };
583 
589 };
590 
593  Manual
594 };
595 
599 };
600 
604  AutoConnectMaster = 0x2
605 };
606 
609  NameAfterDriver = 0x2
610 };
611 
616 };
617 
619 
624  MP4Chaps
625 };
626 
638 };
639 
640 struct PeakData {
641  typedef Sample PeakDatum;
642 
645 };
646 
651 };
652 
654  /* The first two are "synonyms". It is important for JACK to be first
655  both here and in enums.cc, so that the string "JACK" is
656  correctly recognized in older session and preference files.
657  */
658  JACK = 0,
659  Engine = 0,
664 };
665 
674 };
675 
678  TR_Speed = 0x2,
679  TR_Locate = 0x4
680 };
681 
684  Semitones
685 };
686 
687 typedef std::vector<std::shared_ptr<Source> > SourceList;
688 
694  SrcFastest
695 };
696 
697 typedef std::list<samplepos_t> AnalysisFeatureList;
698 typedef std::vector<samplepos_t> XrunPositions;
699 
700 typedef std::list<std::shared_ptr<Route> > RouteList;
701 typedef std::list<std::shared_ptr<AudioTrack> > AudioTrackList;
702 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
703 typedef std::list<std::shared_ptr<Stripable> > StripableList;
704 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
705 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
706 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
707 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
708 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
709 typedef std::set <AutomationType> AutomationTypeSet;
710 
711 typedef std::list<std::shared_ptr<VCA> > VCAList;
712 
713 class Bundle;
714 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
715 
716 class IOPlug;
717 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
718 
723  LayerTime
724 };
725 
729 };
730 
733  Rectified
734 };
735 
740 };
741 
743  CleanupReport () : space (0) {}
744  std::vector<std::string> paths;
745  size_t space;
746 };
747 
752 };
753 
763  enum Type {
771  PortNameChange = 0x40
772  };
773 
775  {}
776 
778  {}
779 
781  {}
782 
787 };
788 
789 struct BusProfile {
791  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
792 };
793 
794 enum FadeShape {
800 };
801 
803  /* these values happen to match the constants used by JACK but
804  this equality cannot be assumed.
805  */
810 };
811 
812 enum PortFlags {
813  /* these values happen to match the constants used by JACK but
814  this equality cannot be assumed.
815  */
816  IsInput = 0x1,
817  IsOutput = 0x2,
818  IsPhysical = 0x4,
819  CanMonitor = 0x8,
820  IsTerminal = 0x10,
821 
822  /* non-JACK related flags */
823  Hidden = 0x20,
824  Shadow = 0x40,
825 
826  TransportMasterPort = 0x80, // incoming data, used by slaves
827  TransportGenerator = 0x100, // outgoing, timecode/clock generators
828  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
829 };
830 
835  MidiPortVirtual = 0x8
836 };
837 
838 struct LatencyRange {
839  LatencyRange () : min (0), max (0) {}
840  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
841 
842  uint32_t min; //< samples
843  uint32_t max; //< samples
844 
845  bool operator==(const LatencyRange& other) const {
846  return (min == other.min && max == other.max);
847  }
848 
850  min = other.min;
851  max = other.max;
852  return *this;
853  }
854 };
855 
861 };
862 
864  LastLocate = 0x1,
866  Loop = 0x4,
868 };
869 
874 };
875 
881 };
882 
886 };
887 
888 struct CaptureInfo {
893 };
894 
899 };
900 
906 };
907 
909  PlaylistChanged = 0x1, // actual playlist was swapped/reset
910  PlaylistModified = 0x2, // contents of playlist changed
912  LoopChanged = 0x8,
913 };
914 
919 };
920 
921 
923  NoDraw = 0x1, /* do not show visually as candidate for new notes */
924  NoInsert = 0x2,
925  NoPlay = 0x4,
926  ForceLower = 0x8,
927  ForceHigher = 0x10,
928  ForceNearest = 0x20,
929  ShowKey = 0x40
930 };
931 
933  FollowCues = 0x1,
935 };
936 
937 typedef std::vector<CaptureInfo*> CaptureInfos;
938 
939 struct FollowAction {
940  enum Type {
944  ForwardTrigger, /* any "next" skipping empties */
945  ReverseTrigger, /* any "prev" skipping empties */
949  };
950 
951  /* We could theoretically limit this to default_triggers_per_box but
952  * doing it this way makes it likely that this will not change. Could
953  * be worth a constexpr-style compile time assert to check
954  * default_triggers_per_box < 64
955  */
956 
957  typedef std::bitset<64> Targets;
958 
961 
963  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
964  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
965  FollowAction (std::string const &);
966 
967  static Targets target_any () { Targets t; t.set(); return t; }
968  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
969  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; }
970  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
971  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
972  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
973 
974  bool operator!= (FollowAction const & other) const {
975  return other.type != type || other.targets != targets;
976  }
977 
978  bool operator== (FollowAction const & other) const {
979  return other.type == type && other.targets == targets;
980  }
981 
982  bool is_arrangement() {
983  return (
984  (type==ForwardTrigger) ||
985  (type==ReverseTrigger) ||
986  (type==JumpTrigger) );
987  }
988 
989  std::string to_string() const;
990 };
991 
992 struct CueEvent {
993  int32_t cue;
995 
996  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
997 };
998 
999 typedef std::vector<CueEvent> CueEvents;
1000 
1001 /* Describes the one or two contiguous time ranges processsed by a process
1002  * callback. The @param cnt member indicates if there are 1 or 2 valid
1003  * elements; It will only be 2 if a locate-for-loop-end occured during the
1004  * process cycle.
1005  *
1006  * Owned by Session. Readable ONLY within process context AFTER
1007  * Session::process() has returned.
1008  */
1009 
1013  uint32_t cnt;
1014 
1015  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
1016 };
1017 
1023  SelectionExtend /* UI only operation, not core */
1024 };
1025 
1028  Enabled = 1,
1029  Recording = 2
1030 };
1031 
1032 
1033 /* compare to IEditController */
1039 };
1040 
1047 };
1048 
1051 };
1052 
1055 };
1056 
1057 } // namespace ARDOUR
1058 
1059 /* for now, break the rules and use "using" to make this "global" */
1060 
1061 using ARDOUR::samplepos_t;
1062 
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