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,
172 std::string auto_state_to_string (AutoState);
173 AutoState string_to_auto_state (std::string);
195 MeterMaxSignal = 0x0001,
196 MeterMaxPeak = 0x0002,
201 MeterIEC1DIN = 0x0040,
202 MeterIEC1NOR = 0x0080,
203 MeterIEC2BBC = 0x0100,
204 MeterIEC2EBU = 0x0200,
207 MeterPeak0dB = 0x1000,
223 AllChannels = 0, ///< Pass through all channel information unmodified
224 FilterChannels, ///< Ignore events on certain channels
225 ForceChannel ///< Force all events to a certain channel
235 RoundDownMaybe = -2, ///< Round down only if necessary
236 RoundDownAlways = -1, ///< Always round down, even if on a division
237 RoundNearest = 0, ///< Round to nearest
238 RoundUpAlways = 1, ///< Always round up, even if on a division
239 RoundUpMaybe = 2 ///< Round up only if necessary
253 Timecode::Time timecode;
254 Timecode::BBT_Time bbt;
261 AnyTime() { type = Frames; frames = 0; }
263 bool operator== (AnyTime const & other) const {
264 if (type != other.type) { return false; }
268 return timecode == other.timecode;
270 return bbt == other.bbt;
272 return frames == other.frames;
274 return seconds == other.seconds;
276 return false; // get rid of warning
279 bool not_zero() const
283 return timecode.hours != 0 || timecode.minutes != 0 ||
284 timecode.seconds != 0 || timecode.frames != 0;
286 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
293 abort(); /* NOTREACHED */
298 /* used for translating audio frames to an exact musical position using a note divisor.
299 an exact musical position almost never falls exactly on an audio frame, but for sub-sample
300 musical accuracy we need to derive exact musical locations from a frame position
301 the division follows TempoMap::exact_beat_at_frame().
303 -1 musical location is the bar closest to frame
304 0 musical location is the musical position of the frame
305 1 musical location is the BBT beat closest to frame
306 n musical location is the quarter-note division n closest to frame
312 MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {}
314 void set (framepos_t f, int32_t d) {frame = f; division = d; }
316 MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); }
319 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
320 but this has a uint32_t id which Evoral::Range<> does not.
327 AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
329 framecnt_t length() const { return end - start + 1; }
331 bool operator== (const AudioRange& other) const {
332 return start == other.start && end == other.end && id == other.id;
335 bool equal (const AudioRange& other) const {
336 return start == other.start && end == other.end;
339 Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
340 return Evoral::coverage (start, end, s, e);
345 Timecode::BBT_Time start;
346 Timecode::BBT_Time end;
349 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
350 : start (s), end (e), id (i) {}
352 bool operator== (const MusicRange& other) const {
353 return start == other.start && end == other.end && id == other.id;
356 bool equal (const MusicRange& other) const {
357 return start == other.start && end == other.end;
362 Slowest = 6.6dB/sec falloff at update rate of 40ms
363 Slow = 6.8dB/sec falloff at update rate of 40ms
368 MeterFalloffSlowest = 1,
369 MeterFalloffSlow = 2,
370 MeterFalloffSlowish = 3,
371 MeterFalloffModerate = 4,
372 MeterFalloffMedium = 5,
373 MeterFalloffFast = 6,
374 MeterFalloffFaster = 7,
375 MeterFalloffFastest = 8,
381 MeterHoldMedium = 100,
392 enum RegionSelectionAfterSplit {
394 NewlyCreatedLeft = 1, // bit 0
395 NewlyCreatedRight = 2, // bit 1
396 NewlyCreatedBoth = 3,
397 Existing = 4, // bit 2
398 ExistingNewlyCreatedLeft = 5,
399 ExistingNewlyCreatedRight = 6,
400 ExistingNewlyCreatedBoth = 7
415 HardwareMonitoring, ///< JACK does monitoring
416 SoftwareMonitoring, ///< Ardour does monitoring
417 ExternalMonitoring ///< we leave monitoring to the audio hardware
428 MonitoringSilence = 0x1,
429 MonitoringInput = 0x2,
430 MonitoringDisk = 0x4,
434 MeteringInput, ///< meter the input IO, regardless of what is going through the route
435 MeteringRoute ///< meter what is going through the route
438 enum VUMeterStandard {
439 MeteringVUfrench, // 0VU = -2dBu
440 MeteringVUamerican, // 0VU = 0dBu
441 MeteringVUstandard, // 0VU = +4dBu
442 MeteringVUeight // 0VU = +8dBu
453 /** PFL signals come from before pre-fader processors */
454 PFLFromBeforeProcessors,
455 /** PFL signals come pre-fader but after pre-fader processors */
456 PFLFromAfterProcessors
460 /** AFL signals come post-fader and before post-fader processors */
461 AFLFromBeforeProcessors,
462 /** AFL signals come post-fader but after post-fader processors */
463 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::shared_ptr<Stripable> > StripableList;
570 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
571 typedef std::list<boost::weak_ptr <Stripable> > WeakStripableList;
572 typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
573 typedef std::list<boost::shared_ptr<SlavableAutomationControl> > SlavableControlList;
574 typedef std::set <boost::shared_ptr<AutomationControl> > AutomationControlSet;
576 typedef std::list<boost::shared_ptr<VCA> > VCAList;
579 typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
591 struct CleanupReport {
592 std::vector<std::string> paths;
596 enum PositionLockStyle {
601 /** A struct used to describe changes to processors in a route.
602 * This is useful because objects that respond to a change in processors
603 * can optimise what work they do based on details of what has changed.
605 struct RouteProcessorChange {
608 MeterPointChange = 0x1,
612 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
615 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
618 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
621 /** type of change; "GeneralChange" means anything could have changed */
623 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
624 bool meter_visibly_changed;
628 AutoConnectOption input_ac; /* override the RC config for input auto-connection */
629 AutoConnectOption output_ac; /* override the RC config for output auto-connection */
630 uint32_t master_out_channels; /* how many channels for the master bus */
631 uint32_t requested_physical_in; /* now many of the available physical inputs to consider usable */
632 uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
643 enum TransportState {
644 /* these values happen to match the constants used by JACK but
645 this equality cannot be assumed.
647 TransportStopped = 0,
648 TransportRolling = 1,
649 TransportLooping = 2,
650 TransportStarting = 3,
654 /* these values happen to match the constants used by JACK but
655 this equality cannot be assumed.
663 /* non-JACK related flags */
670 MidiPortControl = 0x2,
671 MidiPortSelection = 0x4,
672 MidiPortVirtual = 0x8
675 struct LatencyRange {
676 uint32_t min; //< samples
677 uint32_t max; //< samples
680 enum BufferingPreset {
687 enum AutoReturnTarget {
689 RangeSelectionStart = 0x2,
691 RegionSelectionStart = 0x8,
694 enum PlaylistDisposition {
700 enum MidiTrackNameSource {
706 enum MidiTempoMapDisposition {
711 } // namespace ARDOUR
713 static inline ARDOUR::framepos_t
714 session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed)
716 long double result = (long double) session_frame * (long double) speed;
718 if (result >= (long double) ARDOUR::max_framepos) {
719 return ARDOUR::max_framepos;
720 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
721 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
727 static inline ARDOUR::framepos_t
728 track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed)
730 /* NB - do we need a check for speed == 0 ??? */
731 long double result = (long double) track_frame / (long double) speed;
733 if (result >= (long double) ARDOUR::max_framepos) {
734 return ARDOUR::max_framepos;
735 } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) {
736 return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1));
742 /* for now, break the rules and use "using" to make this "global" */
744 using ARDOUR::framepos_t;
747 #endif /* __ardour_types_h__ */