13
0

more type changes for various Region related methods, using timepos_t/timeline_t

This commit is contained in:
Paul Davis 2020-08-10 15:24:09 -06:00
parent 70d53fda91
commit 67de08e78d
11 changed files with 21 additions and 60 deletions

View File

@ -190,7 +190,7 @@ class LIBARDOUR_API AudioRegion : public Region
AudioRegion (boost::shared_ptr<AudioSource>);
AudioRegion (const SourceList &);
AudioRegion (boost::shared_ptr<const AudioRegion>);
AudioRegion (boost::shared_ptr<const AudioRegion>, ARDOUR::MusicSample offset);
AudioRegion (boost::shared_ptr<const AudioRegion>, timecnt_t const & offset);
AudioRegion (boost::shared_ptr<const AudioRegion>, const SourceList&);
AudioRegion (SourceList &);

View File

@ -36,13 +36,6 @@
class XMLNode;
namespace ARDOUR {
namespace Properties {
LIBARDOUR_API extern PBD::PropertyDescriptor<double> start_beats;
LIBARDOUR_API extern PBD::PropertyDescriptor<double> length_beats;
}
}
namespace Evoral {
template<typename Time> class EventSink;
}
@ -113,8 +106,6 @@ class LIBARDOUR_API MidiRegion : public Region
boost::shared_ptr<const MidiModel> 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<MidiSource> source);
@ -131,12 +122,10 @@ class LIBARDOUR_API MidiRegion : public Region
private:
friend class RegionFactory;
PBD::Property<double> _start_beats;
PBD::Property<double> _length_beats;
MidiRegion (const SourceList&);
MidiRegion (boost::shared_ptr<const MidiRegion>);
MidiRegion (boost::shared_ptr<const MidiRegion>, ARDOUR::MusicSample offset);
MidiRegion (boost::shared_ptr<const MidiRegion>, timecnt_t const & offset);
samplecnt_t _read_at (const SourceList&, Evoral::EventSink<samplepos_t>& dst,
samplepos_t position,

View File

@ -407,13 +407,13 @@ protected:
Region (boost::shared_ptr<const Region>);
/** Construct a region from another region, at an offset within that region */
Region (boost::shared_ptr<const Region>, timecnt_t start_offset);
Region (boost::shared_ptr<const Region>, timecnt_t const & start_offset);
/** Construct a region as a copy of another region, but with different sources */
Region (boost::shared_ptr<const Region>, 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;

View File

@ -83,7 +83,7 @@ public:
/** create a copy of \p other starting at zero within \p other's sources */
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> 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<Region> create (boost::shared_ptr<Region> other, ARDOUR::MusicSample offset, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> 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<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);

View File

@ -26,7 +26,7 @@ namespace ARDOUR {
struct LIBARDOUR_API RegionSortByPosition {
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> 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<Region> a, boost::shared_ptr<Region> 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());
}
};

View File

@ -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<AutomationList> (new AutomationList (Evoral::Parameter(EnvelopeAutomation))))
@ -282,7 +282,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
assert (_sources.size() == _master_sources.size());
}
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, MusicSample offset)
AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> 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

View File

@ -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<const MidiRegion> 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<const MidiRegion> other, MusicSample offset)
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> 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 ();

View File

@ -361,7 +361,7 @@ RBEffect::run (boost::shared_ptr<Region> 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 */

View File

@ -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<const Region> 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<const Region> other, timecnt_t offset)
Region::Region (boost::shared_ptr<const Region> other, timecnt_t const & offset)
: SessionObject(other->session(), other->name())
, _type (other->data_type())
, REGION_COPY_STATE (other)

View File

@ -59,7 +59,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bo
boost::shared_ptr<const MidiRegion> mr;
if ((ar = boost::dynamic_pointer_cast<const AudioRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new AudioRegion (ar, MusicSample (0, 0)));
ret = boost::shared_ptr<Region> (new AudioRegion (ar, timecnt_t (superclock_t (0), timepos_t (superclock_t (0)))));
} else if ((mr = boost::dynamic_pointer_cast<const MidiRegion> (region)) != 0) {
if (mr->session ().config.get_midi_copy_is_fork () || fork) {
@ -75,7 +75,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bo
source->set_ancestor_name (mr->sources ().front ()->name ());
ret = mr->clone (source, tl);
} else {
ret = boost::shared_ptr<Region> (new MidiRegion (mr, MusicSample (0, 0)));
ret = boost::shared_ptr<Region> (new MidiRegion (mr, timecnt_t (Temporal::Beats (), timepos_t (Temporal::Beats()))));
}
} else {
@ -148,7 +148,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
}
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, MusicSample offset, const PropertyList& plist, bool announce, ThawList* tl)
RegionFactory::create (boost::shared_ptr<Region> region, timecnt_t const & offset, const PropertyList& plist, bool announce, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other_a;

View File

@ -117,10 +117,10 @@ StripSilence::run (boost::shared_ptr<Region> 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<AudioRegion> (
// 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<AudioRegion> (RegionFactory::create (region, offset, plist));
copy->set_name (RegionFactory::new_region_name (region->name ()));