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"
57 class AutomationControl;
62 typedef uint32_t layer_t;
63 typedef uint64_t microseconds_t;
64 typedef uint32_t pframes_t;
66 /* Any position measured in audio frames.
67 Assumed to be non-negative but not enforced.
69 typedef int64_t framepos_t;
71 /* Any distance from a given framepos_t.
72 Maybe positive or negative.
74 typedef int64_t frameoffset_t;
76 /* Any count of audio frames.
77 Assumed to be positive but not enforced.
79 typedef int64_t framecnt_t;
81 static const framepos_t max_framepos = INT64_MAX;
82 static const framecnt_t max_framecnt = INT64_MAX;
83 static const layer_t max_layer = UINT32_MAX;
85 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
86 typedef std::list<std::pair<frameoffset_t, frameoffset_t> > AudioIntervalResult;
87 // associate a set of intervals with regions (e.g. for silence detection)
88 typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
90 typedef std::list<boost::shared_ptr<Region> > RegionList;
96 ConfigurationChanged = 0x1,
97 ConnectionsChanged = 0x2
100 IOChange () : type (NoChange) {}
101 IOChange (Type t) : type (t) {}
103 /** channel count of IO before a ConfigurationChanged, if appropriate */
104 ARDOUR::ChanCount before;
105 /** channel count of IO after a ConfigurationChanged, if appropriate */
106 ARDOUR::ChanCount after;
109 /* policies for inserting/pasting material where overlaps
113 enum InsertMergePolicy {
114 InsertMergeReject, ///< no overlaps allowed
115 InsertMergeRelax, ///< we just don't care about overlaps
116 InsertMergeReplace, ///< replace old with new
117 InsertMergeTruncateExisting, ///< shorten existing to avoid overlap
118 InsertMergeTruncateAddition, ///< shorten new to avoid overlap
119 InsertMergeExtend ///< extend new (or old) to the range of old+new
122 /** See evoral/Parameter.hpp
124 * When you add things here, you REALLY SHOULD add a case clause to
125 * the constructor of ParameterDescriptor, unless the Controllables
126 * that the enum refers to are completely standard (0-1.0 range, 0.0 as
127 * normal, non-toggled, non-enumerated). Anything else needs to be
128 * added there so that things that try to represent them can do so
129 * with as much information as possible.
131 enum AutomationType {
134 PanAzimuthAutomation,
135 PanElevationAutomation,
137 PanFrontBackAutomation,
140 PluginPropertyAutomation,
142 SoloIsolateAutomation,
146 MidiPgmChangeAutomation,
147 MidiPitchBenderAutomation,
148 MidiChannelPressureAutomation,
149 MidiNotePressureAutomation,
150 MidiSystemExclusiveAutomation,
158 MonitoringAutomation,
182 std::string auto_state_to_string (AutoState);
183 AutoState string_to_auto_state (std::string);
190 std::string auto_style_to_string (AutoStyle);
191 AutoStyle string_to_auto_style (std::string);
213 MeterMaxSignal = 0x0001,
214 MeterMaxPeak = 0x0002,
219 MeterIEC1DIN = 0x0040,
220 MeterIEC1NOR = 0x0080,
221 MeterIEC2BBC = 0x0100,
222 MeterIEC2EBU = 0x0200,
225 MeterPeak0dB = 0x1000,
241 AllChannels = 0, ///< Pass through all channel information unmodified
242 FilterChannels, ///< Ignore events on certain channels
243 ForceChannel ///< Force all events to a certain channel
255 SET_LC_MESSAGES_AND_LC_NUMERIC
259 RoundDownMaybe = -2, ///< Round down only if necessary
260 RoundDownAlways = -1, ///< Always round down, even if on a division
261 RoundNearest = 0, ///< Round to nearest
262 RoundUpAlways = 1, ///< Always round up, even if on a division
263 RoundUpMaybe = 2 ///< Round up only if necessary
277 Timecode::Time timecode;
278 Timecode::BBT_Time bbt;
285 AnyTime() { type = Frames; frames = 0; }
287 bool operator== (AnyTime const & other) const {
288 if (type != other.type) { return false; }
292 return timecode == other.timecode;
294 return bbt == other.bbt;
296 return frames == other.frames;
298 return seconds == other.seconds;
300 return false; // get rid of warning
303 bool not_zero() const
307 return timecode.hours != 0 || timecode.minutes != 0 ||
308 timecode.seconds != 0 || timecode.frames != 0;
310 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
317 abort(); /* NOTREACHED */
322 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
323 but this has a uint32_t id which Evoral::Range<> does not.
330 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
332 framecnt_t length() const { return end - start + 1; }
334 bool operator== (const AudioRange& other) const {
335 return start == other.start && end == other.end && id == other.id;
338 bool equal (const AudioRange& other) const {
339 return start == other.start && end == other.end;
342 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
343 return Evoral::coverage (start, end, s, e);
348 Timecode::BBT_Time start;
349 Timecode::BBT_Time end;
352 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
353 : start (s), end (e), id (i) {}
355 bool operator== (const MusicRange& other) const {
356 return start == other.start && end == other.end && id == other.id;
359 bool equal (const MusicRange& other) const {
360 return start == other.start && end == other.end;
365 Slowest = 6.6dB/sec falloff at update rate of 40ms
366 Slow = 6.8dB/sec falloff at update rate of 40ms
371 MeterFalloffSlowest = 1,
372 MeterFalloffSlow = 2,
373 MeterFalloffSlowish = 3,
374 MeterFalloffModerate = 4,
375 MeterFalloffMedium = 5,
376 MeterFalloffFast = 6,
377 MeterFalloffFaster = 7,
378 MeterFalloffFastest = 8,
384 MeterHoldMedium = 100,
395 enum RegionSelectionAfterSplit {
397 NewlyCreatedLeft = 1, // bit 0
398 NewlyCreatedRight = 2, // bit 1
399 NewlyCreatedBoth = 3,
400 Existing = 4, // bit 2
401 ExistingNewlyCreatedLeft = 5,
402 ExistingNewlyCreatedRight = 6,
403 ExistingNewlyCreatedBoth = 7
418 HardwareMonitoring, ///< JACK does monitoring
419 SoftwareMonitoring, ///< Ardour does monitoring
420 ExternalMonitoring ///< we leave monitoring to the audio hardware
431 MonitoringSilence = 0x1,
432 MonitoringInput = 0x2,
433 MonitoringDisk = 0x4,
437 MeteringInput, ///< meter the input IO, regardless of what is going through the route
438 MeteringRoute ///< meter what is going through the route
441 enum VUMeterStandard {
442 MeteringVUfrench, // 0VU = -2dBu
443 MeteringVUamerican, // 0VU = 0dBu
444 MeteringVUstandard, // 0VU = +4dBu
445 MeteringVUeight // 0VU = +8dBu
456 /** PFL signals come from before pre-fader processors */
457 PFLFromBeforeProcessors,
458 /** PFL signals come pre-fader but after pre-fader processors */
459 PFLFromAfterProcessors
463 /** AFL signals come post-fader and before post-fader processors */
464 AFLFromBeforeProcessors,
465 /** AFL signals come post-fader but after post-fader processors */
466 AFLFromAfterProcessors
481 enum ListenPosition {
486 enum AutoConnectOption {
488 AutoConnectPhysical = 0x1,
489 AutoConnectMaster = 0x2
492 enum TracksAutoNamingRule {
493 UseDefaultNames = 0x1,
494 NameAfterDriver = 0x2
503 int format_data_width (ARDOUR::SampleFormat);
505 enum CDMarkerFormat {
525 typedef Sample PeakDatum;
538 /* These are "synonyms". It is important for JACK to be first
539 both here and in enums.cc, so that the string "JACK" is
540 correctly recognized in older session and preference files.
549 enum ShuttleBehaviour {
559 typedef std::vector<boost::shared_ptr<Source> > SourceList;
569 typedef std::list<framepos_t> AnalysisFeatureList;
571 typedef std::list<boost::shared_ptr<Route> > RouteList;
572 typedef std::list<boost::shared_ptr<Stripable> > StripableList;
573 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
574 typedef std::list<boost::weak_ptr <Stripable> > WeakStripableList;
575 typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
577 typedef std::list<boost::shared_ptr<VCA> > VCAList;
580 typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
592 struct CleanupReport {
593 std::vector<std::string> paths;
597 enum PositionLockStyle {
602 /** A struct used to describe changes to processors in a route.
603 * This is useful because objects that respond to a change in processors
604 * can optimise what work they do based on details of what has changed.
606 struct RouteProcessorChange {
609 MeterPointChange = 0x1,
613 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
616 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
619 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
622 /** type of change; "GeneralChange" means anything could have changed */
624 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
625 bool meter_visibly_changed;
629 AutoConnectOption input_ac; /* override the RC config for input auto-connection */
630 AutoConnectOption output_ac; /* override the RC config for output auto-connection */
631 uint32_t master_out_channels; /* how many channels for the master bus */
632 uint32_t requested_physical_in; /* now many of the available physical inputs to consider usable */
633 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
644 enum TransportState {
645 /* these values happen to match the constants used by JACK but
646 this equality cannot be assumed.
648 TransportStopped = 0,
649 TransportRolling = 1,
650 TransportLooping = 2,
651 TransportStarting = 3,
655 /* these values happen to match the constants used by JACK but
656 this equality cannot be assumed.
664 /* non-JACK related flags */
671 MidiPortControl = 0x2,
672 MidiPortSelection = 0x4,
673 MidiPortVirtual = 0x8
676 struct LatencyRange {
677 uint32_t min; //< samples
678 uint32_t max; //< samples
681 enum BufferingPreset {
688 enum AutoReturnTarget {
690 RangeSelectionStart = 0x2,
692 RegionSelectionStart = 0x8,
695 enum PlaylistDisposition {
701 enum MidiTrackNameSource {
707 enum MidiTempoMapDisposition {
712 } // namespace ARDOUR
715 /* these cover types declared above in this header. See enums.cc
718 std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);
719 std::istream& operator>>(std::istream& o, ARDOUR::HeaderFormat& sf);
720 std::istream& operator>>(std::istream& o, ARDOUR::AutoConnectOption& sf);
721 std::istream& operator>>(std::istream& o, ARDOUR::TracksAutoNamingRule& sf);
722 std::istream& operator>>(std::istream& o, ARDOUR::EditMode& sf);
723 std::istream& operator>>(std::istream& o, ARDOUR::MonitorModel& sf);
724 std::istream& operator>>(std::istream& o, ARDOUR::MonitorChoice& sf);
725 std::istream& operator>>(std::istream& o, ARDOUR::PFLPosition& sf);
726 std::istream& operator>>(std::istream& o, ARDOUR::AFLPosition& sf);
727 std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
728 std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
729 std::istream& operator>>(std::istream& o, ARDOUR::InsertMergePolicy& sf);
730 std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
731 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
732 std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
733 std::istream& operator>>(std::istream& o, Timecode::TimecodeFormat& sf);
734 std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf);
735 std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf);
736 std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf);
737 std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf);
738 std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var);
739 std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf);
740 std::istream& operator>>(std::istream& o, ARDOUR::MeterType& sf);
742 std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf);
743 std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf);
744 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoConnectOption& sf);
745 std::ostream& operator<<(std::ostream& o, const ARDOUR::TracksAutoNamingRule& sf);
746 std::ostream& operator<<(std::ostream& o, const ARDOUR::EditMode& sf);
747 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorModel& sf);
748 std::ostream& operator<<(std::ostream& o, const ARDOUR::MonitorChoice& sf);
749 std::ostream& operator<<(std::ostream& o, const ARDOUR::PFLPosition& sf);
750 std::ostream& operator<<(std::ostream& o, const ARDOUR::AFLPosition& sf);
751 std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
752 std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
753 std::ostream& operator<<(std::ostream& o, const ARDOUR::InsertMergePolicy& sf);
754 std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
755 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
756 std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
757 std::ostream& operator<<(std::ostream& o, const Timecode::TimecodeFormat& sf);
758 std::ostream& operator<<(std::ostream& o, const ARDOUR::DenormalModel& sf);
759 std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf);
760 std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf);
761 std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf);
762 std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var);
763 std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf);
764 std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterType& sf);
766 /* because these operators work on types which can be used when making
767 a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported.
769 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf);
770 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf);
771 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::VUMeterStandard& sf);
772 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::MeterLineUp& sf);
773 LIBARDOUR_API std::istream& operator>>(std::istream& o, ARDOUR::LocaleMode& sf);
775 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformScale& sf);
776 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::WaveformShape& sf);
777 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::VUMeterStandard& sf);
778 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::MeterLineUp& sf);
779 LIBARDOUR_API std::ostream& operator<<(std::ostream& o, const ARDOUR::LocaleMode& sf);
782 static inline ARDOUR::framepos_t
783 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
785 long double result = (long double) session_frame * (long double) speed;
787 if (result >= (long double) ARDOUR::max_framepos) {
788 return ARDOUR::max_framepos;
789 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
790 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
796 static inline ARDOUR::framepos_t
797 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
799 /* NB - do we need a check for speed == 0 ??? */
800 long double result = (long double) track_frame / (long double) speed;
802 if (result >= (long double) ARDOUR::max_framepos) {
803 return ARDOUR::max_framepos;
804 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
805 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
811 /* for now, break the rules and use "using" to make this "global" */
813 using ARDOUR::framepos_t;
816 #endif /* __ardour_types_h__ */