add required methods for region-relative time conversion
This commit is contained in:
parent
1b06fcb335
commit
db8b054543
@ -278,6 +278,35 @@ public:
|
||||
void set_video_locked (bool yn);
|
||||
void set_position_locked (bool yn);
|
||||
|
||||
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)));
|
||||
}
|
||||
/** 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 ();
|
||||
}
|
||||
/** Convert a distance within a region to beats relative to region position */
|
||||
Temporal::Beats region_distance_to_region_beats (Temporal::timecnt_t const &) const;
|
||||
|
||||
/** Convert a timestamp in beats measured from source start into absolute beats */
|
||||
Temporal::Beats source_beats_to_absolute_beats(Temporal::Beats beats) const;
|
||||
|
||||
/** Convert a timestamp in beats measured from source start into absolute samples */
|
||||
Temporal::timepos_t source_beats_to_absolute_time(Temporal::Beats beats) const;
|
||||
|
||||
/** 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)));
|
||||
}
|
||||
/** 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 ();
|
||||
}
|
||||
|
||||
int apply (Filter &, Progress* progress = 0);
|
||||
|
||||
boost::shared_ptr<ARDOUR::Playlist> playlist () const { return _playlist.lock(); }
|
||||
|
@ -1973,6 +1973,56 @@ Region::latest_possible_sample () const
|
||||
return position_sample() + (minlen - start_sample()) - 1;
|
||||
}
|
||||
|
||||
Temporal::TimeDomain
|
||||
Region::position_time_domain() const
|
||||
{
|
||||
return _position.val().time_domain();
|
||||
}
|
||||
|
||||
timepos_t
|
||||
Region::nt_end() const
|
||||
{
|
||||
return _position.val() + _length.val();
|
||||
}
|
||||
|
||||
Temporal::Beats
|
||||
Region::region_distance_to_region_beats (timecnt_t const & region_relative_offset) const
|
||||
{
|
||||
return timecnt_t (region_relative_offset, nt_position()).beats ();
|
||||
}
|
||||
|
||||
Temporal::Beats
|
||||
Region::source_beats_to_absolute_beats (Temporal::Beats beats) const
|
||||
{
|
||||
return source_position().beats() + beats;
|
||||
}
|
||||
|
||||
Temporal::timepos_t
|
||||
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;
|
||||
}
|
||||
|
||||
Temporal::timepos_t
|
||||
Region::source_beats_to_absolute_time (Temporal::Beats beats) const
|
||||
{
|
||||
/* return the time corresponding to `beats' relative to the start of
|
||||
the source. The start of the source is an implied position given by
|
||||
region->position - region->start
|
||||
*/
|
||||
return source_position() + beats;
|
||||
}
|
||||
|
||||
Temporal::Beats
|
||||
Region::absolute_time_to_source_beats(timepos_t const & time) const
|
||||
{
|
||||
const timepos_t s (source_position());
|
||||
return time.earlier (timecnt_t (s, s)).beats();
|
||||
}
|
||||
|
||||
timepos_t
|
||||
Region::source_position () const
|
||||
{
|
||||
@ -1990,4 +2040,3 @@ Region::region_relative_position (timepos_t const & p) const
|
||||
{
|
||||
return p.earlier (_position.val());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user