fixup Region object to work with new factory methods for timeline types (and remove explicit music time-related members)

This commit is contained in:
Paul Davis 2020-08-11 18:27:06 -06:00
parent f06e2dd6d1
commit 889edfd0a0
4 changed files with 19 additions and 56 deletions

View File

@ -65,7 +65,6 @@ namespace Properties {
LIBARDOUR_API extern PBD::PropertyDescriptor<timecnt_t> start;
LIBARDOUR_API extern PBD::PropertyDescriptor<timecnt_t> length;
LIBARDOUR_API extern PBD::PropertyDescriptor<timepos_t> position;
LIBARDOUR_API extern PBD::PropertyDescriptor<double> beat;
LIBARDOUR_API extern PBD::PropertyDescriptor<timecnt_t> sync_position;
LIBARDOUR_API extern PBD::PropertyDescriptor<layer_t> layer;
LIBARDOUR_API extern PBD::PropertyDescriptor<timecnt_t> ancestral_start;
@ -181,7 +180,7 @@ public:
}
Temporal::TimeRange range_samples () const {
return Temporal::TimeRange (first_sample(), first_sample() + length_samples());
return Temporal::TimeRange (timepos_t::from_samples (first_sample()), timepos_t::from_samples (first_sample() + length_samples()));
}
bool hidden () const { return _hidden; }
@ -204,13 +203,6 @@ public:
void set_position_lock_style (PositionLockStyle ps);
void recompute_position_from_lock_style ();
/* meter-based beat at the region position */
double beat () const { return _beat; }
void set_beat (double beat) { _beat = beat; }
/* quarter-note at the region position */
double quarter_note () const { return _quarter_note; }
void set_quarter_note (double qn) { _quarter_note = qn; }
void suspend_property_changes ();
bool covers (samplepos_t sample) const {
@ -413,7 +405,7 @@ protected:
Region (boost::shared_ptr<const Region>, const SourceList&);
/** Constructor for derived types only */
Region (Session& s, timepos_t const & start, timecnt_t const & length, const std::string& name, DataType);
Region (Session& s, timecnt_t const & start, timecnt_t const & length, const std::string& name, DataType);
virtual bool can_trim_start_before_source_start () const {
return false;
@ -439,12 +431,9 @@ protected:
PBD::Property<timecnt_t> _start;
PBD::Property<timecnt_t> _length;
PBD::Property<timepos_t> _position;
PBD::Property<double> _beat;
/** Sync position relative to the start of our file */
PBD::Property<timecnt_t> _sync_position;
double _quarter_note;
SourceList _sources;
/** Used when timefx are applied, so we can always use the original source */
SourceList _master_sources;

View File

@ -352,16 +352,15 @@ RBEffect::run (boost::shared_ptr<Region> r, Progress* progress)
/* now reset ancestral data for each new region */
for (vector<boost::shared_ptr<Region> >::iterator x = results.begin (); x != results.end (); ++x) {
(*x)->set_ancestral_data (timecnt_t (read_start, timepos_t()),
timecnt_t (read_duration, read_start),
(*x)->set_ancestral_data (timecnt_t::from_samples (read_start),
timecnt_t::from_samples (read_duration, timepos_t::from_samples (read_start)),
stretch,
shift);
(*x)->set_master_sources (region->master_sources ());
/* 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.
*/
#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_sample()));
(*x)->set_length (timecnt_t::from_samples (samplepos_t ((*x)->length_samples () * tsr.time_fraction), (*x)->nt_position()));
}
/* stretch region gain envelope */

View File

@ -171,7 +171,6 @@ Region::register_properties ()
add_property (_start);
add_property (_length);
add_property (_position);
add_property (_beat);
add_property (_sync_position);
add_property (_ancestral_start);
add_property (_ancestral_length);
@ -188,12 +187,10 @@ 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 (superclock_t (0)))) \
, _length (Properties::length, timecnt_t (l,timepos_t (s))) \
, _position (Properties::position, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t (superclock_t (0))) \
, _beat (Properties::beat, 0.0) \
, _sync_position (Properties::sync_position, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t (superclock_t (0)))) \
, _quarter_note (0.0) \
, _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) \
, _transient_analysis_end (0) \
@ -208,7 +205,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 (superclock_t (0)))) \
, _ancestral_start (Properties::ancestral_start, timecnt_t (s, _type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))) \
, _ancestral_length (Properties::ancestral_length, (l)) \
, _stretch (Properties::stretch, 1.0) \
, _shift (Properties::shift, 1.0) \
@ -225,9 +222,7 @@ Region::register_properties ()
, _start(Properties::start, other->_start) \
, _length(Properties::length, other->_length) \
, _position(Properties::position, other->_position) \
, _beat (Properties::beat, other->_beat) \
, _sync_position(Properties::sync_position, other->_sync_position) \
, _quarter_note (other->_quarter_note) \
, _user_transients (other->_user_transients) \
, _transient_user_start (other->_transient_user_start) \
, _transients (other->_transients) \
@ -254,12 +249,12 @@ 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 const & length, const string& name, DataType type)
Region::Region (Session& s, timecnt_t const & start, timecnt_t const & length, const string& name, DataType type)
: SessionObject(s, name)
, _type(type)
, REGION_DEFAULT_STATE(start,length)
, REGION_DEFAULT_STATE(start,length)
, _last_length (length)
, _last_position (_type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t (superclock_t (0)))
, _last_position (_type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))
, _first_edit (EditChangesNothing)
, _layer (0)
, _changemap (0)
@ -273,10 +268,10 @@ Region::Region (Session& s, timepos_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 (superclock_t(0)),
_type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_t (superclock_t (0)))
, _last_length (_type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_t (superclock_t (0)))
, _last_position (_type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t (superclock_t (0)))
, REGION_DEFAULT_STATE(_type == DataType::MIDI ? timecnt_t (Temporal::Beats()) : timecnt_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))
, _last_position (_type == DataType::MIDI ? timepos_t (Temporal::Beats()) : timepos_t::from_superclock (0))
, _first_edit (EditChangesNothing)
, _layer (0)
, _changemap (0)
@ -319,8 +314,6 @@ Region::Region (boost::shared_ptr<const Region> other)
_first_edit = other->_first_edit;
_start = other->_start;
_beat = other->_beat;
_quarter_note = other->_quarter_note;
/* sync pos is relative to start of file. our start-in-file is now zero,
* so set our sync position to whatever the the difference between
@ -1349,23 +1342,6 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c
set_id (node);
if (_position_lock_style == MusicTime) {
std::string bbt_str;
if (node.get_property ("bbt-position", bbt_str)) {
if (sscanf (bbt_str.c_str(), "%d|%d|%d",
&bbt_time.bars,
&bbt_time.beats,
&bbt_time.ticks) != 3) {
_position_lock_style = AudioTime;
_beat = _session.tempo_map().beat_at_sample (position_sample());
} else {
_beat = _session.tempo_map().beat_at_bbt (bbt_time);
}
/* no position property change for legacy Property, so we do this here */
_quarter_note = _session.tempo_map().quarter_note_at_beat (_beat);
}
}
/* fix problems with old sessions corrupted by impossible
values for _stretch or _shift
*/
@ -1974,7 +1950,6 @@ Region::is_compound () const
void
Region::post_set (const PropertyChange& pc)
{
_quarter_note = _session.tempo_map().quarter_note_at_beat (_beat);
}
void
@ -1987,7 +1962,7 @@ timepos_t
Region::earliest_possible_position () const
{
if (nt_start() > timecnt_t (_position, timepos_t())) {
return 0;
return timepos_t::from_superclock (0);
} else {
return source_position();
}

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, timecnt_t (superclock_t (0), timepos_t (superclock_t (0)))));
ret = boost::shared_ptr<Region> (new AudioRegion (ar, timecnt_t::from_superclock (0)));
} else if ((mr = boost::dynamic_pointer_cast<const MidiRegion> (region)) != 0) {
if (mr->session ().config.get_midi_copy_is_fork () || fork) {