Chris@545
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@545
|
2
|
Chris@545
|
3 /*
|
Chris@545
|
4 Sonic Visualiser
|
Chris@545
|
5 An audio file viewer and annotation editor.
|
Chris@545
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@545
|
7 This file copyright 2009 QMUL.
|
Chris@545
|
8
|
Chris@545
|
9 This program is free software; you can redistribute it and/or
|
Chris@545
|
10 modify it under the terms of the GNU General Public License as
|
Chris@545
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@545
|
12 License, or (at your option) any later version. See the file
|
Chris@545
|
13 COPYING included with this distribution for more information.
|
Chris@545
|
14 */
|
Chris@545
|
15
|
Chris@1191
|
16 #ifndef DENSE_3D_MODEL_PEAK_CACHE_H
|
Chris@1191
|
17 #define DENSE_3D_MODEL_PEAK_CACHE_H
|
Chris@545
|
18
|
Chris@545
|
19 #include "DenseThreeDimensionalModel.h"
|
Chris@545
|
20 #include "EditableDenseThreeDimensionalModel.h"
|
Chris@545
|
21
|
Chris@545
|
22 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
|
Chris@545
|
23 {
|
Chris@546
|
24 Q_OBJECT
|
Chris@546
|
25
|
Chris@545
|
26 public:
|
Chris@1191
|
27 Dense3DModelPeakCache(const DenseThreeDimensionalModel *source,
|
Chris@929
|
28 int columnsPerPeak);
|
Chris@545
|
29 ~Dense3DModelPeakCache();
|
Chris@545
|
30
|
Chris@1580
|
31 bool isOK() const override {
|
Chris@546
|
32 return m_source && m_source->isOK();
|
Chris@546
|
33 }
|
Chris@546
|
34
|
Chris@1580
|
35 sv_samplerate_t getSampleRate() const override {
|
Chris@546
|
36 return m_source->getSampleRate();
|
Chris@546
|
37 }
|
Chris@546
|
38
|
Chris@1580
|
39 sv_frame_t getStartFrame() const override {
|
Chris@546
|
40 return m_source->getStartFrame();
|
Chris@546
|
41 }
|
Chris@546
|
42
|
Chris@1580
|
43 sv_frame_t getEndFrame() const override {
|
Chris@546
|
44 return m_source->getEndFrame();
|
Chris@546
|
45 }
|
Chris@546
|
46
|
Chris@1580
|
47 int getResolution() const override {
|
Chris@1190
|
48 return m_source->getResolution() * m_columnsPerPeak;
|
Chris@545
|
49 }
|
Chris@545
|
50
|
Chris@1190
|
51 virtual int getColumnsPerPeak() const {
|
Chris@1190
|
52 return m_columnsPerPeak;
|
Chris@1190
|
53 }
|
Chris@1190
|
54
|
Chris@1580
|
55 int getWidth() const override {
|
Chris@1192
|
56 int sourceWidth = m_source->getWidth();
|
Chris@1192
|
57 if ((sourceWidth % m_columnsPerPeak) == 0) {
|
Chris@1192
|
58 return sourceWidth / m_columnsPerPeak;
|
Chris@1192
|
59 } else {
|
Chris@1192
|
60 return sourceWidth / m_columnsPerPeak + 1;
|
Chris@1192
|
61 }
|
Chris@545
|
62 }
|
Chris@545
|
63
|
Chris@1580
|
64 int getHeight() const override {
|
Chris@545
|
65 return m_source->getHeight();
|
Chris@545
|
66 }
|
Chris@545
|
67
|
Chris@1580
|
68 float getMinimumLevel() const override {
|
Chris@545
|
69 return m_source->getMinimumLevel();
|
Chris@545
|
70 }
|
Chris@545
|
71
|
Chris@1580
|
72 float getMaximumLevel() const override {
|
Chris@545
|
73 return m_source->getMaximumLevel();
|
Chris@545
|
74 }
|
Chris@545
|
75
|
Chris@1339
|
76 /**
|
Chris@1339
|
77 * Retrieve the peaks column at peak-cache column number col. This
|
Chris@1339
|
78 * will consist of the peak values in the underlying model from
|
Chris@1339
|
79 * columns (col * getColumnsPerPeak()) to ((col+1) *
|
Chris@1339
|
80 * getColumnsPerPeak() - 1) inclusive.
|
Chris@1339
|
81 */
|
Chris@1580
|
82 Column getColumn(int col) const override;
|
Chris@545
|
83
|
Chris@1580
|
84 float getValueAt(int col, int n) const override;
|
Chris@545
|
85
|
Chris@1580
|
86 QString getBinName(int n) const override {
|
Chris@545
|
87 return m_source->getBinName(n);
|
Chris@545
|
88 }
|
Chris@545
|
89
|
Chris@1580
|
90 bool shouldUseLogValueScale() const override {
|
Chris@545
|
91 return m_source->shouldUseLogValueScale();
|
Chris@545
|
92 }
|
Chris@545
|
93
|
Chris@1580
|
94 QString getTypeName() const override { return tr("Dense 3-D Peak Cache"); }
|
Chris@545
|
95
|
Chris@1580
|
96 int getCompletion() const override {
|
Chris@545
|
97 return m_source->getCompletion();
|
Chris@545
|
98 }
|
Chris@545
|
99
|
Chris@1679
|
100 QString toDelimitedDataString(QString, DataExportOptions,
|
Chris@1679
|
101 sv_frame_t, sv_frame_t) const override {
|
Chris@1679
|
102 return "";
|
Chris@1679
|
103 }
|
Chris@1679
|
104
|
Chris@545
|
105 protected slots:
|
Chris@545
|
106 void sourceModelChanged();
|
Chris@545
|
107 void sourceModelAboutToBeDeleted();
|
Chris@545
|
108
|
Chris@545
|
109 private:
|
Chris@1191
|
110 const DenseThreeDimensionalModel *m_source;
|
Chris@545
|
111 mutable EditableDenseThreeDimensionalModel *m_cache;
|
Chris@1153
|
112 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency
|
Chris@1153
|
113 // (vector of bool uses 1-bit elements)
|
Chris@1190
|
114 int m_columnsPerPeak;
|
Chris@545
|
115
|
Chris@929
|
116 bool haveColumn(int column) const;
|
Chris@929
|
117 void fillColumn(int column) const;
|
Chris@545
|
118 };
|
Chris@545
|
119
|
Chris@545
|
120
|
Chris@545
|
121 #endif
|