From 82e84e6b924f751a0405701649d0549b27ec8c3a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 30 Nov 2020 10:59:08 -0700 Subject: [PATCH] change all Region::nt_*() methods to names without the nt_ prefix (library version) --- libs/ardour/ardour/region.h | 22 ++-- libs/ardour/ardour/region_sorters.h | 6 +- libs/ardour/audio_playlist.cc | 20 ++-- libs/ardour/audioregion.cc | 4 +- libs/ardour/auditioner.cc | 6 +- libs/ardour/filter.cc | 6 +- libs/ardour/lua_api.cc | 2 +- libs/ardour/luabindings.cc | 6 +- libs/ardour/midi_playlist.cc | 14 +-- libs/ardour/midi_region.cc | 4 +- libs/ardour/midi_stretch.cc | 2 +- libs/ardour/playlist.cc | 174 +++++++++++++--------------- libs/ardour/rb_effect.cc | 2 +- libs/ardour/region.cc | 82 ++++++------- libs/ardour/session.cc | 2 +- libs/ardour/session_state.cc | 4 +- 16 files changed, 173 insertions(+), 183 deletions(-) diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 4fea756736..3d341b8acc 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -118,11 +118,11 @@ public: * LENGTH: number of samples the region represents */ - timepos_t nt_position () const { return _position.val(); } - timecnt_t nt_start () const { return _start.val(); } - timecnt_t nt_length () const { return _length.val(); } - timepos_t nt_end() const; - timepos_t nt_last() const { return nt_end().decrement(); } + timepos_t position () const { return _position.val(); } + timecnt_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(); } timepos_t source_position () const; timepos_t source_relative_position (Temporal::timepos_t const &) const; @@ -182,7 +182,7 @@ public: } Temporal::TimeRange range () const { - return Temporal::TimeRange (nt_position(), nt_position() + nt_length()); + return Temporal::TimeRange (position(), position() + length()); } bool hidden () const { return _hidden; } @@ -212,7 +212,7 @@ public: } bool covers (timepos_t const & pos) const { - return nt_position() <= pos && pos <= nt_last(); + return position() <= pos && pos <= nt_last(); } /** @return coverage of this region with the given range; @@ -282,11 +282,11 @@ public: Temporal::timepos_t region_beats_to_absolute_time(Temporal::Beats beats) const; /** Convert a timestamp in beats into timepos_t (both relative to region position) */ Temporal::timepos_t region_beats_to_region_time (Temporal::Beats beats) const { - return timepos_t (nt_position().distance (region_beats_to_absolute_time (beats))); + return timepos_t (position().distance (region_beats_to_absolute_time (beats))); } /** Convert a timestamp in beats relative to region position into beats relative to source start */ Temporal::Beats region_beats_to_source_beats (Temporal::Beats beats) const { - return nt_position().distance (region_beats_to_absolute_time (beats)).beats (); + return position().distance (region_beats_to_absolute_time (beats)).beats (); } /** Convert a distance within a region to beats relative to region position */ Temporal::Beats region_distance_to_region_beats (Temporal::timecnt_t const &) const; @@ -299,13 +299,13 @@ public: /** Convert a timestamp in beats measured from source start into region-relative samples */ Temporal::timepos_t source_beats_to_region_time(Temporal::Beats beats) const { - return timepos_t (nt_position().distance (source_beats_to_absolute_time (beats))); + return timepos_t (position().distance (source_beats_to_absolute_time (beats))); } /** Convert a timestamp in absolute time to beats measured from source start*/ Temporal::Beats absolute_time_to_source_beats(Temporal::timepos_t const &) const; Temporal::Beats absolute_time_to_region_beats (Temporal::timepos_t const & b) const { - return b.distance (nt_position()).beats (); + return b.distance (position()).beats (); } int apply (Filter &, Progress* progress = 0); diff --git a/libs/ardour/ardour/region_sorters.h b/libs/ardour/ardour/region_sorters.h index 13e1a202dc..24d3e8e007 100644 --- a/libs/ardour/ardour/region_sorters.h +++ b/libs/ardour/ardour/region_sorters.h @@ -26,7 +26,7 @@ namespace ARDOUR { struct LIBARDOUR_API RegionSortByPosition { bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - return a->nt_position() < b->nt_position(); + return a->position() < b->position(); } }; @@ -44,8 +44,8 @@ struct LIBARDOUR_API RegionSortByLayer { struct LIBARDOUR_API RegionSortByLayerAndPosition { bool operator() (boost::shared_ptr a, boost::shared_ptr b) { return - (a->layer() < b->layer() && a->nt_position() < b->nt_position()) - || (a->layer() == b->layer() && a->nt_position() < b->nt_position()); + (a->layer() < b->layer() && a->position() < b->position()) + || (a->layer() == b->layer() && a->position() < b->position()); } }; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 70b26a6fc2..9ce317f33a 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -108,21 +108,21 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr other, time } case Temporal::OverlapStart: { - if (timepos_t (end) > region->nt_position() + region->fade_in()->back()->when) { + if (timepos_t (end) > region->position() + region->fade_in()->back()->when) { fade_in = region->fade_in()->back()->when.samples(); //end is after fade-in, preserve the fade-in } - if (timepos_t (end) >= region->nt_end().earlier (region->fade_out()->back()->when)) { + if (timepos_t (end) >= region->end().earlier (region->fade_out()->back()->when)) { fade_out = region->fade_out()->back()->when.earlier (timepos_t (region->last_sample() - end)).samples(); //end is inside the fadeout, preserve the fades endpoint } break; } case Temporal::OverlapEnd: { - if (start < region->nt_end().earlier (region->fade_out()->back()->when)) { //start is before fade-out, preserve the fadeout + if (start < region->end().earlier (region->fade_out()->back()->when)) { //start is before fade-out, preserve the fadeout fade_out = region->fade_out()->back()->when.samples(); } - if (start < region->nt_position() + region->fade_in()->back()->when) { - fade_in = region->fade_in()->back()->when.earlier (start.distance (region->nt_position())).samples(); //end is inside the fade-in, preserve the fade-in endpoint + if (start < region->position() + region->fade_in()->back()->when) { + fade_in = region->fade_in()->back()->when.earlier (start.distance (region->position())).samples(); //end is inside the fade-in, preserve the fade-in endpoint } break; } @@ -153,7 +153,7 @@ struct ReadSorter { return a->layer() > b->layer(); } - return a->nt_position() < b->nt_position(); + return a->position() < b->position(); } }; @@ -285,9 +285,9 @@ AudioPlaylist::dump () const for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) { r = *i; cerr << " " << r->name() << " @ " << r << " [" - << r->nt_start() << "+" << r->nt_length() + << r->start() << "+" << r->length() << "] at " - << r->nt_position() + << r->position() << " on layer " << r->layer () << endl; @@ -467,7 +467,7 @@ AudioPlaylist::pre_uncombine (vector >& originals, boo original region. */ - if (cr->fade_in()->back()->when <= ar->nt_length()) { + if (cr->fade_in()->back()->when <= ar->length()) { /* don't do this if the fade is longer than the * region */ @@ -481,7 +481,7 @@ AudioPlaylist::pre_uncombine (vector >& originals, boo original region. */ - if (cr->fade_out()->back()->when <= ar->nt_length()) { + if (cr->fade_out()->back()->when <= ar->length()) { /* don't do this if the fade is longer than the * region */ diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 7efe67895d..9f464e2007 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1948,7 +1948,7 @@ AudioRegion::find_silence (Sample threshold, samplecnt_t min_length, samplecnt_t Temporal::Range AudioRegion::body_range () const { - return Temporal::Range ((nt_position() + _fade_in->back()->when).increment(), nt_end().earlier (_fade_out->back()->when)); + return Temporal::Range ((position() + _fade_in->back()->when).increment(), end().earlier (_fade_out->back()->when)); } boost::shared_ptr @@ -1966,7 +1966,7 @@ AudioRegion::get_single_other_xfade_region (bool start) const boost::shared_ptr rl; if (start) { - rl = pl->regions_at (nt_position()); + rl = pl->regions_at (position()); } else { rl = pl->regions_at (nt_last()); } diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 2c1f3c8976..fb713d8a75 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -335,7 +335,7 @@ Auditioner::audition_region (boost::shared_ptr region) _midi_audition = true; the_region.reset(); - _import_position = region->nt_position(); + _import_position = region->position(); /* copy it */ midi_region = (boost::dynamic_pointer_cast (RegionFactory::create (region, false))); @@ -384,10 +384,10 @@ Auditioner::audition_region (boost::shared_ptr region) timepos_t offset; if (_midi_audition) { - length = midi_region->nt_length(); + length = midi_region->length(); offset = _import_position + midi_region->sync_offset (dir); } else { - length = the_region->nt_length(); + length = the_region->length(); offset = the_region->sync_offset (dir); } diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index 5067e5013d..c508fa6a65 100644 --- a/libs/ardour/filter.cc +++ b/libs/ardour/filter.cc @@ -121,7 +121,7 @@ Filter::finish (boost::shared_ptr region, SourceList& nsrcs, string regi boost::shared_ptr smfs = boost::dynamic_pointer_cast(*si); if (smfs) { - smfs->set_natural_position (region->nt_position()); + smfs->set_natural_position (region->position()); smfs->flush (); } @@ -140,10 +140,10 @@ Filter::finish (boost::shared_ptr region, SourceList& nsrcs, string regi PropertyList plist; plist.add (Properties::start, std::numeric_limits::min()); - plist.add (Properties::length, region->nt_length()); + plist.add (Properties::length, region->length()); plist.add (Properties::name, region_name); plist.add (Properties::whole_file, true); - plist.add (Properties::position, region->nt_position()); + plist.add (Properties::position, region->position()); boost::shared_ptr r = RegionFactory::create (nsrcs, plist); diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index 0cf23a0aea..4b0fb8697c 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -1233,7 +1233,7 @@ LuaAPI::Rubberband::finalize () ar->set_ancestral_data (timecnt_t (_read_start), timecnt_t (_read_len), _stretch_ratio, _pitch_ratio); ar->set_master_sources (_region->master_sources ()); - ar->set_length (ar->nt_length () * _stretch_ratio); // XXX + ar->set_length (ar->length () * _stretch_ratio); // XXX if (_stretch_ratio != 1.0) { // TODO: apply mapping ar->envelope ()->x_scale (_stretch_ratio); diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 01fd55778c..009e602d0c 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -1252,9 +1252,9 @@ LuaBindings::common (lua_State* L) .addFunction ("playlist", &Region::playlist) .addFunction ("set_name", &Region::set_name) /* properties */ - .addFunction ("position", &Region::nt_position) - .addFunction ("start", &Region::nt_start) - .addFunction ("length", &Region::nt_length) + .addFunction ("position", &Region::position) + .addFunction ("start", &Region::start) + .addFunction ("length", &Region::length) .addFunction ("layer", &Region::layer) .addFunction ("data_type", &Region::data_type) .addFunction ("stretch", &Region::stretch) diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 3d3602e5df..489aa5ffd9 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -149,9 +149,9 @@ MidiPlaylist::dump () const for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) { r = *i; cerr << " " << r->name() << " @ " << r << " [" - << r->nt_start() << "+" << r->nt_length() + << r->start() << "+" << r->length() << "] at " - << r->nt_position() + << r->position() << " on layer " << r->layer () << endl; @@ -202,7 +202,7 @@ MidiPlaylist::_split_region (boost::shared_ptr region, timepos_t const & return; } - if (region->nt_position() == playlist_position || + if (region->position() == playlist_position || region->nt_last() == playlist_position) { return; } @@ -219,8 +219,8 @@ MidiPlaylist::_split_region (boost::shared_ptr region, timepos_t const & string before_name; string after_name; - const timecnt_t before = region->nt_position().distance (playlist_position); - const timecnt_t after = region->nt_length() - before; + const timecnt_t before = region->position().distance (playlist_position); + const timecnt_t after = region->length() - before; RegionFactory::region_name (before_name, region->name(), false); @@ -255,8 +255,8 @@ MidiPlaylist::_split_region (boost::shared_ptr region, timepos_t const & right = RegionFactory::create (region, before, plist, true, &thawlist); } - add_region_internal (left, region->nt_position(), thawlist); - add_region_internal (right, region->nt_position() + before, thawlist); + add_region_internal (left, region->position(), thawlist); + add_region_internal (right, region->position() + before, thawlist); remove_region_internal (region, thawlist); } diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 36ef17b38e..cd62fb8cff 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -338,7 +338,7 @@ MidiRegion::render (Evoral::EventSink& dst, lm, // source lock dst, // destination buffer this->source_position(), // start position of the source in session samples - this->nt_start() + internal_offset, // where to start reading in the source + this->start() + internal_offset, // where to start reading in the source _length, // length to read 0, cursor, @@ -350,7 +350,7 @@ MidiRegion::render (Evoral::EventSink& dst, * Note-Off's get inserted at the end of the region */ - const timepos_t end = source_position() + nt_start() + internal_offset + nt_length(); + const timepos_t end = source_position() + start() + internal_offset + length(); tracker.resolve_notes (dst, end.samples()); return 0; diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index c44e283386..ed1367a951 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -119,7 +119,7 @@ MidiStretch::run (boost::shared_ptr r, Progress*) /* non-musical */ #warning NUTEMPO FIXME do we still need this? - results[0]->set_length (r->nt_length().operator* ( _request.time_fraction)); + results[0]->set_length (r->length().operator* ( _request.time_fraction)); return ret; } diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 0cf6cc66a2..772eb93838 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -185,7 +185,7 @@ Playlist::Playlist (boost::shared_ptr other, string namestr, boo in_set_state++; for (list >::iterator x = tmp.begin(); x != tmp.end(); ++x) { - add_region_internal ((*x), (*x)->nt_position(), thawlist); + add_region_internal ((*x), (*x)->position(), thawlist); } thawlist.release (); @@ -236,7 +236,7 @@ Playlist::Playlist (boost::shared_ptr other, timepos_t const & s continue; case Temporal::OverlapInternal: - offset = region->nt_position().distance (start); + offset = region->position().distance (start); position = 0; len = timecnt_t (cnt); break; @@ -244,19 +244,19 @@ Playlist::Playlist (boost::shared_ptr other, timepos_t const & s case Temporal::OverlapStart: offset = 0; position = region->source_position(); - len = region->nt_position().distance (end); + len = region->position().distance (end); break; case Temporal::OverlapEnd: - offset = region->nt_position().distance (start); + offset = region->position().distance (start); position = 0; - len = region->nt_length() - offset; + len = region->length() - offset; break; case Temporal::OverlapExternal: offset = 0; position = region->source_position(); - len = region->nt_length(); + len = region->length(); break; } @@ -264,7 +264,7 @@ Playlist::Playlist (boost::shared_ptr other, timepos_t const & s PropertyList plist; - plist.add (Properties::start, region->nt_start() + offset); + plist.add (Properties::start, region->start() + offset); plist.add (Properties::length, len); plist.add (Properties::name, new_name); plist.add (Properties::layer, region->layer ()); @@ -499,7 +499,7 @@ Playlist::notify_region_removed (boost::shared_ptr r) void Playlist::notify_region_moved (boost::shared_ptr r) { - Temporal::RangeMove move (r->nt_last (), r->nt_length (), r->nt_position ()); + Temporal::RangeMove move (r->nt_last (), r->length (), r->position ()); if (holding_state ()) { pending_range_moves.push_back (move); @@ -514,12 +514,12 @@ Playlist::notify_region_moved (boost::shared_ptr r) void Playlist::notify_region_start_trimmed (boost::shared_ptr r) { - if (r->nt_position() >= r->last_position()) { + if (r->position() >= r->last_position()) { /* trimmed shorter */ return; } - Temporal::Range const extra (r->nt_position(), r->last_position()); + Temporal::Range const extra (r->position(), r->last_position()); if (holding_state ()) { pending_region_extensions.push_back (extra); @@ -534,11 +534,11 @@ Playlist::notify_region_start_trimmed (boost::shared_ptr r) void Playlist::notify_region_end_trimmed (boost::shared_ptr r) { - if (r->nt_length() < r->last_length()) { + if (r->length() < r->last_length()) { /* trimmed shorter */ } - Temporal::Range const extra (r->nt_position() + r->last_length(), r->nt_position() + r->nt_length()); + Temporal::Range const extra (r->position() + r->last_length(), r->position() + r->length()); if (holding_state ()) { pending_region_extensions.push_back (extra); @@ -690,7 +690,7 @@ Playlist::add_region (boost::shared_ptr region, timepos_t const & positi timepos_t pos = position; if (times == 1 && auto_partition) { - partition_internal (pos - 1, (pos + region->nt_length ()), true, rlock.thawlist); + partition_internal (pos - 1, (pos + region->length ()), true, rlock.thawlist); for (RegionList::iterator i = rlock.thawlist.begin (); i != rlock.thawlist.end (); ++i) { _session.add_command (new StatefulDiffCommand (*i)); } @@ -699,7 +699,7 @@ Playlist::add_region (boost::shared_ptr region, timepos_t const & positi if (itimes >= 1) { add_region_internal (region, pos, rlock.thawlist); set_layer (region, DBL_MAX); - pos += region->nt_length(); + pos += region->length(); --itimes; } @@ -711,20 +711,20 @@ Playlist::add_region (boost::shared_ptr region, timepos_t const & positi boost::shared_ptr copy = RegionFactory::create (region, true, false, &rlock.thawlist); add_region_internal (copy, pos, rlock.thawlist); set_layer (copy, DBL_MAX); - pos += region->nt_length(); + pos += region->length(); } timecnt_t length; if (floor (times) != times) { - length = region->nt_length() * (times - floor (times)); + length = region->length() * (times - floor (times)); string name; RegionFactory::region_name (name, region->name (), false); { PropertyList plist; - plist.add (Properties::start, region->nt_start()); + plist.add (Properties::start, region->start()); plist.add (Properties::length, length); plist.add (Properties::name, name); plist.add (Properties::layer, region->layer ()); @@ -773,11 +773,6 @@ Playlist::add_region_internal (boost::shared_ptr region, timepos_t const regions.insert (upper_bound (regions.begin (), regions.end (), region, cmp), region); all_regions.insert (region); -<<<<<<< HEAD -======= - possibly_splice_unlocked (position, region->nt_length(), region, thawlist); - ->>>>>>> 42145ee744 (libardour: conversion to use timeline types (mega-commit)) if (!holding_state ()) { /* layers get assigned from XML state, and are not reset during undo/redo */ relayer (); @@ -807,13 +802,6 @@ Playlist::replace_region (boost::shared_ptr old, boost::shared_ptrlayer ()); -<<<<<<< HEAD -======= - - _splicing = old_sp; - - possibly_splice_unlocked (pos, old->nt_length() - newr->nt_length(), boost::shared_ptr(), rlock.thawlist); ->>>>>>> 42145ee744 (libardour: conversion to use timeline types (mega-commit)) } void @@ -837,8 +825,9 @@ Playlist::remove_region_internal (boost::shared_ptr region, ThawList& th for (i = regions.begin (); i != regions.end (); ++i) { if (*i == region) { - timepos_t pos = (*i)->nt_position(); - timecnt_t distance = (*i)->nt_length(); + + timepos_t pos = (*i)->position(); + timecnt_t distance = (*i)->length(); regions.erase (i); @@ -978,7 +967,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo current = *i; - if (start < current->nt_position() && end >= current->nt_last()) { + if (start < current->position() && end >= current->nt_last()) { if (cutting) { remove_region_internal (current, thawlist); @@ -992,7 +981,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo * so catch this special case. */ - if (end < current->nt_position()) { + if (end < current->position()) { continue; } @@ -1000,7 +989,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo continue; } - pos1 = current->nt_position(); + pos1 = current->position(); pos2 = start; pos3 = end; pos4 = current->nt_last (); @@ -1026,7 +1015,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo PropertyList plist; - plist.add (Properties::start, current->nt_start() + pos1.distance (pos2)); + plist.add (Properties::start, current->start() + pos1.distance (pos2)); plist.add (Properties::length, pos2.distance (pos3)); plist.add (Properties::name, new_name); plist.add (Properties::layer, current->layer ()); @@ -1049,7 +1038,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo PropertyList plist; - plist.add (Properties::start, current->nt_start() + pos1.distance (pos3)); + plist.add (Properties::start, current->start() + pos1.distance (pos3)); plist.add (Properties::length, pos3.distance (pos4)); plist.add (Properties::name, new_name); plist.add (Properties::layer, current->layer ()); @@ -1087,7 +1076,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo PropertyList plist; - plist.add (Properties::start, current->nt_start() + pos1.distance (pos2)); + plist.add (Properties::start, current->start() + pos1.distance (pos2)); plist.add (Properties::length, pos2.distance (pos4)); plist.add (Properties::name, new_name); plist.add (Properties::layer, current->layer ()); @@ -1129,7 +1118,7 @@ Playlist::partition_internal (timepos_t const & start, timepos_t const & end, bo PropertyList plist; - plist.add (Properties::start, current->nt_start()); + plist.add (Properties::start, current->start()); plist.add (Properties::length, pos1.distance (pos3)); plist.add (Properties::name, new_name); plist.add (Properties::layer, current->layer ()); @@ -1292,8 +1281,8 @@ Playlist::paste (boost::shared_ptr other, timepos_t const & position, the ordering they had in the original playlist. */ - add_region_internal (copy_of_region, (*i)->position () + pos, rl1.thawlist, sub_num); - set_layer (copy_of_region, copy_of_region->layer () + top); + add_region_internal (copy_of_region, (*i)->position() + pos, rl1.thawlist); + set_layer (copy_of_region, copy_of_region->layer() + top); } pos += shift; } @@ -1305,7 +1294,7 @@ Playlist::paste (boost::shared_ptr other, timepos_t const & position, void Playlist::duplicate (boost::shared_ptr region, timepos_t & position, float times) { - duplicate(region, position, region->nt_length(), times); + duplicate(region, position, region->length(), times); } /** @param gap from the beginning of the region to the next beginning */ @@ -1325,14 +1314,14 @@ Playlist::duplicate (boost::shared_ptr region, timepos_t & position, tim } if (floor (times) != times) { - timecnt_t length = region->nt_length() * (times - floor (times)); + timecnt_t length = region->length() * (times - floor (times)); string name; RegionFactory::region_name (name, region->name(), false); { PropertyList plist; - plist.add (Properties::start, region->nt_start()); + plist.add (Properties::start, region->start()); plist.add (Properties::length, length); plist.add (Properties::name, name); @@ -1483,7 +1472,7 @@ Playlist::_split_region (boost::shared_ptr region, timepos_t const & pl return; } - if (region->nt_position() == playlist_position || + if (region->position() == playlist_position || region->nt_last() == playlist_position) { return; } @@ -1491,8 +1480,8 @@ Playlist::_split_region (boost::shared_ptr region, timepos_t const & pl boost::shared_ptr left; boost::shared_ptr right; - timecnt_t before (region->nt_position().distance (playlist_position)); - timecnt_t after (region->nt_length() - before); + timecnt_t before (region->position().distance (playlist_position)); + timecnt_t after (region->length() - before); string before_name; string after_name; @@ -1529,8 +1518,8 @@ Playlist::_split_region (boost::shared_ptr region, timepos_t const & pl right = RegionFactory::create (region, before, plist, true, &thawlist); } - add_region_internal (left, region->nt_position(), thawlist); - add_region_internal (right, region->nt_position() + before, thawlist); + add_region_internal (left, region->position(), thawlist); + add_region_internal (right, region->position() + before, thawlist); remove_region_internal (region, thawlist); } @@ -1562,16 +1551,17 @@ Playlist::SoloSelectedActive () } void +Playlist::ripple_locked (timepos_t const & at, timecnt_t const & distance, RegionList *exclude, ThawList& thawlist) +{ + RegionWriteLock rl (this); + ripple_unlocked (at, distance, exclude, rl.thawlist); +} void -Playlist::ripple_locked (timepos_t const & at, timecnt_t const & distance, RegionList *exclude, ThawList& thawlist) - +Playlist::ripple_unlocked (samplepos_t at, samplecnt_t distance, RegionList* exclude, ThawList& thawlist, bool notify) { - bool changed = false; - - - if (distance == 0 || regions.empty()) { - return false; + if (distance.zero()) { + return; } _rippling = true; @@ -1585,9 +1575,9 @@ Playlist::ripple_locked (timepos_t const & at, timecnt_t const & distance, Regio } } - if ((*i)->nt_position() >= at) { - timepos_t new_pos = (*i)->nt_position() + distance; - timepos_t limit = std::numeric_limits::max().earlier ((*i)->nt_length()); + if ((*i)->position() >= at) { + timepos_t new_pos = (*i)->position() + distance; + timepos_t limit = std::numeric_limits::max().earlier ((*i)->length()); if (new_pos < 0) { new_pos = 0; } else if (new_pos >= limit) { @@ -1638,11 +1628,11 @@ Playlist::region_bounds_changed (const PropertyChange& what_changed, boost::shar timecnt_t delta; if (what_changed.contains (Properties::position)) { - delta = region->last_position().distance (region->nt_position()); + delta = region->last_position().distance (region->position()); } if (what_changed.contains (Properties::length)) { - delta += region->nt_length() - region->last_length(); + delta += region->length() - region->last_length(); } if (holding_state ()) { @@ -1892,7 +1882,7 @@ Playlist::regions_with_start_within (Temporal::Range range) boost::shared_ptr rlist (new RegionList); for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - if ((*i)->nt_position() >= range.start() && (*i)->nt_position() < range.end()) { + if ((*i)->position() >= range.start() && (*i)->position() < range.end()) { rlist->push_back (*i); } } @@ -1949,7 +1939,7 @@ Playlist::find_next_transient (timepos_t const & from, int dir) continue; } } else { - if ((*i)->nt_position() > from) { + if ((*i)->position() > from) { continue; } } @@ -2098,12 +2088,12 @@ Playlist::find_next_region_boundary (timepos_t const & pos, int dir) boost::shared_ptr r = (*i); timecnt_t distance; - if (r->nt_position() > pos) { + if (r->position() > pos) { - distance = pos.distance (r->nt_position()); + distance = pos.distance (r->position()); if (distance < closest) { - ret = r->nt_position (); + ret = r->position (); closest = distance; } } @@ -2134,12 +2124,12 @@ Playlist::find_next_region_boundary (timepos_t const & pos, int dir) } } - if (r->nt_position() < pos) { + if (r->position() < pos) { - distance = r->nt_position().distance (pos); + distance = r->position().distance (pos); if (distance < closest) { - ret = r->nt_position(); + ret = r->position(); closest = distance; } } @@ -2197,7 +2187,7 @@ Playlist::update (const RegionListProperty::ChangeRecord& change) freeze_locked (); /* add the added regions */ for (RegionListProperty::ChangeContainer::const_iterator i = change.added.begin(); i != change.added.end(); ++i) { - add_region_internal ((*i), (*i)->nt_position(), rlock.thawlist); + add_region_internal ((*i), (*i)->position(), rlock.thawlist); } /* remove the removed regions */ for (RegionListProperty::ChangeContainer::const_iterator i = change.removed.begin (); i != change.removed.end (); ++i) { @@ -2292,7 +2282,7 @@ Playlist::set_state (const XMLNode& node, int version) { RegionWriteLock rlock (this); - add_region_internal (region, region->nt_position(), rlock.thawlist); + add_region_internal (region, region->position(), rlock.thawlist); } region->resume_property_changes (); @@ -2422,7 +2412,7 @@ Playlist::_get_extent () const } for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) { - pair const e ((*i)->nt_position(), (*i)->nt_position() + (*i)->nt_length()); + pair const e ((*i)->position(), (*i)->position() + (*i)->length()); if (e.first < ext.first) { ext.first = e.first; } @@ -2506,7 +2496,7 @@ Playlist::setup_layering_indices (RegionList const& regions) struct LaterHigherSort { bool operator () (boost::shared_ptr a, boost::shared_ptr b) { - return a->nt_position() < b->nt_position(); + return a->position() < b->position(); } }; @@ -2535,8 +2525,8 @@ Playlist::relayer () timepos_t end = std::numeric_limits::min(); for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) { - start = min (start, (*i)->nt_position()); - end = max (end, (*i)->nt_position() + (*i)->nt_length()); + start = min (start, (*i)->position()); + end = max (end, (*i)->position() + (*i)->length()); } /* hence the size of each time division */ @@ -2679,22 +2669,22 @@ Playlist::nudge_after (timepos_t const & start, timecnt_t const & distance, bool for (i = regions.begin(); i != regions.end(); ++i) { - if ((*i)->nt_position() >= start) { + if ((*i)->position() >= start) { timepos_t new_pos; if (forwards) { if ((*i)->nt_last() > std::numeric_limits::max().earlier (distance)) { - new_pos = std::numeric_limits::max().earlier ((*i)->nt_length()); + new_pos = std::numeric_limits::max().earlier ((*i)->length()); } else { - new_pos = (*i)->nt_position() + distance; + new_pos = (*i)->position() + distance; } } else { - if ((*i)->nt_position() > distance) { - new_pos = (*i)->nt_position().earlier (distance); + if ((*i)->position() > distance) { + new_pos = (*i)->position().earlier (distance); } else { new_pos = 0; } @@ -2813,9 +2803,9 @@ Playlist::dump () const for (RegionList::const_iterator i = regions.begin (); i != regions.end (); ++i) { r = *i; cerr << " " << r->name() << " [" - << r->nt_start() << "+" << r->nt_length() + << r->start() << "+" << r->length() << "] at " - << r->nt_position() + << r->position() << " on layer " << r->layer () << endl; @@ -2857,24 +2847,24 @@ Playlist::shuffle (boost::shared_ptr region, int dir) timepos_t new_pos; - if ((*next)->nt_position() != region->last_sample() + 1) { + if ((*next)->position() != region->last_sample() + 1) { /* they didn't used to touch, so after shuffle, * just have them swap positions. */ - new_pos = (*next)->nt_position(); + new_pos = (*next)->position(); } else { /* they used to touch, so after shuffle, * make sure they still do. put the earlier * region where the later one will end after * it is moved. */ - new_pos = region->nt_position() + (*next)->nt_length(); + new_pos = region->position() + (*next)->length(); } rlock.thawlist.add (*next); rlock.thawlist.add (region); - (*next)->set_position (region->nt_position()); + (*next)->set_position (region->position()); region->set_position (new_pos); /* avoid a full sort */ @@ -2899,23 +2889,23 @@ Playlist::shuffle (boost::shared_ptr region, int dir) } timepos_t new_pos; - if (region->nt_position() != (*prev)->last_sample() + 1) { + if (region->position() != (*prev)->last_sample() + 1) { /* they didn't used to touch, so after shuffle, * just have them swap positions. */ - new_pos = region->nt_position(); + new_pos = region->position(); } else { /* they used to touch, so after shuffle, * make sure they still do. put the earlier * one where the later one will end after */ - new_pos = (*prev)->nt_position() + region->nt_length(); + new_pos = (*prev)->position() + region->length(); } rlock.thawlist.add (region); rlock.thawlist.add (*prev); - region->set_position ((*prev)->nt_position()); + region->set_position ((*prev)->position()); (*prev)->set_position (new_pos); /* avoid a full sort */ @@ -3014,8 +3004,8 @@ Playlist::find_next_top_layer_position (timepos_t const & t) const copy.sort (RegionSortByPosition ()); for (RegionList::const_iterator i = copy.begin(); i != copy.end(); ++i) { - if ((*i)->nt_position() >= t && (*i)->layer() == top) { - return (*i)->nt_position(); + if ((*i)->position() >= t && (*i)->layer() == top) { + return (*i)->position(); } } @@ -3081,7 +3071,7 @@ Playlist::combine (const RegionList& r) /* make position relative to zero */ - pl->add_region_internal (copied_region, original_region->position().earlier (timecnt_t (earliest_position, earliest_position)), thawlist); + pl->add_region (copied_region, original_region->position().earlier (timecnt_t (earliest_position, earliest_position)), &thawlist); /* use the maximum number of channels for any region */ diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 95ef38471d..6c09a5dcd7 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -360,7 +360,7 @@ RBEffect::run (boost::shared_ptr r, Progress* progress) /* multiply the old (possibly previously stretched) region length by the extra * stretch this time around to get its new length. this is a non-music based edit atm. */ - (*x)->set_length (timecnt_t (tsr.time_fraction * (*x)->length_samples (), (*x)->nt_position())); + (*x)->set_length (timecnt_t (tsr.time_fraction * (*x)->length_samples (), (*x)->position())); } /* stretch region gain envelope */ diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index c107900c50..c2263677b0 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -539,7 +539,7 @@ Region::at_natural_position () const boost::shared_ptr whole_file_region = get_parent(); if (whole_file_region) { - if (_position == whole_file_region->nt_position() + _start) { + if (_position == whole_file_region->position() + _start) { return true; } } @@ -559,7 +559,7 @@ Region::move_to_natural_position () boost::shared_ptr whole_file_region = get_parent(); if (whole_file_region) { - set_position (whole_file_region->nt_position() + _start); + set_position (whole_file_region->position() + _start); } } @@ -738,13 +738,13 @@ Region::nudge_position (timecnt_t const & n) timepos_t new_position = _position; if (n.positive()) { - if (nt_position() > timepos_t::max (n.time_domain()).earlier (n)) { + if (position() > timepos_t::max (n.time_domain()).earlier (n)) { new_position = timepos_t::max (n.time_domain()); } else { new_position += n; } } else { - if (nt_position() < -n) { + if (position() < -n) { new_position = 0; } else { new_position += n; @@ -808,7 +808,7 @@ Region::move_start (timecnt_t const & distance) if (_start > timecnt_t::max() - distance) { new_start = timecnt_t::max(); // makes no sense } else { - new_start = nt_start() + distance; + new_start = start() + distance; } if (!verify_start (new_start)) { @@ -820,7 +820,7 @@ Region::move_start (timecnt_t const & distance) if (_start < -distance) { new_start = 0; } else { - new_start = nt_start() + distance; + new_start = start() + distance; } } @@ -861,16 +861,16 @@ Region::modify_front (timepos_t const & new_position, bool reset_fade) return; } - timepos_t end = nt_end().decrement(); + timepos_t last = end().decrement(); timepos_t source_zero; - if (nt_position() > nt_start()) { + if (position() > start()) { source_zero = source_position (); } else { source_zero = 0; // its actually negative, but this will work for us } - if (new_position < end) { /* can't trim it zero or negative length */ + if (new_position < last) { /* can't trim it zero or negative length */ timecnt_t newlen (_length); timepos_t np = new_position; @@ -880,10 +880,10 @@ Region::modify_front (timepos_t const & new_position, bool reset_fade) np = max (np, source_zero); } - if (np > nt_position()) { - newlen = nt_length() - (nt_position().distance (np)); + if (np > position()) { + newlen = length() - (position().distance (np)); } else { - newlen = nt_length() + (np.distance (nt_position())); + newlen = length() + (np.distance (position())); } trim_to_internal (np, newlen); @@ -908,7 +908,7 @@ Region::modify_end (timepos_t const & new_endpoint, bool reset_fade) } if (new_endpoint > _position) { - trim_to_internal (_position, nt_position().distance (new_endpoint)); + trim_to_internal (_position, position().distance (new_endpoint)); if (reset_fade) { _left_of_split = true; } @@ -943,38 +943,38 @@ Region::trim_to (timepos_t const & position, timecnt_t const & length) } void -Region::trim_to_internal (timepos_t const & position, timecnt_t const & length) +Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len) { - timecnt_t new_start (length.time_domain()); + timecnt_t new_start (len.time_domain()); if (locked()) { return; } - timecnt_t const start_shift = nt_position().distance (position); + timecnt_t const start_shift = position().distance (pos); if (start_shift.positive()) { - if (nt_start() > timecnt_t::max() - start_shift) { + if (start() > timecnt_t::max() - start_shift) { new_start = timecnt_t::max(); } else { - new_start = nt_start() + start_shift; + new_start = start() + start_shift; } } else if (start_shift.negative()) { - if (nt_start() < -start_shift && !can_trim_start_before_source_start ()) { + if (start() < -start_shift && !can_trim_start_before_source_start ()) { new_start = 0; } else { - new_start = nt_start() + start_shift; + new_start = start() + start_shift; } } else { - new_start = nt_start(); + new_start = start(); } timecnt_t ns = new_start; - timecnt_t nl = length; + timecnt_t nl = len; if (!verify_start_and_length (ns, nl)) { return; @@ -982,28 +982,28 @@ Region::trim_to_internal (timepos_t const & position, timecnt_t const & length) PropertyChange what_changed; - if (nt_start() != ns) { + if (start() != ns) { set_start_internal (ns); what_changed.add (Properties::start); } /* Set position before length, otherwise for MIDI regions this bad thing happens: - * 1. we call set_length_internal; length in beats is computed using the region's current + * 1. we call set_length_internal; len in beats is computed using the region's current * (soon-to-be old) position * 2. we call set_position_internal; position is set and length in samples re-computed using * length in beats from (1) but at the new position, which is wrong if the region * straddles a tempo/meter change. */ - if (nt_position() != position) { + if (position() != pos) { if (!property_changes_suspended()) { _last_position = _position; } - set_position_internal (position); + set_position_internal (pos); what_changed.add (Properties::position); } - if (nt_length() != nl) { + if (length() != nl) { if (!property_changes_suspended()) { _last_length = _length; } @@ -1102,7 +1102,7 @@ void Region::set_sync_position (timepos_t const & absolute_pos) { /* position within our file */ - const timecnt_t file_pos = nt_start() + nt_position().distance (absolute_pos); + const timecnt_t file_pos = start() + position().distance (absolute_pos); if (file_pos != _sync_position) { _sync_marked = true; @@ -1178,7 +1178,7 @@ Region::sync_position() const return source_position() + _sync_position; } else { /* if sync has not been marked, use the start of the region */ - return nt_position(); + return position(); } } @@ -1340,8 +1340,8 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c */ if (!_sources.empty() && _type == DataType::AUDIO) { - if ((nt_length().time_domain() == Temporal::AudioTime) && (nt_length() > _sources.front()->length())) { - _length = _sources.front()->length() - nt_start(); + if ((length().time_domain() == Temporal::AudioTime) && (length() > _sources.front()->length())) { + _length = _sources.front()->length() - start(); } } @@ -1430,14 +1430,14 @@ Region::send_change (const PropertyChange& what_changed) bool Region::overlap_equivalent (boost::shared_ptr other) const { - return coverage (other->nt_position(), other->nt_last()) != Temporal::OverlapNone; + return coverage (other->position(), other->nt_last()) != Temporal::OverlapNone; } bool Region::enclosed_equivalent (boost::shared_ptr other) const { - return ((nt_position() >= other->nt_position() && nt_end() <= other->nt_end()) || - (nt_position() <= other->nt_position() && nt_end() >= other->nt_end())); + return ((position() >= other->position() && end() <= other->end()) || + (position() <= other->position() && end() >= other->end())); } bool @@ -1915,12 +1915,12 @@ Region::can_trim () const ct = CanTrim (ct | FrontTrimLater | EndTrimEarlier); - if (nt_start() != 0 || can_trim_start_before_source_start ()) { + if (start() != 0 || can_trim_start_before_source_start ()) { ct = CanTrim (ct | FrontTrimEarlier); } if (!_sources.empty()) { - if ((nt_start() + nt_length()) < _sources.front()->length ()) { + if ((start() + length()) < _sources.front()->length ()) { ct = CanTrim (ct | EndTrimLater); } } @@ -1955,7 +1955,7 @@ Region::set_start_internal (timecnt_t const & s) timepos_t Region::earliest_possible_position () const { - if (nt_start() > timecnt_t (_position, timepos_t())) { + if (start() > timecnt_t (_position, timepos_t())) { return timepos_t::from_superclock (0); } else { return source_position(); @@ -1978,7 +1978,7 @@ Region::latest_possible_sample () const * position, plus the shortest source extent past _start. */ - return (nt_position() + minlen).samples() - 1; + return (position() + minlen).samples() - 1; } Temporal::TimeDomain @@ -1988,7 +1988,7 @@ Region::position_time_domain() const } timepos_t -Region::nt_end() const +Region::end() const { return _position.val() + _length.val(); } @@ -1996,7 +1996,7 @@ Region::nt_end() const Temporal::Beats Region::region_distance_to_region_beats (timecnt_t const & region_relative_offset) const { - return timecnt_t (region_relative_offset, nt_position()).beats (); + return timecnt_t (region_relative_offset, position()).beats (); } Temporal::Beats @@ -2011,7 +2011,7 @@ Region::region_beats_to_absolute_time (Temporal::Beats beats) const /* beats is an additional offset to the start point of the region, from the effective start of the source on the timeline. */ - return source_position() + nt_start () + beats; + return source_position() + start () + beats; } Temporal::timepos_t diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 1c4aae7170..532e944b87 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4417,7 +4417,7 @@ Session::playlist_region_added (boost::weak_ptr w) /* If so, update the session range markers */ if (!in.empty ()) { - maybe_update_session_range (r->nt_position (), r->nt_end ()); + maybe_update_session_range (r->position (), r->end ()); } } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index b998cfa09a..c7f5a08e45 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2322,7 +2322,7 @@ Session::XMLAudioRegionFactory (const XMLNode& node, bool /*full*/) for (SourceList::iterator sx = sources.begin(); sx != sources.end(); ++sx) { boost::shared_ptr sfp = boost::dynamic_pointer_cast (*sx); if (sfp) { - sfp->set_length (region->nt_length().samples()); + sfp->set_length (region->length().samples()); } } } @@ -2391,7 +2391,7 @@ Session::XMLMidiRegionFactory (const XMLNode& node, bool /*full*/) for (SourceList::iterator sx = sources.begin(); sx != sources.end(); ++sx) { boost::shared_ptr sfp = boost::dynamic_pointer_cast (*sx); if (sfp) { - sfp->set_length (region->nt_length().samples()); + sfp->set_length (region->length().samples()); } } }