Mercurial > hg > svcore
comparison data/model/WaveFileModel.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 _WAVE_FILE_MODEL_H_ | |
17 #define _WAVE_FILE_MODEL_H_ | |
18 | |
19 #include "Thread.h" | |
20 #include <QMutex> | |
21 #include <QTimer> | |
22 | |
23 #include "RangeSummarisableTimeValueModel.h" | |
24 #include "PowerOfSqrtTwoZoomConstraint.h" | |
25 | |
26 #include <stdlib.h> | |
27 | |
28 class AudioFileReader; | |
29 | |
30 class WaveFileModel : public RangeSummarisableTimeValueModel, | |
31 virtual public PowerOfSqrtTwoZoomConstraint | |
32 { | |
33 Q_OBJECT | |
34 | |
35 public: | |
36 WaveFileModel(QString path); | |
37 ~WaveFileModel(); | |
38 | |
39 bool isOK() const; | |
40 bool isReady(int *) const; | |
41 | |
42 size_t getFrameCount() const; | |
43 size_t getChannelCount() const; | |
44 size_t getSampleRate() const; | |
45 | |
46 virtual Model *clone() const; | |
47 | |
48 float getValueMinimum() const { return -1.0f; } | |
49 float getValueMaximum() const { return 1.0f; } | |
50 | |
51 virtual size_t getStartFrame() const { return 0; } | |
52 virtual size_t getEndFrame() const { return getFrameCount(); } | |
53 | |
54 virtual size_t getValues(int channel, size_t start, size_t end, | |
55 float *buffer) const; | |
56 | |
57 virtual size_t getValues(int channel, size_t start, size_t end, | |
58 double *buffer) const; | |
59 | |
60 virtual RangeBlock getRanges(size_t channel, size_t start, size_t end, | |
61 size_t &blockSize) const; | |
62 | |
63 virtual Range getRange(size_t channel, size_t start, size_t end) const; | |
64 | |
65 virtual QString toXmlString(QString indent = "", | |
66 QString extraAttributes = "") const; | |
67 | |
68 protected slots: | |
69 void fillTimerTimedOut(); | |
70 void cacheFilled(); | |
71 | |
72 protected: | |
73 void initialize(); | |
74 | |
75 class RangeCacheFillThread : public Thread | |
76 { | |
77 public: | |
78 RangeCacheFillThread(WaveFileModel &model) : | |
79 m_model(model), m_fillExtent(0) { } | |
80 | |
81 size_t getFillExtent() const { return m_fillExtent; } | |
82 virtual void run(); | |
83 | |
84 protected: | |
85 WaveFileModel &m_model; | |
86 size_t m_fillExtent; | |
87 }; | |
88 | |
89 void fillCache(); | |
90 | |
91 QString m_path; | |
92 AudioFileReader *m_reader; | |
93 | |
94 RangeBlock m_cache[2]; // interleaved at two base resolutions | |
95 mutable QMutex m_mutex; | |
96 RangeCacheFillThread *m_fillThread; | |
97 QTimer *m_updateTimer; | |
98 size_t m_lastFillExtent; | |
99 bool m_exiting; | |
100 }; | |
101 | |
102 #endif |