temporal: first guess at a TempoMap::shift() implementation

This commit is contained in:
Paul Davis 2023-06-06 13:23:45 -06:00
parent 5e9d98dbf9
commit a456a10cdf
2 changed files with 50 additions and 0 deletions

View File

@ -1010,6 +1010,54 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool
}
#if 0
void
TempoMap::shift (timepos_t const & at, timecnt_t const & by)
{
if (by.time_domain() == BeatTime) {
} else {
superclock_t distance = by.superclocks ();
superclock_t at_superclocks = by.superclocks ();
Points::iterator p = _points.begin();
while (p.sclock() < at_superclocks) {
++p;
}
if (p == _points.end()) {
return;
}
p->set (at_superclocks + distance, p->beats(), p->bbt());
reset_starting_at (at_superclocks);
}
}
#endif
void
TempoMap::shift (timepos_t const & at, BBT_Offset const & offset)
{
if (offset.bars < 1) {
return;
}
if (offset.beats || offset.ticks) {
return;
}
superclock_t at_superclocks = at.superclocks();
for (auto & p : _points) {
if (p.sclock() < at_superclocks) {
BBT_Time new_bbt (p.bbt().bars + offset.bars, p.bbt().beats, p.bbt().ticks);
p.set (p.sclock(), p.beats(), new_bbt);
}
}
reset_starting_at (at_superclocks);
}
MeterPoint*
TempoMap::add_meter (MeterPoint* mp)
{

View File

@ -822,6 +822,8 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API TempoMapCutBuffer* copy (timepos_t const & start, timepos_t const & end);
LIBTEMPORAL_API void paste (TempoMapCutBuffer const &, timepos_t const & position, bool ripple);
LIBTEMPORAL_API void shift (timepos_t const & at, BBT_Offset const &);
private:
template<typename TimeType, typename Comparator> TempoPoint const & _tempo_at (TimeType when, Comparator cmp) const {
assert (!_tempos.empty());