Mercurial > hg > svcore
changeset 1725:78fe29adfd16
Re-implement extendEndFrame behaviour, used by Tony application
author | Chris Cannam |
---|---|
date | Wed, 19 Jun 2019 13:32:52 +0100 |
parents | 157c62ff0056 |
children | d7ae9bfb015e |
files | data/model/AggregateWaveModel.h data/model/AlignmentModel.cpp data/model/AlignmentModel.h data/model/Dense3DModelPeakCache.h data/model/EditableDenseThreeDimensionalModel.cpp data/model/EditableDenseThreeDimensionalModel.h data/model/FFTModel.h data/model/ImageModel.h data/model/Model.h data/model/NoteModel.h data/model/PathModel.h data/model/ReadOnlyWaveFileModel.h data/model/RegionModel.h data/model/SparseOneDimensionalModel.h data/model/SparseTimeValueModel.h data/model/TextModel.h data/model/WaveFileModel.h data/model/WritableWaveFileModel.h data/model/test/MockWaveModel.h |
diffstat | 19 files changed, 52 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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();
--- 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 {
--- 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 {
--- 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); }
--- 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.
--- 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 {
--- 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;
--- 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(); };
--- 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;
--- 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; }
--- 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; }
--- 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;
--- 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;
--- 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;
--- 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;
--- 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;
--- 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;
--- 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; }