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@769
|
24 #include <stdint.h>
|
chris@769
|
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@319
|
38 RangeSummarisableTimeValueModel() { }
|
Chris@297
|
39
|
Chris@410
|
40 class Range
|
Chris@410
|
41 {
|
Chris@410
|
42 public:
|
Chris@410
|
43 Range() :
|
Chris@410
|
44 m_min(0.f), m_max(0.f), m_absmean(0.f) { }
|
Chris@410
|
45 Range(const Range &r) :
|
Chris@410
|
46 m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { }
|
Chris@410
|
47 Range(float min, float max, float absmean) :
|
Chris@410
|
48 m_min(min), m_max(max), m_absmean(absmean) { }
|
Chris@410
|
49
|
Chris@410
|
50 float min() const { return m_min; }
|
Chris@410
|
51 float max() const { return m_max; }
|
Chris@410
|
52 float absmean() const { return m_absmean; }
|
Chris@410
|
53
|
Chris@410
|
54 void setMin(float min) { m_min = min; }
|
Chris@410
|
55 void setMax(float max) { m_max = max; }
|
Chris@410
|
56 void setAbsmean(float absmean) { m_absmean = absmean; }
|
Chris@410
|
57
|
Chris@410
|
58 private:
|
Chris@410
|
59 float m_min;
|
Chris@410
|
60 float m_max;
|
Chris@410
|
61 float m_absmean;
|
Chris@410
|
62 };
|
Chris@147
|
63
|
Chris@147
|
64 typedef std::vector<Range> RangeBlock;
|
Chris@147
|
65
|
Chris@147
|
66 /**
|
Chris@300
|
67 * Return ranges from the given start frame, corresponding to the
|
Chris@300
|
68 * given number of underlying sample frames, summarised at the
|
Chris@300
|
69 * given block size. duration / blockSize ranges should ideally
|
Chris@300
|
70 * be returned.
|
Chris@147
|
71 *
|
Chris@147
|
72 * If the given block size is not supported by this model
|
Chris@147
|
73 * (according to its zoom constraint), also modify the blockSize
|
Chris@147
|
74 * parameter so as to return the block size that was actually
|
Chris@147
|
75 * obtained.
|
Chris@147
|
76 */
|
Chris@300
|
77 virtual void getSummaries(size_t channel, size_t start, size_t count,
|
Chris@300
|
78 RangeBlock &ranges,
|
Chris@300
|
79 size_t &blockSize) const = 0;
|
Chris@147
|
80
|
Chris@147
|
81 /**
|
Chris@300
|
82 * Return the range from the given start frame, corresponding to
|
Chris@300
|
83 * the given number of underlying sample frames, summarised at a
|
Chris@300
|
84 * block size equal to the distance between start and end frames.
|
Chris@147
|
85 */
|
Chris@300
|
86 virtual Range getSummary(size_t channel, size_t start, size_t count) const = 0;
|
Chris@345
|
87
|
Chris@377
|
88 virtual size_t getSummaryBlockSize(size_t desired) const = 0;
|
Chris@377
|
89
|
Chris@345
|
90 QString getTypeName() const { return tr("Range-Summarisable Time-Value"); }
|
Chris@147
|
91 };
|
Chris@147
|
92
|
Chris@147
|
93 #endif
|
Chris@147
|
94
|