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 samples.
69 Assumed to be non-negative but not enforced.
71 typedef int64_t samplepos_t;
73 /* Any distance from a given samplepos_t.
74 Maybe positive or negative.
76 typedef int64_t sampleoffset_t;
78 /* Any count of audio samples.
79 Assumed to be positive but not enforced.
81 typedef int64_t samplecnt_t;
83 static const samplepos_t max_samplepos = INT64_MAX;
84 static const samplecnt_t max_samplecnt = 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<sampleoffset_t, sampleoffset_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 DiskIOPreFader, /* after the trim control, but before other processors */
197 DiskIOPostFader, /* before the main outs, after other processors */
198 DiskIOCustom, /* up to the user. Caveat Emptor! */
202 MeterMaxSignal = 0x0001,
203 MeterMaxPeak = 0x0002,
208 MeterIEC1DIN = 0x0040,
209 MeterIEC1NOR = 0x0080,
210 MeterIEC2BBC = 0x0100,
211 MeterIEC2EBU = 0x0200,
214 MeterPeak0dB = 0x1000,
230 AllChannels = 0, ///< Pass through all channel information unmodified
231 FilterChannels, ///< Ignore events on certain channels
232 ForceChannel ///< Force all events to a certain channel
242 RoundDownMaybe = -2, ///< Round down only if necessary
243 RoundDownAlways = -1, ///< Always round down, even if on a division
244 RoundNearest = 0, ///< Round to nearest
245 RoundUpAlways = 1, ///< Always round up, even if on a division
246 RoundUpMaybe = 2 ///< Round up only if necessary
260 Timecode::Time timecode;
261 Timecode::BBT_Time bbt;
268 AnyTime() { type = Samples; samples = 0; }
270 bool operator== (AnyTime const & other) const {
271 if (type != other.type) { return false; }
275 return timecode == other.timecode;
277 return bbt == other.bbt;
279 return samples == other.samples;
281 return seconds == other.seconds;
283 return false; // get rid of warning
286 bool not_zero() const
290 return timecode.hours != 0 || timecode.minutes != 0 ||
291 timecode.seconds != 0 || timecode.frames != 0;
293 return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0;
300 abort(); /* NOTREACHED */
305 /* used for translating audio samples to an exact musical position using a note divisor.
306 an exact musical position almost never falls exactly on an audio sample, but for sub-sample
307 musical accuracy we need to derive exact musical locations from a sample position
308 the division follows TempoMap::exact_beat_at_sample().
310 -1 musical location is the bar closest to sample
311 0 musical location is the musical position of the sample
312 1 musical location is the BBT beat closest to sample
313 n musical location is the quarter-note division n closest to sample
319 MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {}
321 void set (samplepos_t f, int32_t d) {sample = f; division = d; }
323 MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); }
326 /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
327 but this has a uint32_t id which Evoral::Range<> does not.
334 AudioRange (samplepos_t s, samplepos_t e, uint32_t i) : start (s), end (e) , id (i) {}
336 samplecnt_t length() const { return end - start + 1; }
338 bool operator== (const AudioRange& other) const {
339 return start == other.start && end == other.end && id == other.id;
342 bool equal (const AudioRange& other) const {
343 return start == other.start && end == other.end;
346 Evoral::OverlapType coverage (samplepos_t s, samplepos_t e) const {
347 return Evoral::coverage (start, end, s, e);
352 Timecode::BBT_Time start;
353 Timecode::BBT_Time end;
356 MusicRange (Timecode::BBT_Time& s, Timecode::BBT_Time& e, uint32_t i)
357 : start (s), end (e), id (i) {}
359 bool operator== (const MusicRange& other) const {
360 return start == other.start && end == other.end && id == other.id;
363 bool equal (const MusicRange& other) const {
364 return start == other.start && end == other.end;
369 Slowest = 6.6dB/sec falloff at update rate of 40ms
370 Slow = 6.8dB/sec falloff at update rate of 40ms
375 MeterFalloffSlowest = 1,
376 MeterFalloffSlow = 2,
377 MeterFalloffSlowish = 3,
378 MeterFalloffModerate = 4,
379 MeterFalloffMedium = 5,
380 MeterFalloffFast = 6,
381 MeterFalloffFaster = 7,
382 MeterFalloffFastest = 8,
388 MeterHoldMedium = 100,
399 enum RegionSelectionAfterSplit {
401 NewlyCreatedLeft = 1, // bit 0
402 NewlyCreatedRight = 2, // bit 1
403 NewlyCreatedBoth = 3,
404 Existing = 4, // bit 2
405 ExistingNewlyCreatedLeft = 5,
406 ExistingNewlyCreatedRight = 6,
407 ExistingNewlyCreatedBoth = 7
422 HardwareMonitoring, ///< JACK does monitoring
423 SoftwareMonitoring, ///< Ardour does monitoring
424 ExternalMonitoring ///< we leave monitoring to the audio hardware
435 MonitoringSilence = 0x1,
436 MonitoringInput = 0x2,
437 MonitoringDisk = 0x4,
441 MeteringInput, ///< meter the input IO, regardless of what is going through the route
442 MeteringRoute ///< meter what is going through the route
445 enum VUMeterStandard {
446 MeteringVUfrench, // 0VU = -2dBu
447 MeteringVUamerican, // 0VU = 0dBu
448 MeteringVUstandard, // 0VU = +4dBu
449 MeteringVUeight // 0VU = +8dBu
460 /** PFL signals come from before pre-fader processors */
461 PFLFromBeforeProcessors,
462 /** PFL signals come pre-fader but after pre-fader processors */
463 PFLFromAfterProcessors
467 /** AFL signals come post-fader and before post-fader processors */
468 AFLFromBeforeProcessors,
469 /** AFL signals come post-fader but after post-fader processors */
470 AFLFromAfterProcessors
485 enum ListenPosition {
490 enum AutoConnectOption {
492 AutoConnectPhysical = 0x1,
493 AutoConnectMaster = 0x2
496 enum TracksAutoNamingRule {
497 UseDefaultNames = 0x1,
498 NameAfterDriver = 0x2
507 int format_data_width (ARDOUR::SampleFormat);
509 enum CDMarkerFormat {
529 typedef Sample PeakDatum;
542 /* These are "synonyms". It is important for JACK to be first
543 both here and in enums.cc, so that the string "JACK" is
544 correctly recognized in older session and preference files.
553 enum ShuttleBehaviour {
563 typedef std::vector<boost::shared_ptr<Source> > SourceList;
573 typedef std::list<samplepos_t> AnalysisFeatureList;
575 typedef std::list<boost::shared_ptr<Route> > RouteList;
576 typedef std::list<boost::shared_ptr<Stripable> > StripableList;
577 typedef std::list<boost::weak_ptr <Route> > WeakRouteList;
578 typedef std::list<boost::weak_ptr <Stripable> > WeakStripableList;
579 typedef std::list<boost::shared_ptr<AutomationControl> > ControlList;
580 typedef std::list<boost::shared_ptr<SlavableAutomationControl> > SlavableControlList;
581 typedef std::set <boost::shared_ptr<AutomationControl> > AutomationControlSet;
583 typedef std::list<boost::shared_ptr<VCA> > VCAList;
586 typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
598 struct CleanupReport {
599 std::vector<std::string> paths;
603 enum PositionLockStyle {
608 /** A struct used to describe changes to processors in a route.
609 * This is useful because objects that respond to a change in processors
610 * can optimise what work they do based on details of what has changed.
612 struct RouteProcessorChange {
615 MeterPointChange = 0x1,
619 RouteProcessorChange () : type (GeneralChange), meter_visibly_changed (true)
622 RouteProcessorChange (Type t) : type (t), meter_visibly_changed (true)
625 RouteProcessorChange (Type t, bool m) : type (t), meter_visibly_changed (m)
628 /** type of change; "GeneralChange" means anything could have changed */
630 /** true if, when a MeterPointChange has occurred, the change is visible to the user */
631 bool meter_visibly_changed;
635 uint32_t master_out_channels; /* how many channels for the master bus, 0: no master bus */
646 enum TransportState {
647 /* these values happen to match the constants used by JACK but
648 this equality cannot be assumed.
650 TransportStopped = 0,
651 TransportRolling = 1,
652 TransportLooping = 2,
653 TransportStarting = 3,
657 /* these values happen to match the constants used by JACK but
658 this equality cannot be assumed.
666 /* non-JACK related flags */
673 MidiPortControl = 0x2,
674 MidiPortSelection = 0x4,
675 MidiPortVirtual = 0x8
678 struct LatencyRange {
679 uint32_t min; //< samples
680 uint32_t max; //< samples
683 enum BufferingPreset {
690 enum AutoReturnTarget {
692 RangeSelectionStart = 0x2,
694 RegionSelectionStart = 0x8,
697 enum PlaylistDisposition {
703 enum MidiTrackNameSource {
709 enum MidiTempoMapDisposition {
719 typedef std::vector<CaptureInfo*> CaptureInfos;
721 } // namespace ARDOUR
723 static inline ARDOUR::samplepos_t
724 session_sample_to_track_sample (ARDOUR::samplepos_t session_sample, double speed)
726 long double result = (long double) session_sample * (long double) speed;
728 if (result >= (long double) ARDOUR::max_samplepos) {
729 return ARDOUR::max_samplepos;
730 } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) {
731 return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1));
737 static inline ARDOUR::samplepos_t
738 track_sample_to_session_sample (ARDOUR::samplepos_t track_sample, double speed)
740 /* NB - do we need a check for speed == 0 ??? */
741 long double result = (long double) track_sample / (long double) speed;
743 if (result >= (long double) ARDOUR::max_samplepos) {
744 return ARDOUR::max_samplepos;
745 } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) {
746 return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1));
752 /* for now, break the rules and use "using" to make this "global" */
754 using ARDOUR::samplepos_t;
757 #endif /* __ardour_types_h__ */