diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 7b6d24c8c4..f247e26e68 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -118,7 +118,7 @@ public: * LENGTH: number of samples the region represents */ - timepos_t position () const { return _position.val(); } + timepos_t position () const { return _length.val().position(); } timecnt_t start () const { return _start.val(); } timecnt_t length () const { return _length.val(); } timepos_t end() const; @@ -128,7 +128,7 @@ public: timepos_t source_relative_position (Temporal::timepos_t const &) const; timepos_t region_relative_position (Temporal::timepos_t const &) const; - samplepos_t position_sample () const { return _position.val().samples(); } + samplepos_t position_sample () const { return position().samples(); } samplecnt_t start_sample () const { return _start.val().samples(); } samplecnt_t length_samples () const { return _length.val().samples(); } @@ -161,7 +161,7 @@ public: /* first_sample() is an alias; last_sample() just hides some math */ - samplepos_t first_sample () const { return _position.val().samples(); } + samplepos_t first_sample () const { return position().samples(); } samplepos_t last_sample () const { return first_sample() + length_samples() - 1; } /** Return the earliest possible value of _position given the @@ -222,7 +222,7 @@ public: * OverlapExternal: the range overlaps all of this region. */ Temporal::OverlapType coverage (timepos_t const & start, timepos_t const & end) const { - return Temporal::coverage_exclusive_ends (_position.val(), nt_last(), start, end); + return Temporal::coverage_exclusive_ends (position(), nt_last(), start, end); } bool exact_equivalent (boost::shared_ptr) const; @@ -463,7 +463,6 @@ protected: PBD::Property _valid_transients; PBD::Property _start; PBD::Property _length; - PBD::Property _position; /** Sync position relative to the start of our file */ PBD::Property _sync_position; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 0e8eeae6ae..3f63d14218 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -461,7 +461,7 @@ samplecnt_t AudioRegion::read (Sample* buf, samplepos_t pos, samplecnt_t cnt, int channel) const { /* raw read, no fades, no gain, nada */ - return read_from_sources (_sources, _length.val().samples(), buf, _position.val().samples() + pos, cnt, channel); + return read_from_sources (_sources, _length.val().samples(), buf, position().samples() + pos, cnt, channel); } samplecnt_t @@ -477,13 +477,13 @@ AudioRegion::master_read_at (Sample *buf, Sample* /*mixdown_buffer*/, float* /*g /** @param buf Buffer to mix data into. * @param mixdown_buffer Scratch buffer for audio data. * @param gain_buffer Scratch buffer for gain data. - * @param position Position within the session to read from. + * @param pos Position within the session to read from. * @param cnt Number of samples to read. * @param chan_n Channel number to read. */ samplecnt_t AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, - samplepos_t position, + samplepos_t pos, samplecnt_t cnt, uint32_t chan_n) const { @@ -504,11 +504,11 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, /* WORK OUT WHERE TO GET DATA FROM */ samplecnt_t to_read; - const samplepos_t psamples = _position.val().samples(); + const samplepos_t psamples = position().samples(); const samplecnt_t lsamples = _length.val().samples(); - assert (position >= psamples); - sampleoffset_t const internal_offset = position - psamples; + assert (pos >= psamples); + sampleoffset_t const internal_offset = pos - psamples; if (internal_offset >= lsamples) { return 0; /* read nothing */ @@ -590,7 +590,7 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, may need to mix with the existing data. */ - if (read_from_sources (_sources, lsamples, mixdown_buffer, position, to_read, chan_n) != to_read) { + if (read_from_sources (_sources, lsamples, mixdown_buffer, pos, to_read, chan_n) != to_read) { return 0; } @@ -729,16 +729,16 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, * @param srcs Source list to get our source from. * @param limit Furthest that we should read, as an offset from the region position. * @param buf Buffer to write data into (existing contents of the buffer will be overwritten) - * @param position Position to read from, in session samples. + * @param pos Position to read from, in session samples. * @param cnt Number of samples to read. * @param chan_n Channel to read from. * @return Number of samples read. */ samplecnt_t -AudioRegion::read_from_sources (SourceList const & srcs, samplecnt_t limit, Sample* buf, samplepos_t position, samplecnt_t cnt, uint32_t chan_n) const +AudioRegion::read_from_sources (SourceList const & srcs, samplecnt_t limit, Sample* buf, samplepos_t pos, samplecnt_t cnt, uint32_t chan_n) const { - sampleoffset_t const internal_offset = position - _position.val().samples(); + sampleoffset_t const internal_offset = pos - position().samples(); if (internal_offset >= limit) { return 0; @@ -978,14 +978,14 @@ AudioRegion::fade_range (samplepos_t start, samplepos_t end) switch (coverage (timepos_t (start), timepos_t (end))) { case Temporal::OverlapStart: trim_front (timepos_t (start)); - s = _position.val().samples(); + s = position().samples(); e = end; set_fade_in (FadeConstantPower, e - s); break; case Temporal::OverlapEnd: trim_end(timepos_t (end)); s = start; - e = (_position.val() + timepos_t (_length)).samples(); + e = (position() + timepos_t (_length)).samples(); set_fade_out (FadeConstantPower, e - s); break; case Temporal::OverlapInternal: diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index fe4575a484..e595612211 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -164,7 +164,6 @@ MidiRegion::clone (boost::shared_ptr newsrc, ThawList* tl) const plist.add (Properties::whole_file, true); plist.add (Properties::start, _start); plist.add (Properties::length, _length); - plist.add (Properties::position, _position); plist.add (Properties::layer, 0); boost::shared_ptr ret (boost::dynamic_pointer_cast (RegionFactory::create (newsrc, plist, true, tl))); @@ -201,7 +200,7 @@ MidiRegion::master_read_at (MidiRingBuffer& out, timecnt_t MidiRegion::_read_at (const SourceList& /*srcs*/, Evoral::EventSink& dst, - timepos_t const & position, + timepos_t const & pos, timecnt_t const & xdur, Temporal::Range* loop_range, MidiCursor& cursor, @@ -222,13 +221,13 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, return timecnt_t(); /* read nothing */ } - if (position < _position) { + if (pos < position()) { /* we are starting the read from before the start of the region */ internal_offset = timecnt_t (Temporal::BeatTime);; - dur -= position.distance (_position); + dur -= pos.distance (position()); } else { /* we are starting the read from after the start of the region */ - internal_offset = _position.val().distance (position); + internal_offset = position().distance (pos); } if (internal_offset >= _length) { @@ -246,11 +245,11 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, src->set_note_mode(lm, mode); #if 0 - cerr << "MR " << name () << " read @ " << position << " + " << to_read + cerr << "MR " << name () << " read @ " << pos << " + " << to_read << " dur was " << dur << " len " << _length << " l-io " << (_length - internal_offset) - << " _position = " << _position + << " position = " << position() << " _start = " << _start << " intoffset = " << internal_offset << " quarter_note = " << quarter_note() @@ -263,7 +262,7 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, if (src->midi_read ( lm, // source lock dst, // destination buffer - _position.val().earlier (_start.val()), // start position of the source on timeline + position().earlier (_start.val()), // start position of the source on timeline _start.val() + internal_offset, // where to start reading in the source to_read, // read duration in samples loop_range, @@ -298,12 +297,12 @@ MidiRegion::render (Evoral::EventSink& dst, /* dump pulls from zero to infinity ... */ - if (!_position.val().zero()) { + if (!position().zero()) { /* we are starting the read from before the start of the region */ internal_offset = timecnt_t (Temporal::BeatTime); } else { /* we are starting the read from after the start of the region */ - internal_offset = timecnt_t (-_position.val()); + internal_offset = timecnt_t (-position()); } if (internal_offset >= _length) { diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 2b339ade7d..3daed2cca9 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -71,9 +71,9 @@ namespace ARDOUR { PBD::PropertyDescriptor valid_transients; PBD::PropertyDescriptor start; PBD::PropertyDescriptor length; - PBD::PropertyDescriptor position; PBD::PropertyDescriptor beat; PBD::PropertyDescriptor sync_position; + PBD::PropertyDescriptor position; PBD::PropertyDescriptor layer; PBD::PropertyDescriptor ancestral_start; PBD::PropertyDescriptor ancestral_length; @@ -123,10 +123,10 @@ Region::make_property_quarks () DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for start = %1\n", Properties::start.property_id)); Properties::length.property_id = g_quark_from_static_string (X_("length")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length = %1\n", Properties::length.property_id)); - Properties::position.property_id = g_quark_from_static_string (X_("position")); - DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for position = %1\n", Properties::position.property_id)); Properties::beat.property_id = g_quark_from_static_string (X_("beat")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for beat = %1\n", Properties::beat.property_id)); + Properties::position.property_id = g_quark_from_static_string (X_("position")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for position = %1\n", Properties::position.property_id)); Properties::sync_position.property_id = g_quark_from_static_string (X_("sync-position")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for sync-position = %1\n", Properties::sync_position.property_id)); Properties::layer.property_id = g_quark_from_static_string (X_("layer")); @@ -168,7 +168,6 @@ Region::register_properties () add_property (_valid_transients); add_property (_start); add_property (_length); - add_property (_position); add_property (_sync_position); add_property (_ancestral_start); add_property (_ancestral_length); @@ -186,7 +185,6 @@ Region::register_properties () , _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))) \ - , _position (Properties::position, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0)) \ , _sync_position (Properties::sync_position, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))) \ , _transient_user_start (0) \ , _transient_analysis_start (0) \ @@ -217,7 +215,6 @@ Region::register_properties () , _valid_transients (Properties::valid_transients, other->_valid_transients) \ , _start(Properties::start, other->_start) \ , _length(Properties::length, other->_length) \ - , _position(Properties::position, other->_position) \ , _sync_position(Properties::sync_position, other->_sync_position) \ , _user_transients (other->_user_transients) \ , _transient_user_start (other->_transient_user_start) \ @@ -297,7 +294,6 @@ Region::Region (boost::shared_ptr other) /* override state that may have been incorrectly inherited from the other region */ - _position = other->_position; _locked = false; _whole_file = false; _hidden = false; @@ -364,7 +360,7 @@ Region::Region (boost::shared_ptr other, timecnt_t const & offset) use_sources (other->_sources); set_master_sources (other->_master_sources); - _position = other->_position.val() + offset; + _length.call().set_position (other->position() + offset); _start = other->_start.val() + offset; /* if the other region had a distinct sync point @@ -473,7 +469,7 @@ Region::set_length (timecnt_t const & len) * length impossible. */ - if (timepos_t::max (len.time_domain()).earlier (len) < _position) { + if (timepos_t::max (len.time_domain()).earlier (len) < position()) { return; } @@ -538,7 +534,7 @@ Region::at_natural_position () const boost::shared_ptr whole_file_region = get_parent(); if (whole_file_region) { - if (_position == whole_file_region->position() + _start) { + if (position() == whole_file_region->position() + _start) { return true; } } @@ -569,17 +565,18 @@ Region::special_set_position (timepos_t const & pos) * a way to store its "natural" or "captured" position. */ - _position = pos; + _length.call().set_position (pos); } void Region::set_position_time_domain (Temporal::TimeDomain ps) { - if (_position.val().time_domain() != ps) { + if (_length.val().time_domain() != ps) { boost::shared_ptr pl (playlist()); - _position.call().set_time_domain (ps); +#warning NUTEMPO need to set ALL of length to new TD + //_length.val().set_time_domain (ps); send_change (Properties::time_domain); } @@ -606,7 +603,7 @@ Region::update_after_tempo_map_change (bool send) * change */ - if (_position.val().time_domain() == Temporal::AudioTime) { + if (_length.val().time_domain() == Temporal::AudioTime) { return; } @@ -675,11 +672,11 @@ Region::set_position_internal (timepos_t const & pos) * (see Region::set_position), so we must always set this up so that * e.g. Playlist::notify_region_moved doesn't use an out-of-date last_position. */ - _last_position = _position; - _last_length.set_position (_position); + _last_position = position(); + _last_length.set_position (_last_position); - if (_position != pos) { - _position = pos; + 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); @@ -688,9 +685,9 @@ Region::set_position_internal (timepos_t const & pos) * * XXX is this the right thing to do? */ - if (timepos_t::max (_length.val().time_domain()).earlier (_length) < _position) { + if (timepos_t::max (_length.val().time_domain()).earlier (_length) < position()) { _last_length = _length; - _length = _position.call().distance (timepos_t::max(_position.val().time_domain())); + _length = position().distance (timepos_t::max (position().time_domain())); } } } @@ -707,8 +704,9 @@ Region::set_initial_position (timepos_t const & pos) return; } - if (_position != pos) { - _position = pos; + if (position() != pos) { + + _length.call().set_position (pos); /* check that the new _position wouldn't make the current * length impossible - if so, change the length. @@ -716,15 +714,15 @@ Region::set_initial_position (timepos_t const & pos) * XXX is this the right thing to do? */ - if (timepos_t::max (_length.val().time_domain()).earlier (_length) < _position) { + if (timepos_t::max (_length.val().time_domain()).earlier (_length) < position()) { _last_length = _length; - _length = _position.call().distance (timepos_t::max (_position.val().time_domain())); + _length = position().distance (timepos_t::max (position().time_domain())); } recompute_position_from_time_domain (); /* ensure that this move doesn't cause a range move */ - _last_position = _position; - _last_length.set_position (_position); + _last_position = position(); + _last_length.set_position (position()); } @@ -745,7 +743,7 @@ Region::nudge_position (timecnt_t const & n) return; } - timepos_t new_position = _position; + timepos_t new_position = position(); if (n.positive()) { if (position() > timepos_t::max (n.time_domain()).earlier (n)) { @@ -755,7 +753,7 @@ Region::nudge_position (timecnt_t const & n) } } else { if (position() < -n) { - new_position = timepos_t (_position.val().time_domain()); + new_position = timepos_t (position().time_domain()); } else { new_position += n; } @@ -917,8 +915,8 @@ Region::modify_end (timepos_t const & new_endpoint, bool reset_fade) return; } - if (new_endpoint > _position) { - trim_to_internal (_position, position().distance (new_endpoint)); + if (new_endpoint > position()) { + trim_to_internal (position(), position().distance (new_endpoint)); if (reset_fade) { _left_of_split = true; } @@ -1007,7 +1005,7 @@ Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) if (position() != pos) { if (!property_changes_suspended()) { - _last_position = _position; + _last_position = position(); } set_position_internal (pos); what_changed.add (Properties::position); @@ -1393,7 +1391,7 @@ Region::suspend_property_changes () { Stateful::suspend_property_changes (); _last_length = _length; - _last_position = _position; + _last_position = position(); } void @@ -1454,7 +1452,7 @@ bool Region::layer_and_time_equivalent (boost::shared_ptr other) const { return _layer == other->_layer && - _position == other->_position && + position() == other->position() && _length == other->_length; } @@ -1462,7 +1460,7 @@ bool Region::exact_equivalent (boost::shared_ptr other) const { return _start == other->_start && - _position == other->_position && + position() == other->position() && _length == other->_length; } @@ -1967,7 +1965,7 @@ Region::set_start_internal (timecnt_t const & s) timepos_t Region::earliest_possible_position () const { - if (start() > timecnt_t (_position, timepos_t())) { + if (start() > timecnt_t (position(), timepos_t())) { return timepos_t::from_superclock (0); } else { return source_position(); @@ -1996,7 +1994,7 @@ Region::latest_possible_sample () const Temporal::TimeDomain Region::position_time_domain() const { - return _position.val().time_domain(); + return position().time_domain(); } timepos_t @@ -2005,14 +2003,14 @@ Region::end() const /* one day we might want to enforce _position, _start and _length (or some combination thereof) all being in the same time domain. */ - return _position.val() + _length.val(); + return position() + _length.val(); } timepos_t Region::source_position () const { /* this is the position of the start of the source, in absolute time */ - return _position.val().earlier (_start.val()); + return position().earlier (_start.val()); } Temporal::Beats @@ -2033,7 +2031,7 @@ Region::source_beats_to_absolute_beats (Temporal::Beats beats) const Temporal::timepos_t Region::region_beats_to_absolute_time (Temporal::Beats beats) const { - return _position.val() + timepos_t (beats); + return position() + timepos_t (beats); } Temporal::timepos_t @@ -2086,5 +2084,5 @@ Region::region_relative_position (timepos_t const & p) const XXX this seems likely to cause problems. */ - return p.earlier (_position.val()); + return p.earlier (position()); }