annotate data/model/RangeSummarisableTimeValueModel.h @ 299:576be0d0d218

* Merge transform directory from sv-match-alignment branch (the previous comment included notes for this stuff, but I missed it in the actual merge) * Fix crash when a transform fails to create an output model and the thread that created the transform then deletes its input model thinking it's no longer needed, even though the transform run thread is still using it -- fix is to wait() on the transform before returning the null output model
author Chris Cannam
date Fri, 28 Sep 2007 16:15:06 +0000
parents c022976d18e8
children 5877d68815c7
rev   line source
Chris@147 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@147 2
Chris@147 3 /*
Chris@147 4 Sonic Visualiser
Chris@147 5 An audio file viewer and annotation editor.
Chris@147 6 Centre for Digital Music, Queen Mary, University of London.
Chris@297 7 This file copyright 2006-2007 Chris Cannam and QMUL.
Chris@147 8
Chris@147 9 This program is free software; you can redistribute it and/or
Chris@147 10 modify it under the terms of the GNU General Public License as
Chris@147 11 published by the Free Software Foundation; either version 2 of the
Chris@147 12 License, or (at your option) any later version. See the file
Chris@147 13 COPYING included with this distribution for more information.
Chris@147 14 */
Chris@147 15
Chris@147 16 #ifndef _RANGE_SUMMARISABLE_TIME_VALUE_MODEL_H_
Chris@147 17 #define _RANGE_SUMMARISABLE_TIME_VALUE_MODEL_H_
Chris@147 18
Chris@147 19 #include <QObject>
Chris@147 20
Chris@147 21 #include "DenseTimeValueModel.h"
Chris@147 22 #include "base/ZoomConstraint.h"
Chris@147 23
Chris@297 24 class AlignmentModel;
Chris@297 25
Chris@147 26 /**
Chris@147 27 * Base class for models containing dense two-dimensional data (value
Chris@147 28 * against time) that may be meaningfully represented in a zoomed view
Chris@147 29 * using min/max range summaries. Audio waveform data is an obvious
Chris@147 30 * example: think "peaks and minima" for "ranges".
Chris@147 31 */
Chris@147 32
Chris@179 33 class RangeSummarisableTimeValueModel : public DenseTimeValueModel
Chris@147 34 {
Chris@147 35 Q_OBJECT
Chris@147 36
Chris@147 37 public:
Chris@297 38 RangeSummarisableTimeValueModel() : m_alignment(0) { }
Chris@297 39
Chris@147 40 struct Range
Chris@147 41 {
Chris@147 42 float min;
Chris@147 43 float max;
Chris@147 44 float absmean;
Chris@147 45 Range() :
Chris@147 46 min(0.f), max(0.f), absmean(0.f) { }
Chris@147 47 Range(const Range &r) :
Chris@147 48 min(r.min), max(r.max), absmean(r.absmean) { }
Chris@147 49 Range(float min_, float max_, float absmean_) :
Chris@147 50 min(min_), max(max_), absmean(absmean_) { }
Chris@147 51 };
Chris@147 52
Chris@147 53 typedef std::vector<Range> RangeBlock;
Chris@147 54
Chris@147 55 /**
Chris@147 56 * Return ranges between the given start and end frames,
Chris@147 57 * summarised at the given block size. ((end - start + 1) /
Chris@147 58 * blockSize) ranges should ideally be returned.
Chris@147 59 *
Chris@147 60 * If the given block size is not supported by this model
Chris@147 61 * (according to its zoom constraint), also modify the blockSize
Chris@147 62 * parameter so as to return the block size that was actually
Chris@147 63 * obtained.
Chris@147 64 */
Chris@225 65 virtual void getRanges(size_t channel, size_t start, size_t end,
Chris@225 66 RangeBlock &ranges,
Chris@225 67 size_t &blockSize) const = 0;
Chris@147 68
Chris@147 69 /**
Chris@147 70 * Return the range between the given start and end frames,
Chris@147 71 * summarised at a block size equal to the distance between start
Chris@147 72 * and end frames.
Chris@147 73 */
Chris@147 74 virtual Range getRange(size_t channel, size_t start, size_t end) const = 0;
Chris@297 75
Chris@297 76 virtual void setAlignment(AlignmentModel *alignment); // I take ownership
Chris@297 77 virtual const Model *getAlignmentReference() const;
Chris@297 78 virtual size_t alignToReference(size_t frame) const;
Chris@297 79 virtual size_t alignFromReference(size_t referenceFrame) const;
Chris@297 80 virtual int getAlignmentCompletion() const;
Chris@297 81
Chris@297 82 signals:
Chris@297 83 void alignmentCompletionChanged();
Chris@297 84
Chris@297 85 protected:
Chris@297 86 AlignmentModel *m_alignment;
Chris@147 87 };
Chris@147 88
Chris@147 89 #endif
Chris@147 90