comparison 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
comparison
equal deleted inserted replaced
146:f90fad823cea 147:3a13b0d4934e
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _DENSE_THREE_DIMENSIONAL_MODEL_H_
17 #define _DENSE_THREE_DIMENSIONAL_MODEL_H_
18
19 #include "base/Model.h"
20 #include "base/ZoomConstraint.h"
21
22 #include <QMutex>
23 #include <vector>
24
25 class DenseThreeDimensionalModel : public Model,
26 virtual public ZoomConstraint,
27 virtual public QObject
28 {
29 Q_OBJECT
30
31 public:
32 //!!! need to reconcile terminology -- windowSize here, resolution in sparse models
33 DenseThreeDimensionalModel(size_t sampleRate,
34 size_t windowSize,
35 size_t yBinCount,
36 bool notifyOnAdd = true);
37
38 virtual bool isOK() const;
39
40 virtual size_t getSampleRate() const;
41 virtual size_t getStartFrame() const;
42 virtual size_t getEndFrame() const;
43
44 virtual Model *clone() const;
45
46
47 /**
48 * Return the number of sample frames covered by each set of bins.
49 */
50 virtual size_t getWindowSize() const;
51
52 /**
53 * Set the number of sample frames covered by each set of bins.
54 */
55 virtual void setWindowSize(size_t sz);
56
57 /**
58 * Return the number of bins in each set of bins.
59 */
60 virtual size_t getYBinCount() const;
61
62 /**
63 * Set the number of bins in each set of bins.
64 */
65 virtual void setYBinCount(size_t sz);
66
67 /**
68 * Return the minimum value of the value in each bin.
69 */
70 virtual float getMinimumLevel() const;
71
72 /**
73 * Set the minimum value of the value in a bin.
74 */
75 virtual void setMinimumLevel(float sz);
76
77 /**
78 * Return the maximum value of the value in each bin.
79 */
80 virtual float getMaximumLevel() const;
81
82 /**
83 * Set the maximum value of the value in a bin.
84 */
85 virtual void setMaximumLevel(float sz);
86
87 typedef std::vector<float> BinValueSet;
88
89 /**
90 * Get the set of bin values at the given sample frame (i.e. the
91 * windowStartFrame/getWindowSize()'th set of bins).
92 */
93 virtual void getBinValues(long windowStartFrame, BinValueSet &result) const;
94
95 /**
96 * Get a single value, the one at the n'th bin of the set of bins
97 * starting at the given sample frame.
98 */
99 virtual float getBinValue(long windowStartFrame, size_t n) const;
100
101 /**
102 * Set the entire set of bin values at the given sample frame.
103 */
104 virtual void setBinValues(long windowStartFrame, const BinValueSet &values);
105
106 virtual QString getBinName(size_t n) const;
107 virtual void setBinName(size_t n, QString);
108 virtual void setBinNames(std::vector<QString> names);
109
110 virtual void setCompletion(int completion);
111 virtual int getCompletion() const { return m_completion; }
112
113 virtual void toXml(QTextStream &out,
114 QString indent = "",
115 QString extraAttributes = "") const;
116
117 virtual QString toXmlString(QString indent = "",
118 QString extraAttributes = "") const;
119
120 protected:
121 typedef std::vector<BinValueSet> ValueMatrix;
122 ValueMatrix m_data;
123
124 std::vector<QString> m_binNames;
125
126 size_t m_sampleRate;
127 size_t m_windowSize;
128 size_t m_yBinCount;
129 float m_minimum;
130 float m_maximum;
131 bool m_notifyOnAdd;
132 long m_sinceLastNotifyMin;
133 long m_sinceLastNotifyMax;
134 int m_completion;
135
136 mutable QMutex m_mutex;
137 };
138
139 #endif