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__
27 #include <boost/shared_ptr.hpp>
28 #include <sys/types.h>
34 #include "timecode/bbt_time.h"
35 #include "timecode/time.h"
39 #include "evoral/Range.hpp"
41 #include "ardour/chan_count.h"
42 #include "ardour/plugin_types.h"
58 class AutomationControl;
59 class SlavableAutomationControl;
64 typedef uint32_t layer_t;
65 typedef uint64_t microseconds_t;
66 typedef uint32_t pframes_t;
68 /* Any position measured in audio frames.
69 Assumed to be non-negative but not enforced.
71 typedef int64_t framepos_t;
73 /* Any distance from a given framepos_t.
74 Maybe positive or negative.
76 typedef int64_t frameoffset_t;
78 /* Any count of audio frames.
79 Assumed to be positive but not enforced.
81 typedef int64_t framecnt_t;
83 static const framepos_t max_framepos = INT64_MAX;
84 static const framecnt_t max_framecnt = INT64_MAX;
85 static const layer_t max_layer = UINT32_MAX;
87 // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
88 typedef std::list<std::pair<frameoffset_t, frameoffset_t> > AudioIntervalResult;
89 // associate a set of intervals with regions (e.g. for silence detection)
90 typedef std::map<boost::shared_ptr<ARDOUR::Region>,AudioIntervalResult> AudioIntervalMap;
92 typedef std::list<boost::shared_ptr<Region> > RegionList;
98 ConfigurationChanged = 0x1,
99 ConnectionsChanged = 0x2
102 IOChange () : type (NoChange) {}
103 IOChange (Type t) : type (t) {}
105 /** channel count of IO before a ConfigurationChanged, if appropriate */
106 ARDOUR::ChanCount before;
107 /** channel count of IO after a ConfigurationChanged, if appropriate */
108 ARDOUR::ChanCount after;
111 /* policies for inserting/pasting material where overlaps
115 enum InsertMergePolicy {
116 InsertMergeReject, ///< no overlaps allowed
117 InsertMergeRelax, ///< we just don't care about overlaps
118 InsertMergeReplace, ///< replace old with new
119 InsertMergeTruncateExisting, ///< shorten existing to avoid overlap
120 InsertMergeTruncateAddition, ///< shorten new to avoid overlap
121 InsertMergeExtend ///< extend new (or old) to the range of old+new
124 /** See evoral/Parameter.hpp
126 * When you add things here, you REALLY SHOULD add a case clause to
127 * the constructor of ParameterDescriptor, unless the Controllables
128 * that the enum refers to are completely standard (0-1.0 range, 0.0 as
129 * normal, non-toggled, non-enumerated). Anything else needs to be
130 * added there so that things that try to represent them can do so
131 * with as much information as possible.
133 enum AutomationType {
136 PanAzimuthAutomation,
137 PanElevationAutomation,
139 PanFrontBackAutomation,
142 PluginPropertyAutomation,
144 SoloIsolateAutomation,
148 MidiPgmChangeAutomation,
149 MidiPitchBenderAutomation,
150 MidiChannelPressureAutomation,
151 MidiNotePressureAutomation,
152 MidiSystemExclusiveAutomation,
160 MonitoringAutomation,
173 std::string auto_state_to_string (AutoState);
174 AutoState string_to_auto_state (std::string);
196 MeterMaxSignal = 0x0001,
197 MeterMaxPeak = 0x0002,
202 MeterIEC1DIN = 0x0040,
203 MeterIEC1NOR = 0x0080,
204 MeterIEC2BBC = 0x0100,
205 MeterIEC2EBU = 0x0200,
208 MeterPeak0dB = 0x1000,
224 AllChannels = 0, ///< Pass through all channel information unmodified
225 FilterChannels, ///< Ignore events on certain channels
226 ForceChannel ///< Force all events to a certain channel
236 RoundDownMaybe = -2, ///< Round down only if necessary
237 RoundDownAlways = -1, ///< Always round down, even if on a division
238 RoundNearest = 0, ///< Round to nearest
239 RoundUpAlways = 1, ///< Always round up, even if on a division
240 RoundUpMaybe = 2 ///< Round up only if necessary
254 Timecode::Time timecode;
255 Timecode::BBT_Time bbt;
262 AnyTime() { type = Frames; frames = 0; }
264 bool operator== (AnyTime const & other) const {
265 if (type != other.type) { return false; }
269 return timecode == other.timecode;
271 return bbt == other.bbt;
273 return frames == other.frames;
275 return seconds == other.seconds;
277 return false; // get rid of warning
280 bool not_zero() const
284 return timecode.hours != 0 || timecode.minutes != 0 ||
285 timecode.seconds != 0 || timecode.frames != 0;
287 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
294 abort(); /* NOTREACHED */
299 /* used for translating audio frames to an exact musical position using a note divisor.
300 an exact musical position almost never falls exactly on an audio frame, but for sub-sample
301 musical accuracy we need to derive exact musical locations from a frame position
302 the division follows TempoMap::exact_beat_at_frame().
304 -1 musical location is the bar closest to frame
305 0 musical location is the musical position of the frame
306 1 musical location is the BBT beat closest to frame
307 n musical location is the quarter-note division n closest to frame
313 MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {}
315 void set (framepos_t f, int32_t d) {frame = f; division = d; }
317 MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); }
320 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
321 but this has a uint32_t id which Evoral::Range<> does not.
328 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
330 framecnt_t length() const { return end - start + 1; }
332 bool operator== (const AudioRange& other) const {
333 return start == other.start && end == other.end && id == other.id;
336 bool equal (const AudioRange& other) const {
337 return start == other.start && end == other.end;
340 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
341 return Evoral::coverage (start, end, s, e);
346 Timecode::BBT_Time start;
347 Timecode::BBT_Time end;
350 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
351 : start (s), end (e), id (i) {}
353 bool operator== (const MusicRange& other) const {
354 return start == other.start && end == other.end && id == other.id;
357 bool equal (const MusicRange& other) const {
358 return start == other.start && end == other.end;
363 Slowest = 6.6dB/sec falloff at update rate of 40ms
364 Slow = 6.8dB/sec falloff at update rate of 40ms
369 MeterFalloffSlowest = 1,
370 MeterFalloffSlow = 2,
371 MeterFalloffSlowish = 3,
372 MeterFalloffModerate = 4,
373 MeterFalloffMedium = 5,
374 MeterFalloffFast = 6,
375 MeterFalloffFaster = 7,
376 MeterFalloffFastest = 8,
382 MeterHoldMedium = 100,
393 enum RegionSelectionAfterSplit {
395 NewlyCreatedLeft = 1, // bit 0
396 NewlyCreatedRight = 2, // bit 1
397 NewlyCreatedBoth = 3,
398 Existing = 4, // bit 2
399 ExistingNewlyCreatedLeft = 5,
400 ExistingNewlyCreatedRight = 6,
401 ExistingNewlyCreatedBoth = 7
416 HardwareMonitoring, ///< JACK does monitoring
417 SoftwareMonitoring, ///< Ardour does monitoring
418 ExternalMonitoring ///< we leave monitoring to the audio hardware
429 MonitoringSilence = 0x1,
430 MonitoringInput = 0x2,
431 MonitoringDisk = 0x4,
435 MeteringInput, ///< meter the input IO, regardless of what is going through the route
436 MeteringRoute ///< meter what is going through the route
439 enum VUMeterStandard {
440 MeteringVUfrench, // 0VU = -2dBu
441 MeteringVUamerican, // 0VU = 0dBu
442 MeteringVUstandard, // 0VU = +4dBu
443 MeteringVUeight // 0VU = +8dBu
454 /** PFL signals come from before pre-fader processors */
455 PFLFromBeforeProcessors,
456 /** PFL signals come pre-fader but after pre-fader processors */
457 PFLFromAfterProcessors
461 /** AFL signals come post-fader and before post-fader processors */
462 AFLFromBeforeProcessors,
463 /** AFL signals come post-fader but after post-fader processors */
464 AFLFromAfterProcessors
479 enum ListenPosition {
484 enum AutoConnectOption {
486 AutoConnectPhysical = 0x1,
487 AutoConnectMaster = 0x2
490 enum TracksAutoNamingRule {
491 UseDefaultNames = 0x1,
492 NameAfterDriver = 0x2
501 int format_data_width (ARDOUR::SampleFormat);
503 enum CDMarkerFormat {
523 typedef Sample PeakDatum;
536 /* These are "synonyms". It is important for JACK to be first
537 both here and in enums.cc, so that the string "JACK" is
538 correctly recognized in older session and preference files.
547 enum ShuttleBehaviour {
557 typedef std::vector<boost::shared_ptr<Source> > SourceList;
567 typedef std::list<framepos_t> AnalysisFeatureList;
569 typedef std::list<boost::shared_ptr<Route> > RouteList;
570 typedef std::list<boost::shared_ptr<Stripable> > StripableList;
571 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
572 typedef std::list<boost::weak_ptr <Stripable> > WeakStripableList;
573 typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
574 typedef std::list<boost::shared_ptr<SlavableAutomationControl> > SlavableControlList;
575 typedef std::set <boost::shared_ptr<AutomationControl> > AutomationControlSet;
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 uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
640 enum TransportState {
641 /* these values happen to match the constants used by JACK but
642 this equality cannot be assumed.
644 TransportStopped = 0,
645 TransportRolling = 1,
646 TransportLooping = 2,
647 TransportStarting = 3,
651 /* these values happen to match the constants used by JACK but
652 this equality cannot be assumed.
660 /* non-JACK related flags */
667 MidiPortControl = 0x2,
668 MidiPortSelection = 0x4,
669 MidiPortVirtual = 0x8
672 struct LatencyRange {
673 uint32_t min; //< samples
674 uint32_t max; //< samples
677 enum BufferingPreset {
684 enum AutoReturnTarget {
686 RangeSelectionStart = 0x2,
688 RegionSelectionStart = 0x8,
691 enum PlaylistDisposition {
697 enum MidiTrackNameSource {
703 enum MidiTempoMapDisposition {
708 } // namespace ARDOUR
710 static inline ARDOUR::framepos_t
711 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
713 long double result = (long double) session_frame * (long double) speed;
715 if (result >= (long double) ARDOUR::max_framepos) {
716 return ARDOUR::max_framepos;
717 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
718 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
724 static inline ARDOUR::framepos_t
725 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
727 /* NB - do we need a check for speed == 0 ??? */
728 long double result = (long double) track_frame / (long double) speed;
730 if (result >= (long double) ARDOUR::max_framepos) {
731 return ARDOUR::max_framepos;
732 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
733 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
739 /* for now, break the rules and use "using" to make this "global" */
741 using ARDOUR::framepos_t;
744 #endif /* __ardour_types_h__ */