Ardour  9.8-201-g363d29fd54
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 
51 #ifndef _WINSOCKAPI_
52 #define _WINSOCKAPI_
53 #endif
54 #endif
55 
56 #include "temporal/bbt_time.h"
57 #include "temporal/range.h"
58 #include "temporal/superclock.h"
59 #include "temporal/time.h"
60 #include "temporal/timeline.h"
61 #include "temporal/types.h"
62 
63 #include "pbd/id.h"
64 #include "pbd/microseconds.h"
65 
66 #include "ardour/chan_count.h"
67 #include "ardour/plugin_types.h"
68 
69 #include <map>
70 
73 
74 #if defined (__GNUC__) && (__GNUC__ < 3)
75 typedef int intptr_t;
76 #endif
77 
78 namespace ARDOUR {
79 
80 class Source;
81 class AudioSource;
82 class AudioTrack;
83 class GraphNode;
84 class Route;
85 class RouteGroup;
86 class Region;
87 class Playlist;
88 class Stripable;
89 class Trigger;
90 class VCA;
91 class AutomationControl;
92 class SlavableAutomationControl;
93 
94 typedef float Sample;
95 typedef float pan_t;
96 typedef float gain_t;
97 typedef uint32_t layer_t;
98 typedef uint32_t pframes_t;
99 
100 /* rebind Temporal position types into ARDOUR namespace */
104 
108 
109 static const layer_t max_layer = UINT32_MAX;
110 
111 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
112 typedef std::list<std::pair<sampleoffset_t, sampleoffset_t> > AudioIntervalResult;
113 // associate a set of intervals with regions (e.g. for silence detection)
114 typedef std::map<std::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
115 
116 typedef std::list<std::shared_ptr<Region> > RegionList;
117 typedef std::set<std::shared_ptr<Playlist> > PlaylistSet;
118 typedef std::list<std::shared_ptr<RouteGroup>> RouteGroupList;
119 
120 
121 struct IOChange {
122 
123  enum Type {
124  NoChange = 0,
126  ConnectionsChanged = 0x2
127  } type;
128 
130  IOChange (Type t) : type (t) {}
131 
136 };
137 
138 /* policies for inserting/pasting material where overlaps
139  might be an issue.
140 */
141 
149 };
150 
203 
204  /* used only by Controllable Descriptor to access send parameters */
205 
209 };
210 
211 enum AutoState {
212  Off = 0x00,
213  Write = 0x01,
214  Touch = 0x02,
215  Play = 0x04,
216  Latch = 0x08
217 };
218 
221 
225 };
226 
230  Automatic
231 };
232 
239 };
240 
242  DiskIOPreFader, /* after the trim control, but before other processors */
243  DiskIOPostFader, /* before the main outs, after other processors */
244  DiskIOCustom, /* up to the user. Caveat Emptor! */
245 };
246 
247 enum MeterType {
248  MeterMaxSignal = 0x0001,
249  MeterMaxPeak = 0x0002,
250  MeterPeak = 0x0004,
251  MeterKrms = 0x0008,
252  MeterK20 = 0x0010,
253  MeterK14 = 0x0020,
254  MeterIEC1DIN = 0x0040,
255  MeterIEC1NOR = 0x0080,
256  MeterIEC2BBC = 0x0100,
257  MeterIEC2EBU = 0x0200,
258  MeterVU = 0x0400,
259  MeterK12 = 0x0800,
260  MeterPeak0dB = 0x1000,
261  MeterMCP = 0x2000
262 };
263 
264 enum TrackMode {
267  /* No longer in use but kept to allow loading of older sessions */
269 };
270 
275 };
276 
282 };
283 
284 enum NoteMode {
286  Percussive
287 };
288 
292  ForceChannel
293 };
294 
295 enum ColorMode {
300 };
301 
302 enum SnapPref {
303  SnapToAny_Visual = 0,
307  SnapToGrid_Scaled = 1,
311  SnapToGrid_Unscaled = 2,
315 };
316 
317 class AnyTime {
318  public:
319  enum Type {
324  Seconds
325  };
326 
328 
330  union {
333  };
334 
335  union {
337  double seconds;
338  };
339 
340  AnyTime () : type (Samples), samples (0) {}
342  AnyTime (std::string const &);
343 
344  std::string str() const;
345 
346  bool operator== (AnyTime const & other) const {
347  if (type != other.type) { return false; }
348 
349  switch (type) {
350  case Timecode:
351  return timecode == other.timecode;
352  case BBT:
353  return bbt == other.bbt;
354  case BBT_Offset:
355  return bbt_offset == other.bbt_offset;
356  case Samples:
357  return samples == other.samples;
358  case Seconds:
359  return seconds == other.seconds;
360  }
361  return false; // get rid of warning
362  }
363 
364  bool not_zero() const
365  {
366  switch (type) {
367  case Timecode:
368  return timecode.hours != 0 || timecode.minutes != 0 ||
369  timecode.seconds != 0 || timecode.frames != 0;
370  case BBT:
371  return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
372  case BBT_Offset:
373  return bbt_offset.bars != 0 || bbt_offset.beats != 0 || bbt_offset.ticks != 0;
374  case Samples:
375  return samples != 0;
376  case Seconds:
377  return seconds != 0;
378  }
379 
380  abort(); /* NOTREACHED */
381  return false;
382  }
383 };
384 
385 /* used for translating audio samples to an exact musical position using a note divisor.
386  an exact musical position almost never falls exactly on an audio sample, but for sub-sample
387  musical accuracy we need to derive exact musical locations from a sample position
388  the division follows TempoMap::exact_beat_at_sample().
389  division
390  -1 musical location is the bar closest to sample
391  0 musical location is the musical position of the sample
392  1 musical location is the BBT beat closest to sample
393  n musical location is the quarter-note division n closest to sample
394 */
395 struct MusicSample {
397  int32_t division;
398 
399  MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
400 
401  void set (samplepos_t f, int32_t d) {sample = f; division = d; }
402 
403  MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
404 };
405 
406 /* Just a Temporal::Range with an ID for identity
407  */
409 {
410  uint32_t id;
411 
412  TimelineRange (Temporal::timepos_t const & s, Temporal::timepos_t e, uint32_t i) : Temporal::TimeRange (s, e), id (i) {}
413 
414  samplecnt_t length_samples() const { return length().samples(); }
415 
416  bool operator== (const TimelineRange& other) const {
417  return id == other.id && Temporal::TimeRange::operator== (other);
418  }
419 
420  bool equal (const TimelineRange& other) const {
421  return Temporal::TimeRange::operator== (other);
422  }
423 };
424 
425 class CueMarker {
426  public:
427  CueMarker (std::string const& text, timepos_t const & position) : _text (text), _position (position) {}
428 
429  std::string text() const { return _text; }
430  void set_text (std::string const & str) { _text = str; }
431 
432  timepos_t position() const { return _position; }
433  void set_position (timepos_t const & pos) { _position = pos; }
434 
435  bool operator== (CueMarker const & other) const { return _position == other.position() && _text == other.text(); }
436  bool operator< (CueMarker const & other) const { return _position < other.position(); }
437 
438  private:
439  std::string _text;
441 };
442 
443 typedef std::set<CueMarker> CueMarkers;
444 
445 /*
446  Slowest = 6.6dB/sec falloff at update rate of 40ms
447  Slow = 6.8dB/sec falloff at update rate of 40ms
448 */
449 
460 };
461 
462 enum MeterHold {
466  MeterHoldLong = 200
467 };
468 
469 enum EditMode {
472  Lock
473 };
474 
479 };
480 
485 };
486 
488  None = 0,
489  NewlyCreatedLeft = 1, // bit 0
490  NewlyCreatedRight = 2, // bit 1
492  Existing = 4, // bit 2
496 };
497 
499  ClearSel = 0,
500  PreserveSel = 1, // bit 0
501  ForceSel = 2 // bit 1
502 };
503 
509 };
510 
514  SyncPoint
515 };
516 
517 enum Placement {
519  PostFader
520 };
521 
526 };
527 
531  MonitorDisk = 0x2,
532  MonitorCue = 0x3,
533 };
534 
537  FastWindVarispeed = 0x1, //rewind/ffwd commands will varispeed the transport (incl reverse playback)
538  FastWindLocate = 0x2, //rewind/ffwd commands will jump to next/prior marker
539 };
540 
546 };
547 
553 };
554 
560 };
561 
566 };
567 
573 };
574 
580 };
581 
586 };
587 
593 };
594 
597  Manual
598 };
599 
603 };
604 
608  AutoConnectMaster = 0x2
609 };
610 
613  NameAfterDriver = 0x2
614 };
615 
620 };
621 
623 
628  MP4Chaps
629 };
630 
642 };
643 
644 struct PeakData {
645  typedef Sample PeakDatum;
646 
649 };
650 
655 };
656 
658  /* The first two are "synonyms". It is important for JACK to be first
659  both here and in enums.cc, so that the string "JACK" is
660  correctly recognized in older session and preference files.
661  */
662  JACK = 0,
663  Engine = 0,
668 };
669 
678 };
679 
682  TR_Speed = 0x2,
683  TR_Locate = 0x4
684 };
685 
688  Semitones
689 };
690 
691 typedef std::vector<std::shared_ptr<Source> > SourceList;
692 
698  SrcFastest
699 };
700 
701 typedef std::list<samplepos_t> AnalysisFeatureList;
702 typedef std::vector<samplepos_t> XrunPositions;
703 
704 typedef std::list<std::shared_ptr<Route> > RouteList;
705 typedef std::list<std::shared_ptr<AudioTrack> > AudioTrackList;
706 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
707 typedef std::list<std::shared_ptr<Stripable> > StripableList;
708 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
709 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
710 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
711 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
712 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
713 typedef std::set <AutomationType> AutomationTypeSet;
714 
715 typedef std::list<std::shared_ptr<VCA> > VCAList;
716 
717 class Bundle;
718 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
719 
720 class IOPlug;
721 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
722 
727  LayerTime
728 };
729 
733 };
734 
737  Rectified
738 };
739 
744 };
745 
747  CleanupReport () : space (0) {}
748  std::vector<std::string> paths;
749  size_t space;
750 };
751 
756 };
757 
762 };
763 
773  enum Type {
781  PortNameChange = 0x40
782  };
783 
785  {}
786 
788  {}
789 
791  {}
792 
797 };
798 
799 struct BusProfile {
801  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
802 };
803 
804 enum FadeShape {
810 };
811 
813  /* these values happen to match the constants used by JACK but
814  this equality cannot be assumed.
815  */
820 };
821 
822 enum PortFlags {
823  /* these values happen to match the constants used by JACK but
824  this equality cannot be assumed.
825  */
826  IsInput = 0x1,
827  IsOutput = 0x2,
828  IsPhysical = 0x4,
829  CanMonitor = 0x8,
830  IsTerminal = 0x10,
831 
832  /* non-JACK related flags */
833  Hidden = 0x20,
834  Shadow = 0x40,
835 
836  TransportMasterPort = 0x80, // incoming data, used by slaves
837  TransportGenerator = 0x100, // outgoing, timecode/clock generators
838  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
839 };
840 
845  MidiPortVirtual = 0x8
846 };
847 
848 struct LatencyRange {
849  LatencyRange () : min (0), max (0) {}
850  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
851 
852  uint32_t min; //< samples
853  uint32_t max; //< samples
854 
855  bool operator==(const LatencyRange& other) const {
856  return (min == other.min && max == other.max);
857  }
858 
860  min = other.min;
861  max = other.max;
862  return *this;
863  }
864 };
865 
871 };
872 
874  LastLocate = 0x1,
876  Loop = 0x4,
878 };
879 
884 };
885 
891 };
892 
896 };
897 
898 struct CaptureInfo {
903 };
904 
909 };
910 
916 };
917 
919  PlaylistChanged = 0x1, // actual playlist was swapped/reset
920  PlaylistModified = 0x2, // contents of playlist changed
922  LoopChanged = 0x8,
923 };
924 
929 };
930 
931 
933  NoDraw = 0x1, /* do not show visually as candidate for new notes */
934  NoInsert = 0x2,
935  NoPlay = 0x4,
936  ForceLower = 0x8,
937  ForceHigher = 0x10,
938  ForceNearest = 0x20,
939  ShowKey = 0x40
940 };
941 
943  FollowCues = 0x1,
945 };
946 
947 typedef std::vector<CaptureInfo*> CaptureInfos;
948 
949 struct FollowAction {
950  enum Type {
954  ForwardTrigger, /* any "next" skipping empties */
955  ReverseTrigger, /* any "prev" skipping empties */
959  };
960 
961  /* We could theoretically limit this to default_triggers_per_box but
962  * doing it this way makes it likely that this will not change. Could
963  * be worth a constexpr-style compile time assert to check
964  * default_triggers_per_box < 64
965  */
966 
967  typedef std::bitset<64> Targets;
968 
971 
973  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
974  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
975  FollowAction (std::string const &);
976 
977  static Targets target_any () { Targets t; t.set(); return t; }
978  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
979  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; }
980  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
981  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
982  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
983 
984  bool operator!= (FollowAction const & other) const {
985  return other.type != type || other.targets != targets;
986  }
987 
988  bool operator== (FollowAction const & other) const {
989  return other.type == type && other.targets == targets;
990  }
991 
992  bool is_arrangement() {
993  return (
994  (type==ForwardTrigger) ||
995  (type==ReverseTrigger) ||
996  (type==JumpTrigger) );
997  }
998 
999  std::string to_string() const;
1000 };
1001 
1002 struct CueEvent {
1003  int32_t cue;
1005 
1006  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
1007 };
1008 
1009 typedef std::vector<CueEvent> CueEvents;
1010 
1011 /* Describes the one or two contiguous time ranges processsed by a process
1012  * callback. The @param cnt member indicates if there are 1 or 2 valid
1013  * elements; It will only be 2 if a locate-for-loop-end occured during the
1014  * process cycle.
1015  *
1016  * Owned by Session. Readable ONLY within process context AFTER
1017  * Session::process() has returned.
1018  */
1019 
1023  uint32_t cnt;
1024 
1025  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
1026 };
1027 
1033  SelectionExtend /* UI only operation, not core */
1034 };
1035 
1038  Enabled = 1,
1039  Recording = 2
1040 };
1041 
1042 
1043 /* compare to IEditController */
1049 };
1050 
1057 };
1058 
1061 };
1062 
1063 
1064 } // namespace ARDOUR
1065 
1066 /* for now, break the rules and use "using" to make this "global" */
1067 
1068 using ARDOUR::samplepos_t;
1069 
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