Mercurial > hg > svcore
changeset 1451:b40f67578976 streaming-csv-writer
Update getEndFrame so as to refer explicitly to final frame + 1 (consistent with selection semantics and existing wave model)
author | Chris Cannam |
---|---|
date | Tue, 17 Apr 2018 10:37:15 +0100 |
parents | a12fd0456f0c |
children | 6e9615bde1f9 |
files | data/model/Model.h data/model/SparseModel.h |
diffstat | 2 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/Model.h Tue Apr 17 10:35:42 2018 +0100 +++ b/data/model/Model.h Tue Apr 17 10:37:15 2018 +0100 @@ -53,7 +53,11 @@ virtual sv_frame_t getStartFrame() const = 0; /** - * Return the last audio frame spanned by the model. + * Return the audio frame at the end of the model, i.e. 1 more + * than the final frame contained within the model. The end frame + * minus the start frame should yield the total duration in frames + * spanned by the model. This is consistent with the definition of + * the end frame of a Selection object. */ virtual sv_frame_t getEndFrame() const = 0; @@ -220,11 +224,11 @@ virtual QString toDelimitedDataString(QString delimiter) const { return toDelimitedDataStringSubset - (delimiter, getStartFrame(), getEndFrame() + 1); + (delimiter, getStartFrame(), getEndFrame()); } virtual QString toDelimitedDataStringWithOptions(QString delimiter, DataExportOptions opts) const { return toDelimitedDataStringSubsetWithOptions - (delimiter, opts, getStartFrame(), getEndFrame() + 1); + (delimiter, opts, getStartFrame(), getEndFrame()); } virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const { return "";
--- a/data/model/SparseModel.h Tue Apr 17 10:35:42 2018 +0100 +++ b/data/model/SparseModel.h Tue Apr 17 10:37:15 2018 +0100 @@ -62,12 +62,6 @@ return m_resolution ? m_resolution : 1; } virtual void setResolution(int resolution); - - // Extend the end of the model. If this is set to something beyond - // the end of the final point in the model, then getEndFrame() - // will return this value. Otherwise getEndFrame() will return the - // end of the final point. - virtual void extendEndFrame(sv_frame_t to) { m_extendTo = to; } typedef PointType Point; typedef std::multiset<PointType, @@ -168,7 +162,7 @@ DataExportOptions opts) const { return toDelimitedDataStringSubsetWithOptions (delimiter, opts, - std::min(getStartFrame(), sv_frame_t(0)), getEndFrame() + 1); + std::min(getStartFrame(), sv_frame_t(0)), getEndFrame()); } virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { @@ -395,7 +389,6 @@ protected: sv_samplerate_t m_sampleRate; int m_resolution; - sv_frame_t m_extendTo; bool m_notifyOnAdd; sv_frame_t m_sinceLastNotifyMin; sv_frame_t m_sinceLastNotifyMax; @@ -541,7 +534,6 @@ bool notifyOnAdd) : m_sampleRate(sampleRate), m_resolution(resolution), - m_extendTo(0), m_notifyOnAdd(notifyOnAdd), m_sinceLastNotifyMin(-1), m_sinceLastNotifyMax(-1), @@ -571,10 +563,9 @@ sv_frame_t f = 0; if (!m_points.empty()) { PointListConstIterator i(m_points.end()); - f = (--i)->frame; + f = (--i)->frame + 1; } - if (m_extendTo > f) return m_extendTo; - else return f; + return f; } template <typename PointType>