# HG changeset patch # User Chris Cannam # Date 1560947572 -3600 # Node ID 78fe29adfd169493d572ce233221c4363794acd5 # Parent 157c62ff0056d4af8c76b82436754667ac1eebff Re-implement extendEndFrame behaviour, used by Tony application diff -r 157c62ff0056 -r 78fe29adfd16 data/model/AggregateWaveModel.h --- a/data/model/AggregateWaveModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/AggregateWaveModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -62,7 +62,7 @@ float getValueMaximum() const override { return 1.0f; } sv_frame_t getStartFrame() const override { return 0; } - sv_frame_t getEndFrame() const override { return getFrameCount(); } + sv_frame_t getTrueEndFrame() const override { return getFrameCount(); } floatvec_t getData(int channel, sv_frame_t start, sv_frame_t count) const override; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/AlignmentModel.cpp Wed Jun 19 13:32:52 2019 +0100 @@ -90,7 +90,7 @@ } sv_frame_t -AlignmentModel::getEndFrame() const +AlignmentModel::getTrueEndFrame() const { sv_frame_t a = m_reference->getEndFrame(); sv_frame_t b = m_aligned->getEndFrame(); diff -r 157c62ff0056 -r 78fe29adfd16 data/model/AlignmentModel.h --- a/data/model/AlignmentModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/AlignmentModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -41,7 +41,7 @@ QString getError() const { return m_error; } sv_frame_t getStartFrame() const override; - sv_frame_t getEndFrame() const override; + sv_frame_t getTrueEndFrame() const override; sv_samplerate_t getSampleRate() const override; bool isReady(int *completion = 0) const override; int getCompletion() const override { diff -r 157c62ff0056 -r 78fe29adfd16 data/model/Dense3DModelPeakCache.h --- a/data/model/Dense3DModelPeakCache.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/Dense3DModelPeakCache.h Wed Jun 19 13:32:52 2019 +0100 @@ -40,8 +40,8 @@ return m_source->getStartFrame(); } - sv_frame_t getEndFrame() const override { - return m_source->getEndFrame(); + sv_frame_t getTrueEndFrame() const override { + return m_source->getTrueEndFrame(); } int getResolution() const override { diff -r 157c62ff0056 -r 78fe29adfd16 data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Wed Jun 19 13:32:52 2019 +0100 @@ -83,7 +83,7 @@ } sv_frame_t -EditableDenseThreeDimensionalModel::getEndFrame() const +EditableDenseThreeDimensionalModel::getTrueEndFrame() const { return m_resolution * m_data.size() + (m_resolution - 1); } diff -r 157c62ff0056 -r 78fe29adfd16 data/model/EditableDenseThreeDimensionalModel.h --- a/data/model/EditableDenseThreeDimensionalModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -55,7 +55,7 @@ sv_samplerate_t getSampleRate() const override; sv_frame_t getStartFrame() const override; - sv_frame_t getEndFrame() const override; + sv_frame_t getTrueEndFrame() const override; /** * Set the frame offset of the first column. diff -r 157c62ff0056 -r 78fe29adfd16 data/model/FFTModel.h --- a/data/model/FFTModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/FFTModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -65,7 +65,7 @@ float getValueAt(int x, int y) const override { return getMagnitudeAt(x, y); } bool isOK() const override { return m_model && m_model->isOK(); } sv_frame_t getStartFrame() const override { return 0; } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { return sv_frame_t(getWidth()) * getResolution() + getResolution(); } sv_samplerate_t getSampleRate() const override { diff -r 157c62ff0056 -r 78fe29adfd16 data/model/ImageModel.h --- a/data/model/ImageModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/ImageModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -61,7 +61,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame() + 1; if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/Model.h --- a/data/model/Model.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/Model.h Wed Jun 19 13:32:52 2019 +0100 @@ -62,8 +62,36 @@ * frames (as a multiple of the resolution) spanned by the * model. This is broadly consistent with the definition of the * end frame of a Selection object. + * + * If the end has been extended by extendEndFrame() beyond the + * true end frame, return the extended end instead. This is + * usually the behaviour you want. */ - virtual sv_frame_t getEndFrame() const = 0; + sv_frame_t getEndFrame() const { + sv_frame_t trueEnd = getTrueEndFrame(); + if (m_extendTo > trueEnd) { + return m_extendTo; + } else { + return trueEnd; + } + } + + /** + * Return the audio frame at the end of the model. This is + * identical to getEndFrame(), except that it ignores any extended + * duration set with extendEndFrame(). + */ + virtual sv_frame_t getTrueEndFrame() const = 0; + + /** + * Extend the end of the model. If this is set to something beyond + * the true end of the data within the model, then getEndFrame() + * will return this value instead of the true end. (This is used + * by the Tony application.) + */ + void extendEndFrame(sv_frame_t to) { + m_extendTo = to; + } /** * Return the frame rate in frames per second. @@ -315,7 +343,8 @@ m_sourceModel(0), m_alignment(0), m_abandoning(false), - m_aboutToDelete(false) { } + m_aboutToDelete(false), + m_extendTo(0) { } // Not provided. Model(const Model &); @@ -327,7 +356,8 @@ QString m_typeUri; bool m_abandoning; bool m_aboutToDelete; - + sv_frame_t m_extendTo; + int getNextId(); }; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/NoteModel.h --- a/data/model/NoteModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/NoteModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -102,7 +102,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame(); if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/PathModel.h --- a/data/model/PathModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/PathModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -83,7 +83,7 @@ sv_frame_t getStartFrame() const override { return m_start; } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { return m_end; } diff -r 157c62ff0056 -r 78fe29adfd16 data/model/ReadOnlyWaveFileModel.h --- a/data/model/ReadOnlyWaveFileModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/ReadOnlyWaveFileModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -77,7 +77,7 @@ float getValueMaximum() const override { return 1.0f; } sv_frame_t getStartFrame() const override { return m_startFrame; } - sv_frame_t getEndFrame() const override { return m_startFrame + getFrameCount(); } + sv_frame_t getTrueEndFrame() const override { return m_startFrame + getFrameCount(); } void setStartFrame(sv_frame_t startFrame) override { m_startFrame = startFrame; } diff -r 157c62ff0056 -r 78fe29adfd16 data/model/RegionModel.h --- a/data/model/RegionModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/RegionModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -83,7 +83,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame(); if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/SparseOneDimensionalModel.h --- a/data/model/SparseOneDimensionalModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/SparseOneDimensionalModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -67,7 +67,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame() + 1; if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/SparseTimeValueModel.h --- a/data/model/SparseTimeValueModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/SparseTimeValueModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -87,7 +87,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame() + 1; if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/TextModel.h --- a/data/model/TextModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/TextModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -59,7 +59,7 @@ sv_frame_t getStartFrame() const override { return m_events.getStartFrame(); } - sv_frame_t getEndFrame() const override { + sv_frame_t getTrueEndFrame() const override { if (m_events.isEmpty()) return 0; sv_frame_t e = m_events.getEndFrame() + 1; if (e % m_resolution == 0) return e; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/WaveFileModel.h --- a/data/model/WaveFileModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/WaveFileModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -37,7 +37,7 @@ QString getLocation() const override = 0; sv_frame_t getStartFrame() const override = 0; - sv_frame_t getEndFrame() const override = 0; + sv_frame_t getTrueEndFrame() const override = 0; virtual void setStartFrame(sv_frame_t startFrame) = 0; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/WritableWaveFileModel.h --- a/data/model/WritableWaveFileModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/WritableWaveFileModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -175,7 +175,7 @@ float getValueMaximum() const override { return 1.0f; } sv_frame_t getStartFrame() const override { return m_startFrame; } - sv_frame_t getEndFrame() const override { return m_startFrame + getFrameCount(); } + sv_frame_t getTrueEndFrame() const override { return m_startFrame + getFrameCount(); } void setStartFrame(sv_frame_t startFrame) override; diff -r 157c62ff0056 -r 78fe29adfd16 data/model/test/MockWaveModel.h --- a/data/model/test/MockWaveModel.h Mon Jun 17 11:02:03 2019 +0100 +++ b/data/model/test/MockWaveModel.h Wed Jun 19 13:32:52 2019 +0100 @@ -48,7 +48,7 @@ QString getDefaultPlayClipId() const override { return ""; } sv_frame_t getStartFrame() const override { return 0; } - sv_frame_t getEndFrame() const override { return m_data[0].size(); } + sv_frame_t getTrueEndFrame() const override { return m_data[0].size(); } sv_samplerate_t getSampleRate() const override { return 44100; } bool isOK() const override { return true; } int getCompletion() const override { return 100; }