Ardour  9.2-646-g3365b984da
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,
667 };
668 
676 };
677 
680  TR_Speed = 0x2,
681  TR_Locate = 0x4
682 };
683 
686  Semitones
687 };
688 
689 typedef std::vector<std::shared_ptr<Source> > SourceList;
690 
696  SrcFastest
697 };
698 
699 typedef std::list<samplepos_t> AnalysisFeatureList;
700 typedef std::vector<samplepos_t> XrunPositions;
701 
702 typedef std::list<std::shared_ptr<Route> > RouteList;
703 typedef std::list<std::shared_ptr<AudioTrack> > AudioTrackList;
704 typedef std::list<std::shared_ptr<GraphNode> > GraphNodeList;
705 typedef std::list<std::shared_ptr<Stripable> > StripableList;
706 typedef std::list<std::weak_ptr <Route> > WeakRouteList;
707 typedef std::list<std::weak_ptr <Stripable> > WeakStripableList;
708 typedef std::list<std::shared_ptr<AutomationControl> > AutomationControlList;
709 typedef std::list<std::weak_ptr <AutomationControl> > WeakAutomationControlList;
710 typedef std::list<std::shared_ptr<SlavableAutomationControl> > SlavableAutomationControlList;
711 typedef std::set <AutomationType> AutomationTypeSet;
712 
713 typedef std::list<std::shared_ptr<VCA> > VCAList;
714 
715 class Bundle;
716 typedef std::vector<std::shared_ptr<Bundle> > BundleList;
717 
718 class IOPlug;
719 typedef std::vector<std::shared_ptr<IOPlug> > IOPlugList;
720 
725  LayerTime
726 };
727 
731 };
732 
735  Rectified
736 };
737 
742 };
743 
745  CleanupReport () : space (0) {}
746  std::vector<std::string> paths;
747  size_t space;
748 };
749 
754 };
755 
760 };
761 
771  enum Type {
779  PortNameChange = 0x40
780  };
781 
783  {}
784 
786  {}
787 
789  {}
790 
795 };
796 
797 struct BusProfile {
799  uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
800 };
801 
802 enum FadeShape {
808 };
809 
811  /* these values happen to match the constants used by JACK but
812  this equality cannot be assumed.
813  */
818 };
819 
820 enum PortFlags {
821  /* these values happen to match the constants used by JACK but
822  this equality cannot be assumed.
823  */
824  IsInput = 0x1,
825  IsOutput = 0x2,
826  IsPhysical = 0x4,
827  CanMonitor = 0x8,
828  IsTerminal = 0x10,
829 
830  /* non-JACK related flags */
831  Hidden = 0x20,
832  Shadow = 0x40,
833 
834  TransportMasterPort = 0x80, // incoming data, used by slaves
835  TransportGenerator = 0x100, // outgoing, timecode/clock generators
836  TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator
837 };
838 
843  MidiPortVirtual = 0x8
844 };
845 
846 struct LatencyRange {
847  LatencyRange () : min (0), max (0) {}
848  LatencyRange (const LatencyRange& other) : min (other.min), max (other.max) {}
849 
850  uint32_t min; //< samples
851  uint32_t max; //< samples
852 
853  bool operator==(const LatencyRange& other) const {
854  return (min == other.min && max == other.max);
855  }
856 
858  min = other.min;
859  max = other.max;
860  return *this;
861  }
862 };
863 
869 };
870 
872  LastLocate = 0x1,
874  Loop = 0x4,
876 };
877 
882 };
883 
889 };
890 
894 };
895 
896 struct CaptureInfo {
901 };
902 
907 };
908 
914 };
915 
917  PlaylistChanged = 0x1, // actual playlist was swapped/reset
918  PlaylistModified = 0x2, // contents of playlist changed
920  LoopChanged = 0x8,
921 };
922 
927 };
928 
930  FollowCues = 0x1,
932 };
933 
934 typedef std::vector<CaptureInfo*> CaptureInfos;
935 
936 struct FollowAction {
937  enum Type {
941  ForwardTrigger, /* any "next" skipping empties */
942  ReverseTrigger, /* any "prev" skipping empties */
946  };
947 
948  /* We could theoretically limit this to default_triggers_per_box but
949  * doing it this way makes it likely that this will not change. Could
950  * be worth a constexpr-style compile time assert to check
951  * default_triggers_per_box < 64
952  */
953 
954  typedef std::bitset<64> Targets;
955 
958 
960  FollowAction (Type t, Targets const & tgts = Targets()) : type (t), targets (tgts) {}
961  FollowAction (Type t, std::string const & bitstring) : type (t), targets (bitstring) {}
962  FollowAction (std::string const &);
963 
964  static Targets target_any () { Targets t; t.set(); return t; }
965  static Targets target_other (uint8_t skip) { Targets t; t.set (); t.reset (skip); return t; }
966  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; }
967  static Targets target_prev_wrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } else { t.set (t.size() - 1); } return t; }
968  static Targets target_next_nowrap (uint8_t from) { Targets t; if (from < t.size() - 1) { t.set (from + 1); } return t; }
969  static Targets target_prev_nowrap (uint8_t from) { Targets t; if (from) { t.set (from - 1); } return t; }
970 
971  bool operator!= (FollowAction const & other) const {
972  return other.type != type || other.targets != targets;
973  }
974 
975  bool operator== (FollowAction const & other) const {
976  return other.type == type && other.targets == targets;
977  }
978 
979  bool is_arrangement() {
980  return (
981  (type==ForwardTrigger) ||
982  (type==ReverseTrigger) ||
983  (type==JumpTrigger) );
984  }
985 
986  std::string to_string() const;
987 };
988 
989 struct CueEvent {
990  int32_t cue;
992 
993  CueEvent (int32_t c, samplepos_t t) : cue (c), time (t) {}
994 };
995 
996 typedef std::vector<CueEvent> CueEvents;
997 
998 /* Describes the one or two contiguous time ranges processsed by a process
999  * callback. The @param cnt member indicates if there are 1 or 2 valid
1000  * elements; It will only be 2 if a locate-for-loop-end occured during the
1001  * process cycle.
1002  *
1003  * Owned by Session. Readable ONLY within process context AFTER
1004  * Session::process() has returned.
1005  */
1006 
1010  uint32_t cnt;
1011 
1012  ProcessedRanges() : start { 0, 0 }, end { 0, 0 }, cnt (0) {}
1013 };
1014 
1020  SelectionExtend /* UI only operation, not core */
1021 };
1022 
1025  Enabled = 1,
1026  Recording = 2
1027 };
1028 
1029 
1030 /* compare to IEditController */
1036 };
1037 
1038 } // namespace ARDOUR
1039 
1040 /* for now, break the rules and use "using" to make this "global" */
1041 
1042 using ARDOUR::samplepos_t;
1043 
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