annotate data/model/DenseThreeDimensionalModel.h @ 147:3a13b0d4934e

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:44:37 +0000
parents
children 4b2ea82fd0ed
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@147 7 This file copyright 2006 Chris Cannam.
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 _DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@147 17 #define _DENSE_THREE_DIMENSIONAL_MODEL_H_
Chris@147 18
Chris@147 19 #include "base/Model.h"
Chris@147 20 #include "base/ZoomConstraint.h"
Chris@147 21
Chris@147 22 #include <QMutex>
Chris@147 23 #include <vector>
Chris@147 24
Chris@147 25 class DenseThreeDimensionalModel : public Model,
Chris@147 26 virtual public ZoomConstraint,
Chris@147 27 virtual public QObject
Chris@147 28 {
Chris@147 29 Q_OBJECT
Chris@147 30
Chris@147 31 public:
Chris@147 32 //!!! need to reconcile terminology -- windowSize here, resolution in sparse models
Chris@147 33 DenseThreeDimensionalModel(size_t sampleRate,
Chris@147 34 size_t windowSize,
Chris@147 35 size_t yBinCount,
Chris@147 36 bool notifyOnAdd = true);
Chris@147 37
Chris@147 38 virtual bool isOK() const;
Chris@147 39
Chris@147 40 virtual size_t getSampleRate() const;
Chris@147 41 virtual size_t getStartFrame() const;
Chris@147 42 virtual size_t getEndFrame() const;
Chris@147 43
Chris@147 44 virtual Model *clone() const;
Chris@147 45
Chris@147 46
Chris@147 47 /**
Chris@147 48 * Return the number of sample frames covered by each set of bins.
Chris@147 49 */
Chris@147 50 virtual size_t getWindowSize() const;
Chris@147 51
Chris@147 52 /**
Chris@147 53 * Set the number of sample frames covered by each set of bins.
Chris@147 54 */
Chris@147 55 virtual void setWindowSize(size_t sz);
Chris@147 56
Chris@147 57 /**
Chris@147 58 * Return the number of bins in each set of bins.
Chris@147 59 */
Chris@147 60 virtual size_t getYBinCount() const;
Chris@147 61
Chris@147 62 /**
Chris@147 63 * Set the number of bins in each set of bins.
Chris@147 64 */
Chris@147 65 virtual void setYBinCount(size_t sz);
Chris@147 66
Chris@147 67 /**
Chris@147 68 * Return the minimum value of the value in each bin.
Chris@147 69 */
Chris@147 70 virtual float getMinimumLevel() const;
Chris@147 71
Chris@147 72 /**
Chris@147 73 * Set the minimum value of the value in a bin.
Chris@147 74 */
Chris@147 75 virtual void setMinimumLevel(float sz);
Chris@147 76
Chris@147 77 /**
Chris@147 78 * Return the maximum value of the value in each bin.
Chris@147 79 */
Chris@147 80 virtual float getMaximumLevel() const;
Chris@147 81
Chris@147 82 /**
Chris@147 83 * Set the maximum value of the value in a bin.
Chris@147 84 */
Chris@147 85 virtual void setMaximumLevel(float sz);
Chris@147 86
Chris@147 87 typedef std::vector<float> BinValueSet;
Chris@147 88
Chris@147 89 /**
Chris@147 90 * Get the set of bin values at the given sample frame (i.e. the
Chris@147 91 * windowStartFrame/getWindowSize()'th set of bins).
Chris@147 92 */
Chris@147 93 virtual void getBinValues(long windowStartFrame, BinValueSet &result) const;
Chris@147 94
Chris@147 95 /**
Chris@147 96 * Get a single value, the one at the n'th bin of the set of bins
Chris@147 97 * starting at the given sample frame.
Chris@147 98 */
Chris@147 99 virtual float getBinValue(long windowStartFrame, size_t n) const;
Chris@147 100
Chris@147 101 /**
Chris@147 102 * Set the entire set of bin values at the given sample frame.
Chris@147 103 */
Chris@147 104 virtual void setBinValues(long windowStartFrame, const BinValueSet &values);
Chris@147 105
Chris@147 106 virtual QString getBinName(size_t n) const;
Chris@147 107 virtual void setBinName(size_t n, QString);
Chris@147 108 virtual void setBinNames(std::vector<QString> names);
Chris@147 109
Chris@147 110 virtual void setCompletion(int completion);
Chris@147 111 virtual int getCompletion() const { return m_completion; }
Chris@147 112
Chris@147 113 virtual void toXml(QTextStream &out,
Chris@147 114 QString indent = "",
Chris@147 115 QString extraAttributes = "") const;
Chris@147 116
Chris@147 117 virtual QString toXmlString(QString indent = "",
Chris@147 118 QString extraAttributes = "") const;
Chris@147 119
Chris@147 120 protected:
Chris@147 121 typedef std::vector<BinValueSet> ValueMatrix;
Chris@147 122 ValueMatrix m_data;
Chris@147 123
Chris@147 124 std::vector<QString> m_binNames;
Chris@147 125
Chris@147 126 size_t m_sampleRate;
Chris@147 127 size_t m_windowSize;
Chris@147 128 size_t m_yBinCount;
Chris@147 129 float m_minimum;
Chris@147 130 float m_maximum;
Chris@147 131 bool m_notifyOnAdd;
Chris@147 132 long m_sinceLastNotifyMin;
Chris@147 133 long m_sinceLastNotifyMax;
Chris@147 134 int m_completion;
Chris@147 135
Chris@147 136 mutable QMutex m_mutex;
Chris@147 137 };
Chris@147 138
Chris@147 139 #endif