Mercurial > hg > svcore
comparison data/model/RangeSummarisableTimeValueModel.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 | 0ed2b2e26b44 |
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 _RANGE_SUMMARISABLE_TIME_VALUE_MODEL_H_ | |
17 #define _RANGE_SUMMARISABLE_TIME_VALUE_MODEL_H_ | |
18 | |
19 #include <QObject> | |
20 | |
21 #include "DenseTimeValueModel.h" | |
22 #include "base/ZoomConstraint.h" | |
23 | |
24 /** | |
25 * Base class for models containing dense two-dimensional data (value | |
26 * against time) that may be meaningfully represented in a zoomed view | |
27 * using min/max range summaries. Audio waveform data is an obvious | |
28 * example: think "peaks and minima" for "ranges". | |
29 */ | |
30 | |
31 class RangeSummarisableTimeValueModel : public DenseTimeValueModel, | |
32 virtual public ZoomConstraint, | |
33 virtual public QObject | |
34 { | |
35 Q_OBJECT | |
36 | |
37 public: | |
38 struct Range | |
39 { | |
40 float min; | |
41 float max; | |
42 float absmean; | |
43 Range() : | |
44 min(0.f), max(0.f), absmean(0.f) { } | |
45 Range(const Range &r) : | |
46 min(r.min), max(r.max), absmean(r.absmean) { } | |
47 Range(float min_, float max_, float absmean_) : | |
48 min(min_), max(max_), absmean(absmean_) { } | |
49 }; | |
50 | |
51 typedef std::vector<Range> RangeBlock; | |
52 | |
53 /** | |
54 * Return ranges between the given start and end frames, | |
55 * summarised at the given block size. ((end - start + 1) / | |
56 * blockSize) ranges should ideally be returned. | |
57 * | |
58 * If the given block size is not supported by this model | |
59 * (according to its zoom constraint), also modify the blockSize | |
60 * parameter so as to return the block size that was actually | |
61 * obtained. | |
62 */ | |
63 virtual RangeBlock getRanges(size_t channel, size_t start, size_t end, | |
64 size_t &blockSize) const = 0; | |
65 | |
66 /** | |
67 * Return the range between the given start and end frames, | |
68 * summarised at a block size equal to the distance between start | |
69 * and end frames. | |
70 */ | |
71 virtual Range getRange(size_t channel, size_t start, size_t end) const = 0; | |
72 }; | |
73 | |
74 #endif | |
75 |