From b3040a31fc07cb83935db1180f9e75ec5566b849 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 4 May 2023 13:39:53 -0600 Subject: [PATCH] temporal: a basic data structure to hold the result of a TempoMap cut/copy operation --- libs/temporal/tempo.cc | 51 ++++++++++++++++++++++++++++++++++ libs/temporal/temporal/tempo.h | 38 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 8bdd3f4824..9195043b46 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -4510,3 +4510,54 @@ DomainSwapInformation::undo () clear (); } + +TempoMapCutBuffer::TempoMapCutBuffer (timecnt_t const & dur, TempoMetric const & start, TempoMetric const & end) + : _start_metric (start) + , _end_metric (end) + , _duration (dur) +{ +} + +void +TempoMapCutBuffer::add (TempoPoint const & tp) +{ + TempoPoint* ntp = new TempoPoint (tp); + + ntp->set (tp.sclock() - _duration.position().superclocks(), tp.beats(), tp.bbt()); + + _tempos.push_back (*ntp); + _points.push_back (*ntp); +} + +void +TempoMapCutBuffer::add (MeterPoint const & mp) +{ + MeterPoint* ntp = new MeterPoint (mp); + + ntp->set (mp.sclock() - _duration.position().superclocks(), mp.beats(), mp.bbt()); + + _meters.push_back (*ntp); + _points.push_back (*ntp); +} + +void +TempoMapCutBuffer::add (MusicTimePoint const & mtp) +{ + MusicTimePoint* ntp = new MusicTimePoint (mtp); + + ntp->set (mtp.sclock() - _duration.position().superclocks(), mtp.beats(), mtp.bbt()); + + _bartimes.push_back (*ntp); + _tempos.push_back (*ntp); + _meters.push_back (*ntp); + _points.push_back (*ntp); +} + +void +TempoMapCutBuffer::clear () +{ + _tempos.clear (); + _meters.clear (); + _bartimes.clear (); + _points.clear (); +} diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index aac5940751..cd94061b45 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -1144,6 +1144,44 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible void drop_lookup_table (); }; +class LIBTEMPORAL_API TempoMapCutBuffer +{ + public: + TempoMapCutBuffer (timecnt_t const &, TempoMetric const &, TempoMetric const &); + + timecnt_t duration() const { return _duration; } + + TempoMetric const & metric_at_start () const { return _start_metric; } + TempoMetric const & metric_at_end () const { return _end_metric; } + + typedef boost::intrusive::list> Tempos; + typedef boost::intrusive::list> Meters; + typedef boost::intrusive::list> MusicTimes; + typedef boost::intrusive::list> Points; + + void add (TempoPoint const &); + void add (MeterPoint const &); + void add (MusicTimePoint const &); + void add (Point const &); + + void clear (); + + Tempos const & tempos() const { return _tempos; } + Meters const & meters() const { return _meters; } + MusicTimes const & bartimes() const { return _bartimes; } + Points const & points() const { return _points; } + + private: + TempoMetric _start_metric; + TempoMetric _end_metric; + timecnt_t _duration; + + Tempos _tempos; + Meters _meters; + MusicTimes _bartimes; + Points _points; +}; + class LIBTEMPORAL_API TempoCommand : public Command { public: