diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 171f5d60db..7fc2ed4d66 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -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) { diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 03b5145402..e548fc7fdd 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -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 TempoPoint const & _tempo_at (TimeType when, Comparator cmp) const { assert (!_tempos.empty());