2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_types_h__
21 #define __ardour_types_h__
26 #include <boost/shared_ptr.hpp>
27 #include <sys/types.h>
33 #include "timecode/bbt_time.h"
34 #include "timecode/time.h"
38 #include "evoral/Range.hpp"
40 #include "ardour/chan_count.h"
41 #include "ardour/plugin_types.h"
59 typedef uint32_t layer_t;
60 typedef uint64_t microseconds_t;
61 typedef uint32_t pframes_t;
63 /* Any position measured in audio frames.
64 Assumed to be non-negative but not enforced.
66 typedef int64_t framepos_t;
68 /* Any distance from a given framepos_t.
69 Maybe positive or negative.
71 typedef int64_t frameoffset_t;
73 /* Any count of audio frames.
74 Assumed to be positive but not enforced.
76 typedef int64_t framecnt_t;
78 static const framepos_t max_framepos = INT64_MAX;
79 static const framecnt_t max_framecnt = INT64_MAX;
80 static const layer_t max_layer = UINT32_MAX;
82 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
83 typedef std::list<std::pair<frameoffset_t, frameoffset_t> > AudioIntervalResult;
84 // associate a set of intervals with regions (e.g. for silence detection)
85 typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
87 typedef std::list<boost::shared_ptr<Region> > RegionList;
93 ConfigurationChanged = 0x1,
94 ConnectionsChanged = 0x2
97 IOChange () : type (NoChange) {}
98 IOChange (Type t) : type (t) {}
100 /** channel count of IO before a ConfigurationChanged, if appropriate */
101 ARDOUR::ChanCount before;
102 /** channel count of IO after a ConfigurationChanged, if appropriate */
103 ARDOUR::ChanCount after;
106 /* policies for inserting/pasting material where overlaps
110 enum InsertMergePolicy {
111 InsertMergeReject, // no overlaps allowed
112 InsertMergeRelax, // we just don't care about overlaps
113 InsertMergeReplace, // replace old with new
114 InsertMergeTruncateExisting, // shorten existing to avoid overlap
115 InsertMergeTruncateAddition, // shorten new to avoid overlap
116 InsertMergeExtend // extend new (or old) to the range of old+new
119 /** See evoral/Parameter.hpp
121 enum AutomationType {
124 PanAzimuthAutomation,
125 PanElevationAutomation,
127 PanFrontBackAutomation,
130 PluginPropertyAutomation,
134 MidiPgmChangeAutomation,
135 MidiPitchBenderAutomation,
136 MidiChannelPressureAutomation,
137 MidiSystemExclusiveAutomation,
152 std::string auto_state_to_string (AutoState);
153 AutoState string_to_auto_state (std::string);
160 std::string auto_style_to_string (AutoStyle);
161 AutoStyle string_to_auto_style (std::string);
183 MeterMaxSignal = 0x0001,
184 MeterMaxPeak = 0x0002,
189 MeterIEC1DIN = 0x0040,
190 MeterIEC1NOR = 0x0080,
191 MeterIEC2BBC = 0x0100,
192 MeterIEC2EBU = 0x0200,
195 MeterPeak0dB = 0x1000,
211 AllChannels = 0, ///< Pass through all channel information unmodified
212 FilterChannels, ///< Ignore events on certain channels
213 ForceChannel ///< Force all events to a certain channel
223 RoundDownMaybe = -2, ///< Round down only if necessary
224 RoundDownAlways = -1, ///< Always round down, even if on a division
225 RoundNearest = 0, ///< Round to nearest
226 RoundUpAlways = 1, ///< Always round up, even if on a division
227 RoundUpMaybe = 2 ///< Round up only if necessary
241 Timecode::Time timecode;
242 Timecode::BBT_Time bbt;
249 AnyTime() { type = Frames; frames = 0; }
251 bool operator== (AnyTime const & other) const {
252 if (type != other.type) { return false; }
256 return timecode == other.timecode;
258 return bbt == other.bbt;
260 return frames == other.frames;
262 return seconds == other.seconds;
264 return false; // get rid of warning
267 bool not_zero() const
271 return timecode.hours != 0 || timecode.minutes != 0 ||
272 timecode.seconds != 0 || timecode.frames != 0;
274 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
281 abort(); /* NOTREACHED */
286 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
287 but this has a uint32_t id which Evoral::Range<> does not.
294 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
296 framecnt_t length() { return end - start + 1; }
298 bool operator== (const AudioRange& other) const {
299 return start == other.start && end == other.end && id == other.id;
302 bool equal (const AudioRange& other) const {
303 return start == other.start && end == other.end;
306 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
307 return Evoral::coverage (start, end, s, e);
312 Timecode::BBT_Time start;
313 Timecode::BBT_Time end;
316 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
317 : start (s), end (e), id (i) {}
319 bool operator== (const MusicRange& other) const {
320 return start == other.start && end == other.end && id == other.id;
323 bool equal (const MusicRange& other) const {
324 return start == other.start && end == other.end;
329 Slowest = 6.6dB/sec falloff at update rate of 40ms
330 Slow = 6.8dB/sec falloff at update rate of 40ms
335 MeterFalloffSlowest = 1,
336 MeterFalloffSlow = 2,
337 MeterFalloffSlowish = 3,
338 MeterFalloffModerate = 4,
339 MeterFalloffMedium = 5,
340 MeterFalloffFast = 6,
341 MeterFalloffFaster = 7,
342 MeterFalloffFastest = 8,
348 MeterHoldMedium = 100,
359 enum RegionSelectionAfterSplit {
361 NewlyCreatedLeft = 1, // bit 0
362 NewlyCreatedRight = 2, // bit 1
363 NewlyCreatedBoth = 3,
364 Existing = 4, // bit 2
365 ExistingNewlyCreatedLeft = 5,
366 ExistingNewlyCreatedRight = 6,
367 ExistingNewlyCreatedBoth = 7
382 HardwareMonitoring, ///< JACK does monitoring
383 SoftwareMonitoring, ///< Ardour does monitoring
384 ExternalMonitoring ///< we leave monitoring to the audio hardware
395 MonitoringSilence = 0x1,
396 MonitoringInput = 0x2,
397 MonitoringDisk = 0x4,
401 MeteringInput, ///< meter the input IO, regardless of what is going through the route
402 MeteringRoute ///< meter what is going through the route
405 enum VUMeterStandard {
406 MeteringVUfrench, // 0VU = -2dBu
407 MeteringVUamerican, // 0VU = 0dBu
408 MeteringVUstandard, // 0VU = +4dBu
409 MeteringVUeight // 0VU = +8dBu
420 /** PFL signals come from before pre-fader processors */
421 PFLFromBeforeProcessors,
422 /** PFL signals come pre-fader but after pre-fader processors */
423 PFLFromAfterProcessors
427 /** AFL signals come post-fader and before post-fader processors */
428 AFLFromBeforeProcessors,
429 /** AFL signals come post-fader but after post-fader processors */
430 AFLFromAfterProcessors
450 enum ListenPosition {
455 enum AutoConnectOption {
457 AutoConnectPhysical = 0x1,
458 AutoConnectMaster = 0x2
461 enum TracksAutoNamingRule {
462 UseDefaultNames = 0x1,
463 NameAfterDriver = 0x2
472 int format_data_width (ARDOUR::SampleFormat);
474 enum CDMarkerFormat {
494 typedef Sample PeakDatum;
507 /* These are "synonyms". It is important for JACK to be first
508 both here and in enums.cc, so that the string "JACK" is
509 correctly recognized in older session and preference files.
518 enum ShuttleBehaviour {
528 typedef std::vector<boost::shared_ptr<Source> > SourceList;
538 typedef std::list<framepos_t> AnalysisFeatureList;
540 typedef std::list<boost::shared_ptr<Route> > RouteList;
541 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
544 typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
556 struct CleanupReport {
557 std::vector<std::string> paths;
561 enum PositionLockStyle {
566 /** A struct used to describe changes to processors in a route.
567 * This is useful because objects that respond to a change in processors
568 * can optimise what work they do based on details of what has changed.
570 struct RouteProcessorChange {
573 MeterPointChange = 0x1,
577 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
580 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
583 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
586 /** type of change; "GeneralChange" means anything could have changed */
588 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
589 bool meter_visibly_changed;
593 AutoConnectOption input_ac; /* override the RC config for input auto-connection */
594 AutoConnectOption output_ac; /* override the RC config for output auto-connection */
595 uint32_t master_out_channels; /* how many channels for the master bus */
596 uint32_t requested_physical_in; /* now many of the available physical inputs to consider usable */
597 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
608 enum TransportState {
609 /* these values happen to match the constants used by JACK but
610 this equality cannot be assumed.
612 TransportStopped = 0,
613 TransportRolling = 1,
614 TransportLooping = 2,
615 TransportStarting = 3,
619 /* these values happen to match the constants used by JACK but
620 this equality cannot be assumed.
629 struct LatencyRange {
630 uint32_t min; //< samples
631 uint32_t max; //< samples
634 enum BufferingPreset {
641 enum AutoReturnTarget {
643 RangeSelectionStart = 0x2,
645 RegionSelectionStart = 0x8,
648 } // namespace ARDOUR
651 /* these cover types declared above in this header. See enums.cc
654 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
655 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
656 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
657 std::istream& operator>>(std::istream& o, ARDOUR::TracksAutoNamingRule& sf);
658 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
659 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
660 std::istream& operator>>(std::istream& o, ARDOUR::PFLPosition& sf);
661 std::istream& operator>>(std::istream& o, ARDOUR::AFLPosition& sf);
662 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
663 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
664 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
665 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
666 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
667 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
668 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
669 std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
670 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
671 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
672 std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf);
673 std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf);
674 std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var);
675 std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf);
676 std::istream& operator>>(std::istream& o, ARDOUR::MeterType& sf);
678 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
679 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
680 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
681 std::ostream& operator<<(std::ostream& o, const ARDOUR::TracksAutoNamingRule& sf);
682 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
683 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
684 std::ostream& operator<<(std::ostream& o, const ARDOUR::PFLPosition& sf);
685 std::ostream& operator<<(std::ostream& o, const ARDOUR::AFLPosition& sf);
686 std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
687 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
688 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
689 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
690 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
691 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
692 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
693 std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
694 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
695 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
696 std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf);
697 std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf);
698 std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var);
699 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf);
700 std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterType& sf);
702 /* because these operators work on types which can be used when making
703 a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported.
705 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
706 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
707 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::VUMeterStandard& sf);
708 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::MeterLineUp& sf);
710 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
711 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
712 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::VUMeterStandard& sf);
713 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterLineUp& sf);
716 static inline ARDOUR::framepos_t
717 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
719 long double result = (long double) session_frame * (long double) speed;
721 if (result >= (long double) ARDOUR::max_framepos) {
722 return ARDOUR::max_framepos;
723 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
724 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
730 static inline ARDOUR::framepos_t
731 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
733 /* NB - do we need a check for speed == 0 ??? */
734 long double result = (long double) track_frame / (long double) speed;
736 if (result >= (long double) ARDOUR::max_framepos) {
737 return ARDOUR::max_framepos;
738 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
739 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
745 /* for now, break the rules and use "using" to make this "global" */
747 using ARDOUR::framepos_t;
750 #endif /* __ardour_types_h__ */