From 67de08e78d0fa21fd4108b8cfb9ebfa67e8b9352 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 10 Aug 2020 15:24:09 -0600 Subject: [PATCH] more type changes for various Region related methods, using timepos_t/timeline_t --- libs/ardour/ardour/audioregion.h | 2 +- libs/ardour/ardour/midi_region.h | 13 +------------ libs/ardour/ardour/region.h | 4 ++-- libs/ardour/ardour/region_factory.h | 2 +- libs/ardour/ardour/region_sorters.h | 6 +++--- libs/ardour/audioregion.cc | 4 ++-- libs/ardour/midi_region.cc | 30 +---------------------------- libs/ardour/rb_effect.cc | 2 +- libs/ardour/region.cc | 4 ++-- libs/ardour/region_factory.cc | 6 +++--- libs/ardour/strip_silence.cc | 8 ++++---- 11 files changed, 21 insertions(+), 60 deletions(-) diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 1288255221..57e042521b 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -190,7 +190,7 @@ class LIBARDOUR_API AudioRegion : public Region AudioRegion (boost::shared_ptr); AudioRegion (const SourceList &); AudioRegion (boost::shared_ptr); - AudioRegion (boost::shared_ptr, ARDOUR::MusicSample offset); + AudioRegion (boost::shared_ptr, timecnt_t const & offset); AudioRegion (boost::shared_ptr, const SourceList&); AudioRegion (SourceList &); diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 1957d34680..a5b5bc5637 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -36,13 +36,6 @@ class XMLNode; -namespace ARDOUR { - namespace Properties { - LIBARDOUR_API extern PBD::PropertyDescriptor start_beats; - LIBARDOUR_API extern PBD::PropertyDescriptor length_beats; - } -} - namespace Evoral { template class EventSink; } @@ -113,8 +106,6 @@ class LIBARDOUR_API MidiRegion : public Region boost::shared_ptr model() const; void fix_negative_start (); - double start_beats () const {return _start_beats; } - double length_beats () const {return _length_beats; } void clobber_sources (boost::shared_ptr source); @@ -131,12 +122,10 @@ class LIBARDOUR_API MidiRegion : public Region private: friend class RegionFactory; - PBD::Property _start_beats; - PBD::Property _length_beats; MidiRegion (const SourceList&); MidiRegion (boost::shared_ptr); - MidiRegion (boost::shared_ptr, ARDOUR::MusicSample offset); + MidiRegion (boost::shared_ptr, timecnt_t const & offset); samplecnt_t _read_at (const SourceList&, Evoral::EventSink& dst, samplepos_t position, diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index bb4fdd6f10..5c8e51589c 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -407,13 +407,13 @@ protected: Region (boost::shared_ptr); /** Construct a region from another region, at an offset within that region */ - Region (boost::shared_ptr, timecnt_t start_offset); + Region (boost::shared_ptr, timecnt_t const & start_offset); /** Construct a region as a copy of another region, but with different sources */ Region (boost::shared_ptr, const SourceList&); /** Constructor for derived types only */ - Region (Session& s, timepos_t const & start, timecnt_t 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; diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h index 4c6e718dd6..507f0de786 100644 --- a/libs/ardour/ardour/region_factory.h +++ b/libs/ardour/ardour/region_factory.h @@ -83,7 +83,7 @@ public: /** create a copy of \p other starting at zero within \p other's sources */ static boost::shared_ptr create (boost::shared_ptr other, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0); /** create a copy of \p other starting at \p offset within \p other */ - static boost::shared_ptr create (boost::shared_ptr other, ARDOUR::MusicSample offset, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0); + static boost::shared_ptr create (boost::shared_ptr other, timecnt_t const & offset, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0); /** create a "copy" of \p other but using a different set of sources \p srcs */ static boost::shared_ptr create (boost::shared_ptr other, const SourceList& srcs, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0); diff --git a/libs/ardour/ardour/region_sorters.h b/libs/ardour/ardour/region_sorters.h index 24d3e8e007..13e1a202dc 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->position() < b->position(); + return a->nt_position() < b->nt_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->position() < b->position()) - || (a->layer() == b->layer() && a->position() < b->position()); + (a->layer() < b->layer() && a->nt_position() < b->nt_position()) + || (a->layer() == b->layer() && a->nt_position() < b->nt_position()); } }; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 6e663626d4..619ca7e0b5 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -235,7 +235,7 @@ AudioRegion::init () } /** Constructor for use by derived types only */ -AudioRegion::AudioRegion (Session& s, samplepos_t start, samplecnt_t len, std::string name) +AudioRegion::AudioRegion (Session& s, timecnt_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)))) @@ -282,7 +282,7 @@ AudioRegion::AudioRegion (boost::shared_ptr other) assert (_sources.size() == _master_sources.size()); } -AudioRegion::AudioRegion (boost::shared_ptr other, MusicSample offset) +AudioRegion::AudioRegion (boost::shared_ptr other, timecnt_t const & offset) : Region (other, offset) , AUDIOREGION_COPY_STATE (other) /* As far as I can see, the _envelope's times are relative to region position, and have nothing diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index debbf8f68b..e94d34e8cc 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -67,22 +67,6 @@ namespace ARDOUR { } } -void -MidiRegion::make_property_quarks () -{ - Properties::start_beats.property_id = g_quark_from_static_string (X_("start-beats")); - DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for start-beats = %1\n", Properties::start_beats.property_id)); - Properties::length_beats.property_id = g_quark_from_static_string (X_("length-beats")); - DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length-beats = %1\n", Properties::length_beats.property_id)); -} - -void -MidiRegion::register_properties () -{ - add_property (_start_beats); - add_property (_length_beats); -} - /* Basic MidiRegion constructor (many channels) */ MidiRegion::MidiRegion (const SourceList& srcs) : Region (srcs) @@ -90,7 +74,6 @@ MidiRegion::MidiRegion (const SourceList& srcs) , _length_beats (Properties::length_beats, midi_source(0)->length_beats().to_double()) , _ignore_shift (false) { - register_properties (); midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this)); model_changed (); assert(_name.val().find("/") == string::npos); @@ -103,30 +86,19 @@ MidiRegion::MidiRegion (boost::shared_ptr other) , _length_beats (Properties::length_beats, other->_length_beats) , _ignore_shift (false) { - //update_length_beats (); - register_properties (); - assert(_name.val().find("/") == string::npos); midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this)); model_changed (); } /** Create a new MidiRegion that is part of an existing one */ -MidiRegion::MidiRegion (boost::shared_ptr other, MusicSample offset) +MidiRegion::MidiRegion (boost::shared_ptr other, timecnt_t const & offset) : Region (other, offset) , _start_beats (Properties::start_beats, other->_start_beats) , _length_beats (Properties::length_beats, other->_length_beats) , _ignore_shift (false) { - register_properties (); - - const double offset_quarter_note = _session.tempo_map().exact_qn_at_sample (other->_position + offset.sample, offset.division) - other->_quarter_note; - if (offset.sample != 0) { - _start_beats = other->_start_beats + offset_quarter_note; - _length_beats = other->_length_beats - offset_quarter_note; - } - assert(_name.val().find("/") == string::npos); midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this)); model_changed (); diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 261bd3032f..872a1c548c 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -361,7 +361,7 @@ RBEffect::run (boost::shared_ptr r, Progress* progress) * stretch this time around to get its new length. this is a non-music based edit atm. */ #warning NUTEMPO FIXME should use (*x)->position() sa 2nd arg also needs to figure out units for first arg - (*x)->set_length (timecnt_t (samplepos_t ((*x)->length_samples () * tsr.time_fraction), (*x)->position_samples())); + (*x)->set_length (timecnt_t (samplepos_t ((*x)->length_samples () * tsr.time_fraction), (*x)->position_sample())); } /* stretch region gain envelope */ diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 9ddd8594fa..668bf4bd61 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -254,7 +254,7 @@ Region::register_properties () , _contents (Properties::contents, other->_contents) /* derived-from-derived constructor (no sources in constructor) */ -Region::Region (Session& s, timepos_t const & start, timecnt_t 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) @@ -355,7 +355,7 @@ Region::Region (boost::shared_ptr other) * the start within \a other is given by \a offset * (i.e. relative to the start of \a other's sources, the start is \a offset + \a other.start() */ -Region::Region (boost::shared_ptr other, timecnt_t offset) +Region::Region (boost::shared_ptr other, timecnt_t const & offset) : SessionObject(other->session(), other->name()) , _type (other->data_type()) , REGION_COPY_STATE (other) diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index ed0ce6cf49..83e784b9eb 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -59,7 +59,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce, bo boost::shared_ptr mr; if ((ar = boost::dynamic_pointer_cast (region)) != 0) { - ret = boost::shared_ptr (new AudioRegion (ar, MusicSample (0, 0))); + ret = boost::shared_ptr (new AudioRegion (ar, timecnt_t (superclock_t (0), timepos_t (superclock_t (0))))); } else if ((mr = boost::dynamic_pointer_cast (region)) != 0) { if (mr->session ().config.get_midi_copy_is_fork () || fork) { @@ -75,7 +75,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce, bo source->set_ancestor_name (mr->sources ().front ()->name ()); ret = mr->clone (source, tl); } else { - ret = boost::shared_ptr (new MidiRegion (mr, MusicSample (0, 0))); + ret = boost::shared_ptr (new MidiRegion (mr, timecnt_t (Temporal::Beats (), timepos_t (Temporal::Beats())))); } } else { @@ -148,7 +148,7 @@ RegionFactory::create (boost::shared_ptr region, const PropertyList& pli } boost::shared_ptr -RegionFactory::create (boost::shared_ptr region, MusicSample offset, const PropertyList& plist, bool announce, ThawList* tl) +RegionFactory::create (boost::shared_ptr region, timecnt_t const & offset, const PropertyList& plist, bool announce, ThawList* tl) { boost::shared_ptr ret; boost::shared_ptr other_a; diff --git a/libs/ardour/strip_silence.cc b/libs/ardour/strip_silence.cc index 087ed75adf..a2e8f543c2 100644 --- a/libs/ardour/strip_silence.cc +++ b/libs/ardour/strip_silence.cc @@ -117,10 +117,10 @@ StripSilence::run (boost::shared_ptr r, Progress* progress) plist.add (Properties::length, i->second - i->first); plist.add (Properties::position, r->position_sample() + (i->first - r->start_sample())); -#warning NUTEMPO FIXME need new constructors etc. -// copy = boost::dynamic_pointer_cast ( -// RegionFactory::create (region, MusicSample (i->first - r->start(), 0), plist) -// ); +#warning NUTEMPO are these arguments samples or superclocks? + const timecnt_t offset (i->first - r->start_sample(), timepos_t (i->first)); + + copy = boost::dynamic_pointer_cast (RegionFactory::create (region, offset, plist)); copy->set_name (RegionFactory::new_region_name (region->name ()));