add back-pointer to TempoMap from points, and push dirty=true into map
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 15 Sep 2017 02:50:08 +0000 (22:50 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Sep 2017 15:40:54 +0000 (11:40 -0400)
nutemp/t.cc
nutemp/t.h

index 2ea87a0a16345bb73b85346d8b737447ac17c98b..c8336ccde8d8c1d341f41d9015fa6a8b8de855a4 100644 (file)
@@ -306,6 +306,23 @@ TempoMetric::superclock_at_qn (Evoral::Beats const & qn) const
        return llrint (superclocks_per_quarter_note() * (log1p (_c_per_quarter * qn.to_double()) / _c_per_quarter));
 }
 
+void
+TempoMapPoint::set_map (TempoMap* m)
+{
+       _map = m;
+}
+
+void
+TempoMapPoint::set_dirty (bool yn)
+{
+       if (yn != _dirty) {
+               _dirty = yn;
+               if (yn && _map) {
+                       _map->set_dirty (true);
+               }
+       }
+}
+
 Evoral::Beats
 TempoMapPoint::quarters_at (superclock_t sc) const
 {
@@ -339,11 +356,18 @@ TempoMapPoint::bbt_at (Evoral::Beats const & qn) const
 
 TempoMap::TempoMap (Tempo const & initial_tempo, Meter const & initial_meter, framecnt_t sr)
        : _sample_rate (sr)
+       , _dirty (false)
 {
        TempoMapPoint tmp (TempoMapPoint::Flag (TempoMapPoint::ExplicitMeter|TempoMapPoint::ExplicitTempo), initial_tempo, initial_meter, 0, Evoral::Beats(), Timecode::BBT_Time(), AudioTime);
        _points.push_back (tmp);
 }
 
+void
+TempoMap::set_dirty (bool yn)
+{
+       _dirty = yn;
+}
+
 Meter const &
 TempoMap::meter_at (superclock_t sc) const
 {
index c4117a9ad54cce41afba317c00b389066b1b11d1..be54c136ba4de2f11e10a4d6fcd4101bb3c3bc0b 100644 (file)
@@ -191,11 +191,13 @@ class LIBARDOUR_API TempoMapPoint
        };
 
        TempoMapPoint (Flag f, Tempo const& t, Meter const& m, superclock_t sc, Evoral::Beats const & q, Timecode::BBT_Time const & bbt, PositionLockStyle psl, bool ramp = false)
-               : _flags (f), _explicit (t, m, psl, ramp), _sclock (sc), _quarters (q), _bbt (bbt), _dirty (true) {}
+               : _flags (f), _explicit (t, m, psl, ramp), _sclock (sc), _quarters (q), _bbt (bbt), _dirty (true), _map (0) {}
        TempoMapPoint (TempoMapPoint const & tmp, superclock_t sc, Evoral::Beats const & q, Timecode::BBT_Time const & bbt)
-               : _flags (Flag (0)), _reference (&tmp), _sclock (sc), _quarters (q), _bbt (bbt), _dirty (true) {}
+               : _flags (Flag (0)), _reference (&tmp), _sclock (sc), _quarters (q), _bbt (bbt), _dirty (true), _map (0) {}
        ~TempoMapPoint () {}
 
+       void set_map (TempoMap* m);
+
        Flag flags() const       { return _flags; }
        bool is_explicit() const { return _flags != Flag (0); }
        bool is_implicit() const { return _flags == Flag (0); }
@@ -230,7 +232,7 @@ class LIBARDOUR_API TempoMapPoint
        void set_sclock (superclock_t  sc) { if (is_explicit()) { _sclock = sc; _dirty = true; } }
        void set_quarters (Evoral::Beats const & q) { if (is_explicit()) { _quarters = q; _dirty = true;  } }
        void set_bbt (Timecode::BBT_Time const & bbt) {  if (is_explicit()) { _bbt = bbt; _dirty = true;  } }
-       void set_dirty (bool yn) { if (is_explicit()) { _dirty = yn; } }
+       void set_dirty (bool yn);
        void set_lock_style (PositionLockStyle psl) {  if (is_explicit()) { _explicit.lock_style = psl; _dirty = true; } }
 
        void make_explicit (Flag f) {
@@ -289,6 +291,7 @@ class LIBARDOUR_API TempoMapPoint
        Evoral::Beats         _quarters;
        Timecode::BBT_Time    _bbt;
        bool                  _dirty;
+       TempoMap*             _map;
 };
 
 typedef std::list<TempoMapPoint> TempoMapPoints;
@@ -298,6 +301,8 @@ class LIBARDOUR_API TempoMap
    public:
        TempoMap (Tempo const & initial_tempo, Meter const & initial_meter, framecnt_t sr);
 
+       void set_dirty (bool yn);
+
        void set_sample_rate (framecnt_t sr);
        framecnt_t sample_rate() const { return _sample_rate; }
 
@@ -360,6 +365,7 @@ class LIBARDOUR_API TempoMap
        TempoMapPoints _points;
        framecnt_t     _sample_rate;
        mutable Glib::Threads::RWLock _lock;
+       bool _dirty;
 
        /* these return an iterator that refers to the TempoMapPoint at or most immediately preceding the given position.
         *