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"
56 class AutomationControl;
61 typedef uint32_t layer_t;
62 typedef uint64_t microseconds_t;
63 typedef uint32_t pframes_t;
65 /* Any position measured in audio frames.
66 Assumed to be non-negative but not enforced.
68 typedef int64_t framepos_t;
70 /* Any distance from a given framepos_t.
71 Maybe positive or negative.
73 typedef int64_t frameoffset_t;
75 /* Any count of audio frames.
76 Assumed to be positive but not enforced.
78 typedef int64_t framecnt_t;
80 static const framepos_t max_framepos = INT64_MAX;
81 static const framecnt_t max_framecnt = INT64_MAX;
82 static const layer_t max_layer = UINT32_MAX;
84 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
85 typedef std::list<std::pair<frameoffset_t, frameoffset_t> > AudioIntervalResult;
86 // associate a set of intervals with regions (e.g. for silence detection)
87 typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
89 typedef std::list<boost::shared_ptr<Region> > RegionList;
95 ConfigurationChanged = 0x1,
96 ConnectionsChanged = 0x2
99 IOChange () : type (NoChange) {}
100 IOChange (Type t) : type (t) {}
102 /** channel count of IO before a ConfigurationChanged, if appropriate */
103 ARDOUR::ChanCount before;
104 /** channel count of IO after a ConfigurationChanged, if appropriate */
105 ARDOUR::ChanCount after;
108 /* policies for inserting/pasting material where overlaps
112 enum InsertMergePolicy {
113 InsertMergeReject, // no overlaps allowed
114 InsertMergeRelax, // we just don't care about overlaps
115 InsertMergeReplace, // replace old with new
116 InsertMergeTruncateExisting, // shorten existing to avoid overlap
117 InsertMergeTruncateAddition, // shorten new to avoid overlap
118 InsertMergeExtend // extend new (or old) to the range of old+new
121 /** See evoral/Parameter.hpp
123 * When you add things here, you REALLY SHOULD add a case clause to
124 * the constructor of ParameterDescriptor, unless the Controllables
125 * that the enum refers to are completely standard (0-1.0 range, 0.0 as
126 * normal, non-toggled, non-enumerated). Anything else needs to be
127 * added there so that things that try to represent them can do so
128 * with as much information as possible.
130 enum AutomationType {
133 PanAzimuthAutomation,
134 PanElevationAutomation,
136 PanFrontBackAutomation,
139 PluginPropertyAutomation,
141 SoloIsolateAutomation,
145 MidiPgmChangeAutomation,
146 MidiPitchBenderAutomation,
147 MidiChannelPressureAutomation,
148 MidiSystemExclusiveAutomation,
156 MonitoringAutomation,
180 std::string auto_state_to_string (AutoState);
181 AutoState string_to_auto_state (std::string);
188 std::string auto_style_to_string (AutoStyle);
189 AutoStyle string_to_auto_style (std::string);
211 MeterMaxSignal = 0x0001,
212 MeterMaxPeak = 0x0002,
217 MeterIEC1DIN = 0x0040,
218 MeterIEC1NOR = 0x0080,
219 MeterIEC2BBC = 0x0100,
220 MeterIEC2EBU = 0x0200,
223 MeterPeak0dB = 0x1000,
239 AllChannels = 0, ///< Pass through all channel information unmodified
240 FilterChannels, ///< Ignore events on certain channels
241 ForceChannel ///< Force all events to a certain channel
251 RoundDownMaybe = -2, ///< Round down only if necessary
252 RoundDownAlways = -1, ///< Always round down, even if on a division
253 RoundNearest = 0, ///< Round to nearest
254 RoundUpAlways = 1, ///< Always round up, even if on a division
255 RoundUpMaybe = 2 ///< Round up only if necessary
269 Timecode::Time timecode;
270 Timecode::BBT_Time bbt;
277 AnyTime() { type = Frames; frames = 0; }
279 bool operator== (AnyTime const & other) const {
280 if (type != other.type) { return false; }
284 return timecode == other.timecode;
286 return bbt == other.bbt;
288 return frames == other.frames;
290 return seconds == other.seconds;
292 return false; // get rid of warning
295 bool not_zero() const
299 return timecode.hours != 0 || timecode.minutes != 0 ||
300 timecode.seconds != 0 || timecode.frames != 0;
302 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
309 abort(); /* NOTREACHED */
314 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
315 but this has a uint32_t id which Evoral::Range<> does not.
322 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
324 framecnt_t length() const { return end - start + 1; }
326 bool operator== (const AudioRange& other) const {
327 return start == other.start && end == other.end && id == other.id;
330 bool equal (const AudioRange& other) const {
331 return start == other.start && end == other.end;
334 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
335 return Evoral::coverage (start, end, s, e);
340 Timecode::BBT_Time start;
341 Timecode::BBT_Time end;
344 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
345 : start (s), end (e), id (i) {}
347 bool operator== (const MusicRange& other) const {
348 return start == other.start && end == other.end && id == other.id;
351 bool equal (const MusicRange& other) const {
352 return start == other.start && end == other.end;
357 Slowest = 6.6dB/sec falloff at update rate of 40ms
358 Slow = 6.8dB/sec falloff at update rate of 40ms
363 MeterFalloffSlowest = 1,
364 MeterFalloffSlow = 2,
365 MeterFalloffSlowish = 3,
366 MeterFalloffModerate = 4,
367 MeterFalloffMedium = 5,
368 MeterFalloffFast = 6,
369 MeterFalloffFaster = 7,
370 MeterFalloffFastest = 8,
376 MeterHoldMedium = 100,
387 enum RegionSelectionAfterSplit {
389 NewlyCreatedLeft = 1, // bit 0
390 NewlyCreatedRight = 2, // bit 1
391 NewlyCreatedBoth = 3,
392 Existing = 4, // bit 2
393 ExistingNewlyCreatedLeft = 5,
394 ExistingNewlyCreatedRight = 6,
395 ExistingNewlyCreatedBoth = 7
410 HardwareMonitoring, ///< JACK does monitoring
411 SoftwareMonitoring, ///< Ardour does monitoring
412 ExternalMonitoring ///< we leave monitoring to the audio hardware
423 MonitoringSilence = 0x1,
424 MonitoringInput = 0x2,
425 MonitoringDisk = 0x4,
429 MeteringInput, ///< meter the input IO, regardless of what is going through the route
430 MeteringRoute ///< meter what is going through the route
433 enum VUMeterStandard {
434 MeteringVUfrench, // 0VU = -2dBu
435 MeteringVUamerican, // 0VU = 0dBu
436 MeteringVUstandard, // 0VU = +4dBu
437 MeteringVUeight // 0VU = +8dBu
448 /** PFL signals come from before pre-fader processors */
449 PFLFromBeforeProcessors,
450 /** PFL signals come pre-fader but after pre-fader processors */
451 PFLFromAfterProcessors
455 /** AFL signals come post-fader and before post-fader processors */
456 AFLFromBeforeProcessors,
457 /** AFL signals come post-fader but after post-fader processors */
458 AFLFromAfterProcessors
478 enum ListenPosition {
483 enum AutoConnectOption {
485 AutoConnectPhysical = 0x1,
486 AutoConnectMaster = 0x2
489 enum TracksAutoNamingRule {
490 UseDefaultNames = 0x1,
491 NameAfterDriver = 0x2
500 int format_data_width (ARDOUR::SampleFormat);
502 enum CDMarkerFormat {
522 typedef Sample PeakDatum;
535 /* These are "synonyms". It is important for JACK to be first
536 both here and in enums.cc, so that the string "JACK" is
537 correctly recognized in older session and preference files.
546 enum ShuttleBehaviour {
556 typedef std::vector<boost::shared_ptr<Source> > SourceList;
566 typedef std::list<framepos_t> AnalysisFeatureList;
568 typedef std::list<boost::shared_ptr<Route> > RouteList;
569 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
570 typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
572 typedef std::list<boost::shared_ptr<VCA> > VCAList;
575 typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
587 struct CleanupReport {
588 std::vector<std::string> paths;
592 enum PositionLockStyle {
597 /** A struct used to describe changes to processors in a route.
598 * This is useful because objects that respond to a change in processors
599 * can optimise what work they do based on details of what has changed.
601 struct RouteProcessorChange {
604 MeterPointChange = 0x1,
608 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
611 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
614 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
617 /** type of change; "GeneralChange" means anything could have changed */
619 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
620 bool meter_visibly_changed;
624 AutoConnectOption input_ac; /* override the RC config for input auto-connection */
625 AutoConnectOption output_ac; /* override the RC config for output auto-connection */
626 uint32_t master_out_channels; /* how many channels for the master bus */
627 uint32_t requested_physical_in; /* now many of the available physical inputs to consider usable */
628 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
639 enum TransportState {
640 /* these values happen to match the constants used by JACK but
641 this equality cannot be assumed.
643 TransportStopped = 0,
644 TransportRolling = 1,
645 TransportLooping = 2,
646 TransportStarting = 3,
650 /* these values happen to match the constants used by JACK but
651 this equality cannot be assumed.
660 struct LatencyRange {
661 uint32_t min; //< samples
662 uint32_t max; //< samples
665 enum BufferingPreset {
672 enum AutoReturnTarget {
674 RangeSelectionStart = 0x2,
676 RegionSelectionStart = 0x8,
679 enum PlaylistDisposition {
685 } // namespace ARDOUR
688 /* these cover types declared above in this header. See enums.cc
691 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
692 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
693 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
694 std::istream& operator>>(std::istream& o, ARDOUR::TracksAutoNamingRule& sf);
695 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
696 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
697 std::istream& operator>>(std::istream& o, ARDOUR::PFLPosition& sf);
698 std::istream& operator>>(std::istream& o, ARDOUR::AFLPosition& sf);
699 std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
700 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
701 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
702 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
703 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
704 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
705 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
706 std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
707 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
708 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
709 std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf);
710 std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf);
711 std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var);
712 std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf);
713 std::istream& operator>>(std::istream& o, ARDOUR::MeterType& sf);
715 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
716 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
717 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
718 std::ostream& operator<<(std::ostream& o, const ARDOUR::TracksAutoNamingRule& sf);
719 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
720 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
721 std::ostream& operator<<(std::ostream& o, const ARDOUR::PFLPosition& sf);
722 std::ostream& operator<<(std::ostream& o, const ARDOUR::AFLPosition& sf);
723 std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
724 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
725 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
726 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
727 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
728 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
729 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
730 std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
731 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
732 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
733 std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf);
734 std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf);
735 std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var);
736 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf);
737 std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterType& sf);
739 /* because these operators work on types which can be used when making
740 a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported.
742 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
743 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
744 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::VUMeterStandard& sf);
745 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::MeterLineUp& sf);
747 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
748 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
749 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::VUMeterStandard& sf);
750 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterLineUp& sf);
753 static inline ARDOUR::framepos_t
754 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
756 long double result = (long double) session_frame * (long double) speed;
758 if (result >= (long double) ARDOUR::max_framepos) {
759 return ARDOUR::max_framepos;
760 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
761 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
767 static inline ARDOUR::framepos_t
768 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
770 /* NB - do we need a check for speed == 0 ??? */
771 long double result = (long double) track_frame / (long double) speed;
773 if (result >= (long double) ARDOUR::max_framepos) {
774 return ARDOUR::max_framepos;
775 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
776 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
782 /* for now, break the rules and use "using" to make this "global" */
784 using ARDOUR::framepos_t;
787 #endif /* __ardour_types_h__ */