diff data/model/SparseTimeValueModel.h @ 1659:8bf3a52a1604 single-point

Work on start/end frame stuff to match API description
author Chris Cannam
date Thu, 21 Mar 2019 11:35:30 +0000
parents 5b7b01da430a
children 353a2d15f213
line wrap: on
line diff
--- a/data/model/SparseTimeValueModel.h	Wed Mar 20 16:22:13 2019 +0000
+++ b/data/model/SparseTimeValueModel.h	Thu Mar 21 11:35:30 2019 +0000
@@ -81,10 +81,19 @@
     }
 
     QString getTypeName() const override { return tr("Sparse Time-Value"); }
+    bool isSparse() const { return true; }
+    bool isOK() const override { return true; }
 
-    bool isOK() const override { return true; }
-    sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); }
-    sv_frame_t getEndFrame() const override { return m_events.getEndFrame(); }
+    sv_frame_t getStartFrame() const override {
+        return m_events.getStartFrame();
+    }
+    sv_frame_t getEndFrame() const override {
+        if (m_events.isEmpty()) return 0;
+        sv_frame_t e = m_events.getEndFrame() + 1;
+        if (e % m_resolution == 0) return e;
+        else return (e / m_resolution + 1) * m_resolution;
+    }
+    
     sv_samplerate_t getSampleRate() const override { return m_sampleRate; }
     int getResolution() const { return m_resolution; }