Ardour  9.2-79-gba93f2fe52
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 {
288  TrackColor
289 };
290 
291 enum SnapPref {
292  SnapToAny_Visual = 0,
296  SnapToGrid_Scaled = 1,
300  SnapToGrid_Unscaled = 2,
304 };
305 
306 class AnyTime {
307  public:
308  enum Type {
313  Seconds
314  };
315 
317 
319  union {
322  };
323 
324  union {
326  double seconds;
327  };
328 
329  AnyTime () : type (Samples), samples (0) {}
331  AnyTime (std::string const &);
332 
333  std::string str() const;
334 
335  bool operator== (AnyTime const & other) const {
336  if (type != other.type) { return false; }
337 
338  switch (type) {
339  case Timecode:
340  return timecode == other.timecode;
341  case BBT:
342  return bbt == other.bbt;
343  case BBT_Offset:
344  return bbt_offset == other.bbt_offset;
345  case Samples:
346  return samples == other.samples;
347  case Seconds:
348  return seconds == other.seconds;
349  }
350  return false; // get rid of warning
351  }
352 
353  bool not_zero() const
354  {
355  switch (type) {
356  case Timecode:
357  return timecode.hours != 0 || timecode.minutes != 0 ||
358  timecode.seconds != 0 || timecode.frames != 0;
359  case BBT:
360  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
361  case BBT_Offset:
362  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
363  case Samples:
364  return samples != 0;
365  case Seconds:
366  return seconds != 0;
367  }
368 
369  abort(); /* NOTREACHED */
370  return false;
371  }
372 };
373 
374 /* used for translating audio samples to an exact musical position using a note divisor.
375  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
376  musical accuracy we need to derive exact musical locations from a sample position
377  the division follows TempoMap::exact_beat_at_sample().
378  division
379  -1 musical location is the bar closest to sample
380  0 musical location is the musical position of the sample
381  1 musical location is the BBT beat closest to sample
382  n musical location is the quarter-note division n closest to sample
383 */
384 struct MusicSample {
386  int32_t division;
387 
388  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
389 
390  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
391 
392  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
393 };
394 
395 /* Just a Temporal::Range with an ID for identity
396  */
398 {
399  uint32_t id;
400 
401  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
402 
403  samplecnt_t length_samples() const { return length().samples(); }
404 
405  bool operator== (const TimelineRange& other) const {
406  return id == other.id && Temporal::TimeRange::operator== (other);
407  }
408 
409  bool equal (const TimelineRange& other) const {
410  return Temporal::TimeRange::operator== (other);
411  }
412 };
413 
414 class CueMarker {
415  public:
416  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
417 
418  std::string text() const { return _text; }
419  void set_text (std::string const & str) { _text = str; }
420 
421  timepos_t position() const { return _position; }
422  void set_position (timepos_t const & pos) { _position = pos; }
423 
424  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
425  bool operator< (CueMarker const & other) const { return _position < other.position(); }
426 
427  private:
428  std::string _text;
430 };
431 
432 typedef std::set<CueMarker> CueMarkers;
433 
434 /*
435  Slowest = 6.6dB/sec falloff at update rate of 40ms
436  Slow = 6.8dB/sec falloff at update rate of 40ms
437 */
438 
449 };
450 
451 enum MeterHold {
455  MeterHoldLong = 200
456 };
457 
458 enum EditMode {
461  Lock
462 };
463 
468 };
469 
474 };
475 
477  None = 0,
478  NewlyCreatedLeft = 1, // bit 0
479  NewlyCreatedRight = 2, // bit 1
481  Existing = 4, // bit 2
485 };
486 
488  ClearSel = 0,
489  PreserveSel = 1, // bit 0
490  ForceSel = 2 // bit 1
491 };
492 
498 };
499 
503  SyncPoint
504 };
505 
506 enum Placement {
508  PostFader
509 };
510 
515 };
516 
520  MonitorDisk = 0x2,
521  MonitorCue = 0x3,
522 };
523 
526  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
527  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
528 };
529 
535 };
536 
542 };
543 
549 };
550 
555 };
556 
562 };
563 
569 };
570 
575 };
576 
582 };
583 
586  Manual
587 };
588 
592 };
593 
597  AutoConnectMaster = 0x2
598 };
599 
602  NameAfterDriver = 0x2
603 };
604 
609 };
610 
612 
617  MP4Chaps
618 };
619 
631 };
632 
633 struct PeakData {
634  typedef Sample PeakDatum;
635 
638 };
639 
644 };
645 
647  /* The first two are "synonyms". It is important for JACK to be first
648  both here and in enums.cc, so that the string "JACK" is
649  correctly recognized in older session and preference files.
650  */
651  JACK = 0,
652  Engine = 0,
656 };
657 
665 };
666 
669  TR_Speed = 0x2,
670  TR_Locate = 0x4
671 };
672 
675  Semitones
676 };
677 
678 typedef std::vector<std::shared_ptr<Source> > SourceList;
679 
685  SrcFastest
686 };
687 
688 typedef std::list<samplepos_t> AnalysisFeatureList;
689 typedef std::vector<samplepos_t> XrunPositions;
690 
691 typedef std::list<std::shared_ptr<Route> > RouteList;
692 typedef std::list<std::shared_ptr<AudioTrack> > AudioTrackList;
693 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
694 typedef std::list<std::shared_ptr<Stripable> > StripableList;
695 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
696 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
697 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
698 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
699 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
700 typedef std::set <AutomationType> AutomationTypeSet;
701 
702 typedef std::list<std::shared_ptr<VCA> > VCAList;
703 
704 class Bundle;
705 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
706 
707 class IOPlug;
708 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
709 
714  LayerTime
715 };
716 
720 };
721 
724  Rectified
725 };
726 
731 };
732 
734  CleanupReport () : space (0) {}
735  std::vector<std::string> paths;
736  size_t space;
737 };
738 
743 };
744 
749 };
750 
760  enum Type {
768  PortNameChange = 0x40
769  };
770 
772  {}
773 
775  {}
776 
778  {}
779 
784 };
785 
786 struct BusProfile {
788  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
789 };
790 
791 enum FadeShape {
797 };
798 
800  /* these values happen to match the constants used by JACK but
801  this equality cannot be assumed.
802  */
807 };
808 
809 enum PortFlags {
810  /* these values happen to match the constants used by JACK but
811  this equality cannot be assumed.
812  */
813  IsInput = 0x1,
814  IsOutput = 0x2,
815  IsPhysical = 0x4,
816  CanMonitor = 0x8,
817  IsTerminal = 0x10,
818 
819  /* non-JACK related flags */
820  Hidden = 0x20,
821  Shadow = 0x40,
822 
823  TransportMasterPort = 0x80, // incoming data, used by slaves
824  TransportGenerator = 0x100, // outgoing, timecode/clock generators
825  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
826 };
827 
832  MidiPortVirtual = 0x8
833 };
834 
835 struct LatencyRange {
836  LatencyRange () : min (0), max (0) {}
837  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
838 
839  uint32_t min; //< samples
840  uint32_t max; //< samples
841 
842  bool operator==(const LatencyRange& other) const {
843  return (min == other.min && max == other.max);
844  }
845 
847  min = other.min;
848  max = other.max;
849  return *this;
850  }
851 };
852 
858 };
859 
861  LastLocate = 0x1,
863  Loop = 0x4,
865 };
866 
871 };
872 
878 };
879 
883 };
884 
885 struct CaptureInfo {
890 };
891 
896 };
897 
903 };
904 
906  PlaylistChanged = 0x1, // actual playlist was swapped/reset
907  PlaylistModified = 0x2, // contents of playlist changed
909  LoopChanged = 0x8,
910 };
911 
916 };
917 
919  FollowCues = 0x1,
921 };
922 
923 typedef std::vector<CaptureInfo*> CaptureInfos;
924 
925 struct FollowAction {
926  enum Type {
930  ForwardTrigger, /* any "next" skipping empties */
931  ReverseTrigger, /* any "prev" skipping empties */
935  };
936 
937  /* We could theoretically limit this to default_triggers_per_box but
938  * doing it this way makes it likely that this will not change. Could
939  * be worth a constexpr-style compile time assert to check
940  * default_triggers_per_box < 64
941  */
942 
943  typedef std::bitset<64> Targets;
944 
947 
949  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
950  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
951  FollowAction (std::string const &);
952 
953  static Targets target_any () { Targets t; t.set(); return t; }
954  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
955  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; }
956  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
957  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
958  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
959 
960  bool operator!= (FollowAction const & other) const {
961  return other.type != type || other.targets != targets;
962  }
963 
964  bool operator== (FollowAction const & other) const {
965  return other.type == type && other.targets == targets;
966  }
967 
968  bool is_arrangement() {
969  return (
970  (type==ForwardTrigger) ||
971  (type==ReverseTrigger) ||
972  (type==JumpTrigger) );
973  }
974 
975  std::string to_string() const;
976 };
977 
978 struct CueEvent {
979  int32_t cue;
981 
982  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
983 };
984 
985 typedef std::vector<CueEvent> CueEvents;
986 
987 /* Describes the one or two contiguous time ranges processsed by a process
988  * callback. The @param cnt member indicates if there are 1 or 2 valid
989  * elements; It will only be 2 if a locate-for-loop-end occured during the
990  * process cycle.
991  *
992  * Owned by Session. Readable ONLY within process context AFTER
993  * Session::process() has returned.
994  */
995 
999  uint32_t cnt;
1000 
1001  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
1002 };
1003 
1009  SelectionExtend /* UI only operation, not core */
1010 };
1011 
1014  Enabled = 1,
1015  Recording = 2
1016 };
1017 
1018 
1019 /* compare to IEditController */
1025 };
1026 
1027 } // namespace ARDOUR
1028 
1029 /* for now, break the rules and use "using" to make this "global" */
1030 
1031 using ARDOUR::samplepos_t;
1032 
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