diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 97a4db9c1b..e907971319 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -247,7 +247,7 @@ class LIBARDOUR_API AudioRegion : public Region, public AudioReadable protected: /* default constructor for derived (compound) types */ - AudioRegion (Session& s, timecnt_t const &, timecnt_t const &, std::string name); + AudioRegion (Session& s, timepos_t const &, timecnt_t const &, std::string name); int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); }; diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 717c28565b..64d090a2cb 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -102,7 +102,7 @@ class LIBARDOUR_API MidiSource : virtual public Source virtual timecnt_t midi_read (const Lock& lock, Evoral::EventSink& dst, timepos_t const & source_start, - timecnt_t const & start, + timepos_t const & start, timecnt_t const & cnt, Temporal::Range* loop_range, MidiCursor& cursor, @@ -209,7 +209,7 @@ class LIBARDOUR_API MidiSource : virtual public Source virtual timecnt_t read_unlocked (const Lock& lock, Evoral::EventSink& dst, timepos_t const & position, - timecnt_t const & start, + timepos_t const & start, timecnt_t const & cnt, Temporal::Range* loop_range, MidiStateTracker* tracker, diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 364b4b03e2..6f94ad6277 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -62,12 +62,12 @@ namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor hidden; LIBARDOUR_API extern PBD::PropertyDescriptor position_locked; LIBARDOUR_API extern PBD::PropertyDescriptor valid_transients; - LIBARDOUR_API extern PBD::PropertyDescriptor start; + LIBARDOUR_API extern PBD::PropertyDescriptor start; LIBARDOUR_API extern PBD::PropertyDescriptor length; LIBARDOUR_API extern PBD::PropertyDescriptor position; - LIBARDOUR_API extern PBD::PropertyDescriptor sync_position; + LIBARDOUR_API extern PBD::PropertyDescriptor sync_position; LIBARDOUR_API extern PBD::PropertyDescriptor layer; - LIBARDOUR_API extern PBD::PropertyDescriptor ancestral_start; + LIBARDOUR_API extern PBD::PropertyDescriptor ancestral_start; LIBARDOUR_API extern PBD::PropertyDescriptor ancestral_length; LIBARDOUR_API extern PBD::PropertyDescriptor stretch; LIBARDOUR_API extern PBD::PropertyDescriptor shift; @@ -119,7 +119,7 @@ public: */ timepos_t position () const { return _length.val().position(); } - timecnt_t start () const { return _start.val(); } + timepos_t start () const { return _start.val(); } timecnt_t length () const { return _length.val(); } timepos_t end() const; timepos_t nt_last() const { return end().decrement(); } @@ -146,13 +146,13 @@ public: samplecnt_t ancestral_start_sample () const { return _ancestral_start.val().samples(); } samplecnt_t ancestral_length_samples () const { return _ancestral_length.val().samples(); } - timecnt_t ancestral_start () const { return _ancestral_start.val(); } + timepos_t ancestral_start () const { return _ancestral_start.val(); } timecnt_t ancestral_length () const { return _ancestral_length.val(); } float stretch () const { return _stretch; } float shift () const { return _shift; } - void set_ancestral_data (timecnt_t const & start, timecnt_t const & length, float stretch, float shift); + void set_ancestral_data (timepos_t const & start, timecnt_t const & length, float stretch, float shift); timecnt_t sync_offset (int& dir) const; timepos_t sync_position () const; @@ -241,7 +241,7 @@ public: /* EDITING OPERATIONS */ void set_length (timecnt_t const &); - void set_start (timecnt_t const &); + void set_start (timepos_t const &); void set_position (timepos_t const &); void set_initial_position (timepos_t const &); void special_set_position (timepos_t const &); @@ -439,7 +439,7 @@ protected: Region (boost::shared_ptr, const SourceList&); /** Constructor for derived types only */ - Region (Session& s, timecnt_t const & start, timecnt_t const & length, const std::string& name, DataType); + Region (Session& s, timepos_t const & start, timecnt_t const & length, const std::string& name, DataType); virtual bool can_trim_start_before_source_start () const { return false; @@ -451,8 +451,8 @@ protected: virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); virtual void set_position_internal (timepos_t const & pos); virtual void set_length_internal (timecnt_t const &); - virtual void set_start_internal (timecnt_t const &); - bool verify_start_and_length (timecnt_t const &, timecnt_t&); + virtual void set_start_internal (timepos_t const &); + bool verify_start_and_length (timepos_t const &, timecnt_t&); void first_edit (); DataType _type; @@ -461,10 +461,10 @@ protected: PBD::Property _left_of_split; PBD::Property _right_of_split; PBD::Property _valid_transients; - PBD::Property _start; + PBD::Property _start; PBD::Property _length; /** Sync position relative to the start of our file */ - PBD::Property _sync_position; + PBD::Property _sync_position; SourceList _sources; /** Used when timefx are applied, so we can always use the original source */ @@ -496,7 +496,7 @@ private: void maybe_uncopy (); - bool verify_start (timecnt_t const &); + bool verify_start (timepos_t const &); bool verify_start_mutable (timecnt_t&); bool verify_length (timecnt_t&); @@ -513,7 +513,7 @@ private: PBD::Property _external; PBD::Property _hidden; PBD::Property _position_locked; - PBD::Property _ancestral_start; + PBD::Property _ancestral_start; PBD::Property _ancestral_length; PBD::Property _stretch; PBD::Property _shift; diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index d8407ddcd3..3f4ff7e0cf 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -83,7 +83,7 @@ public: Temporal::Beats _last_ev_time_beats; samplepos_t _last_ev_time_samples; /** end time (start + duration) of last call to read_unlocked */ - mutable timecnt_t _smf_last_read_end; + mutable timepos_t _smf_last_read_end; /** time (in SMF ticks, 1 tick per _ppqn) of the last event read by read_unlocked */ mutable timepos_t _smf_last_read_time; @@ -94,7 +94,7 @@ public: timecnt_t read_unlocked (const Lock& lock, Evoral::EventSink& dst, timepos_t const & position, - timecnt_t const & start, + timepos_t const & start, timecnt_t const & cnt, Temporal::Range* loop_range, MidiStateTracker* tracker, diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 3f63d14218..b26212f2fd 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -242,7 +242,7 @@ AudioRegion::init () } /** Constructor for use by derived types only */ -AudioRegion::AudioRegion (Session& s, timecnt_t const & start, timecnt_t const & len, std::string name) +AudioRegion::AudioRegion (Session& s, timepos_t const & start, timecnt_t const & len, std::string name) : Region (s, start, len, name, DataType::AUDIO) , AUDIOREGION_STATE_DEFAULT , _envelope (Properties::envelope, boost::shared_ptr (new AutomationList (Evoral::Parameter(EnvelopeAutomation), Temporal::AudioTime))) diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index f9a39c54d7..a86ed57132 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -1243,7 +1243,7 @@ LuaAPI::Rubberband::finalize () ar->set_fade_out (_region->fade_out ()); *(ar->envelope ()) = *(_region->envelope ()); - ar->set_ancestral_data (timecnt_t (_read_start), timecnt_t (_read_len), _stretch_ratio, _pitch_ratio); + ar->set_ancestral_data (timepos_t (_read_start), timecnt_t (_read_len), _stretch_ratio, _pitch_ratio); ar->set_master_sources (_region->master_sources ()); ar->set_length (ar->length () * _stretch_ratio); // XXX if (_stretch_ratio != 1.0) { diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index e595612211..88a0b92d63 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -490,7 +490,7 @@ MidiRegion::model_shifted (timecnt_t distance) if (!_ignore_shift) { PropertyChange what_changed; - _start += distance; + _start.call().operator+= (distance); what_changed.add (Properties::start); what_changed.add (Properties::contents); send_change (what_changed); @@ -532,9 +532,9 @@ MidiRegion::fix_negative_start () { _ignore_shift = true; - model()->insert_silence_at_start (-_start.val().beats()); + model()->insert_silence_at_start (-start().beats()); - _start = timecnt_t::zero (_start.val().time_domain()); + _start = timepos_t::zero (start().time_domain()); } bool diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 7e76a32dd9..b59e524bf2 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -176,7 +176,7 @@ timecnt_t MidiSource::midi_read (const Lock& lm, Evoral::EventSink& dst, timepos_t const & source_start, - timecnt_t const & start, + timepos_t const & start, timecnt_t const & cnt, Temporal::Range* loop_range, MidiCursor& cursor, @@ -189,7 +189,7 @@ MidiSource::midi_read (const Lock& lm, source_start, start, cnt, tracker, name())); if (!_model) { - return timecnt_t (read_unlocked (lm, dst, source_start, start, cnt, loop_range, tracker, filter), start.position()); + return timecnt_t (read_unlocked (lm, dst, source_start, start, cnt, loop_range, tracker, filter), start); } // Find appropriate model iterator diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 538097c473..1c75496d34 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -352,7 +352,7 @@ RBEffect::run (boost::shared_ptr r, Progress* progress) /* now reset ancestral data for each new region */ for (vector >::iterator x = results.begin (); x != results.end (); ++x) { - (*x)->set_ancestral_data (timecnt_t (read_start), + (*x)->set_ancestral_data (timepos_t (read_start), timecnt_t (read_duration, timepos_t (read_start)), stretch, shift); diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 8496cb898e..ce2156ead6 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -69,13 +69,13 @@ namespace ARDOUR { PBD::PropertyDescriptor hidden; PBD::PropertyDescriptor position_locked; PBD::PropertyDescriptor valid_transients; - PBD::PropertyDescriptor start; + PBD::PropertyDescriptor start; PBD::PropertyDescriptor length; PBD::PropertyDescriptor beat; - PBD::PropertyDescriptor sync_position; + PBD::PropertyDescriptor sync_position; PBD::PropertyDescriptor position; PBD::PropertyDescriptor layer; - PBD::PropertyDescriptor ancestral_start; + PBD::PropertyDescriptor ancestral_start; PBD::PropertyDescriptor ancestral_length; PBD::PropertyDescriptor stretch; PBD::PropertyDescriptor shift; @@ -183,9 +183,9 @@ Region::register_properties () , _left_of_split (Properties::left_of_split, false) \ , _right_of_split (Properties::right_of_split, false) \ , _valid_transients (Properties::valid_transients, false) \ - , _start (Properties::start, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))) \ - , _length (Properties::length, timecnt_t (l, timepos_t (s))) \ - , _sync_position (Properties::sync_position, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))) \ + , _start (Properties::start, (s)) \ + , _length (Properties::length, (l)) \ + , _sync_position (Properties::sync_position, (s)) \ , _transient_user_start (0) \ , _transient_analysis_start (0) \ , _transient_analysis_end (0) \ @@ -200,7 +200,7 @@ Region::register_properties () , _external (Properties::external, false) \ , _hidden (Properties::hidden, false) \ , _position_locked (Properties::position_locked, false) \ - , _ancestral_start (Properties::ancestral_start, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))) \ + , _ancestral_start (Properties::ancestral_start, (s)) \ , _ancestral_length (Properties::ancestral_length, (l)) \ , _stretch (Properties::stretch, 1.0) \ , _shift (Properties::shift, 1.0) \ @@ -241,10 +241,10 @@ Region::register_properties () , _contents (Properties::contents, other->_contents) /* derived-from-derived constructor (no sources in constructor) */ -Region::Region (Session& s, timecnt_t const & start, timecnt_t const & length, const string& name, DataType type) +Region::Region (Session& s, timepos_t const & start, timecnt_t const & length, const string& name, DataType type) : SessionObject(s, name) - , _type(type) - , REGION_DEFAULT_STATE(start,length) + , _type (type) + , REGION_DEFAULT_STATE (start,length) , _last_length (length) , _first_edit (EditChangesNothing) , _layer (0) @@ -259,7 +259,7 @@ Region::Region (Session& s, timecnt_t const & start, timecnt_t const & length, c Region::Region (const SourceList& srcs) : SessionObject(srcs.front()->session(), "toBeRenamed") , _type (srcs.front()->type()) - , REGION_DEFAULT_STATE(_type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_t::from_superclock (0), + , REGION_DEFAULT_STATE(_type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0), _type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_t::from_superclock (0)) , _last_length (_type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_t::from_superclock (0)) , _first_edit (EditChangesNothing) @@ -316,7 +316,7 @@ Region::Region (boost::shared_ptr other) if (other->sync_marked()) { if (other->_start < other->_sync_position) { /* sync pos was after the start point of the other region */ - _sync_position = other->_sync_position - other->_start; + _sync_position = timepos_t (other->start().distance (other->_sync_position)); } else { /* sync pos was before the start point of the other region. not possible here. */ _sync_marked = false; @@ -670,8 +670,6 @@ Region::set_position_internal (timepos_t const & pos) _last_length.set_position (position()); if (position() != pos) { -#warning NUTEMPO is this correct? why would set position set the position of the start (duration)? - _start.call().set_position (pos); _length.call().set_position (pos); /* check that the new _position wouldn't make the current @@ -759,7 +757,7 @@ Region::nudge_position (timecnt_t const & n) } void -Region::set_ancestral_data (timecnt_t const & s, timecnt_t const & l, float st, float sh) +Region::set_ancestral_data (timepos_t const & s, timecnt_t const & l, float st, float sh) { _ancestral_length = l; _ancestral_start = s; @@ -768,7 +766,7 @@ Region::set_ancestral_data (timecnt_t const & s, timecnt_t const & l, float st, } void -Region::set_start (timecnt_t const & pos) +Region::set_start (timepos_t const & pos) { if (locked() || position_locked() || video_locked()) { return; @@ -780,7 +778,7 @@ Region::set_start (timecnt_t const & pos) if (_start != pos) { - timecnt_t p = pos; + timepos_t p = pos; if (!verify_start (p)) { return; @@ -802,14 +800,15 @@ Region::move_start (timecnt_t const & distance) return; } - timecnt_t new_start (_start); - + timepos_t new_start (_start); + timepos_t current_start (_start); + if (distance.positive()) { - if (_start > timecnt_t::max() - distance) { - new_start = timecnt_t::max(); // makes no sense + if (current_start > timepos_t::max (current_start.time_domain()).earlier (distance)) { + new_start = timecnt_t::max(current_start.time_domain()); // makes no sense } else { - new_start = start() + distance; + new_start = current_start + distance; } if (!verify_start (new_start)) { @@ -818,10 +817,10 @@ Region::move_start (timecnt_t const & distance) } else { - if (_start < -distance) { - new_start = timecnt_t (_start.val().time_domain()); + if (current_start < -distance) { + new_start = timecnt_t (current_start.time_domain()); } else { - new_start = start() + distance; + new_start = current_start + distance; } } @@ -946,7 +945,7 @@ Region::trim_to (timepos_t const & position, timecnt_t const & length) void Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) { - timecnt_t new_start (len.time_domain()); + timepos_t new_start (len.time_domain()); if (locked()) { return; @@ -957,7 +956,7 @@ Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) if (start_shift.positive()) { if (start() > timecnt_t::max() - start_shift) { - new_start = timecnt_t::max(); + new_start = timepos_t::max (start().time_domain()); } else { new_start = start() + start_shift; } @@ -974,7 +973,7 @@ Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) new_start = start(); } - timecnt_t ns = new_start; + timepos_t ns = new_start; timecnt_t nl = len; if (!verify_start_and_length (ns, nl)) { @@ -1103,7 +1102,7 @@ void Region::set_sync_position (timepos_t const & absolute_pos) { /* position within our file */ - const timecnt_t file_pos = start() + position().distance (absolute_pos); + const timepos_t file_pos = start() + position().distance (absolute_pos); if (file_pos != _sync_position) { _sync_marked = true; @@ -1129,21 +1128,21 @@ Region::clear_sync_position () } } -/* @return the sync point relative the first sample of the region */ +/* @return the sync point relative the position of the region */ timecnt_t Region::sync_offset (int& dir) const { if (sync_marked()) { if (_sync_position > _start) { dir = 1; - return _sync_position - _start; + return start().distance (_sync_position); } else { dir = -1; - return _start - _sync_position; + return sync_position().distance (start()); } } else { dir = 0; - return timecnt_t (); + return timecnt_t::zero (start().time_domain()); } } @@ -1681,7 +1680,7 @@ Region::verify_length (timecnt_t& len) } bool -Region::verify_start_and_length (timecnt_t const & new_start, timecnt_t& new_length) +Region::verify_start_and_length (timepos_t const & new_start, timecnt_t& new_length) { if (source() && source()->length_mutable()) { return true; @@ -1699,7 +1698,7 @@ Region::verify_start_and_length (timecnt_t const & new_start, timecnt_t& new_len } bool -Region::verify_start (timecnt_t const & pos) +Region::verify_start (timepos_t const & pos) { if (source() && source()->length_mutable()) { return true; @@ -1949,7 +1948,7 @@ Region::is_compound () const } void -Region::set_start_internal (timecnt_t const & s) +Region::set_start_internal (timepos_t const & s) { _start = s; } diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index c39f7d1782..acf807f563 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -216,7 +216,7 @@ timecnt_t SMFSource::read_unlocked (const Lock& lock, Evoral::EventSink& destination, timepos_t const & source_start, - timecnt_t const & start, + timepos_t const & start, timecnt_t const & duration, Temporal::Range* loop_range, MidiStateTracker* tracker, @@ -244,7 +244,7 @@ SMFSource::read_unlocked (const Lock& lock, DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked: start in ticks %1\n", start_ticks)); - if (_smf_last_read_end == 0 || start != _smf_last_read_end) { + if (_smf_last_read_end.zero() || start != _smf_last_read_end) { DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked: seek to %1\n", start)); Evoral::SMF::seek_to_start(); while (time < start_ticks) {