comparison data/model/WaveFileModel.h @ 1069:32ab6c48efaa

Merge from branch tonioni
author Chris Cannam
date Mon, 20 Apr 2015 09:11:34 +0100
parents 0fd3661bcfff
children 9f4505ac9072
comparison
equal deleted inserted replaced
1036:682d64f05e72 1069:32ab6c48efaa
32 class WaveFileModel : public RangeSummarisableTimeValueModel 32 class WaveFileModel : public RangeSummarisableTimeValueModel
33 { 33 {
34 Q_OBJECT 34 Q_OBJECT
35 35
36 public: 36 public:
37 WaveFileModel(FileSource source, int targetRate = 0); 37 WaveFileModel(FileSource source, sv_samplerate_t targetRate = 0);
38 WaveFileModel(FileSource source, AudioFileReader *reader); 38 WaveFileModel(FileSource source, AudioFileReader *reader);
39 ~WaveFileModel(); 39 ~WaveFileModel();
40 40
41 bool isOK() const; 41 bool isOK() const;
42 bool isReady(int *) const; 42 bool isReady(int *) const;
43 43
44 const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } 44 const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; }
45 45
46 int getFrameCount() const; 46 sv_frame_t getFrameCount() const;
47 int getChannelCount() const; 47 int getChannelCount() const;
48 int getSampleRate() const; 48 sv_samplerate_t getSampleRate() const;
49 int getNativeRate() const; 49 sv_samplerate_t getNativeRate() const;
50 50
51 QString getTitle() const; 51 QString getTitle() const;
52 QString getMaker() const; 52 QString getMaker() const;
53 QString getLocation() const; 53 QString getLocation() const;
54 54
55 QString getLocalFilename() const; 55 QString getLocalFilename() const;
56 56
57 virtual Model *clone() const;
58
59 float getValueMinimum() const { return -1.0f; } 57 float getValueMinimum() const { return -1.0f; }
60 float getValueMaximum() const { return 1.0f; } 58 float getValueMaximum() const { return 1.0f; }
61 59
62 virtual int getStartFrame() const { return m_startFrame; } 60 virtual sv_frame_t getStartFrame() const { return m_startFrame; }
63 virtual int getEndFrame() const { return m_startFrame + getFrameCount(); } 61 virtual sv_frame_t getEndFrame() const { return m_startFrame + getFrameCount(); }
64 62
65 void setStartFrame(int startFrame) { m_startFrame = startFrame; } 63 void setStartFrame(sv_frame_t startFrame) { m_startFrame = startFrame; }
66 64
67 virtual int getData(int channel, int start, int count, 65 virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count,
68 float *buffer) const; 66 float *buffer) const;
69 67
70 virtual int getData(int channel, int start, int count, 68 virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count,
71 double *buffer) const; 69 double *buffer) const;
72 70
73 virtual int getData(int fromchannel, int tochannel, 71 virtual sv_frame_t getData(int fromchannel, int tochannel,
74 int start, int count, 72 sv_frame_t start, sv_frame_t count,
75 float **buffers) const; 73 float **buffers) const;
76 74
77 virtual int getSummaryBlockSize(int desired) const; 75 virtual int getSummaryBlockSize(int desired) const;
78 76
79 virtual void getSummaries(int channel, int start, int count, 77 virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count,
80 RangeBlock &ranges, 78 RangeBlock &ranges,
81 int &blockSize) const; 79 int &blockSize) const;
82 80
83 virtual Range getSummary(int channel, int start, int count) const; 81 virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const;
84 82
85 QString getTypeName() const { return tr("Wave File"); } 83 QString getTypeName() const { return tr("Wave File"); }
86 84
87 virtual void toXml(QTextStream &out, 85 virtual void toXml(QTextStream &out,
88 QString indent = "", 86 QString indent = "",
100 public: 98 public:
101 RangeCacheFillThread(WaveFileModel &model) : 99 RangeCacheFillThread(WaveFileModel &model) :
102 m_model(model), m_fillExtent(0), 100 m_model(model), m_fillExtent(0),
103 m_frameCount(model.getFrameCount()) { } 101 m_frameCount(model.getFrameCount()) { }
104 102
105 int getFillExtent() const { return m_fillExtent; } 103 sv_frame_t getFillExtent() const { return m_fillExtent; }
106 virtual void run(); 104 virtual void run();
107 105
108 protected: 106 protected:
109 WaveFileModel &m_model; 107 WaveFileModel &m_model;
110 int m_fillExtent; 108 sv_frame_t m_fillExtent;
111 int m_frameCount; 109 sv_frame_t m_frameCount;
112 }; 110 };
113 111
114 void fillCache(); 112 void fillCache();
115 113
116 FileSource m_source; 114 FileSource m_source;
117 QString m_path; 115 QString m_path;
118 AudioFileReader *m_reader; 116 AudioFileReader *m_reader;
119 bool m_myReader; 117 bool m_myReader;
120 118
121 int m_startFrame; 119 sv_frame_t m_startFrame;
122 120
123 RangeBlock m_cache[2]; // interleaved at two base resolutions 121 RangeBlock m_cache[2]; // interleaved at two base resolutions
124 mutable QMutex m_mutex; 122 mutable QMutex m_mutex;
125 RangeCacheFillThread *m_fillThread; 123 RangeCacheFillThread *m_fillThread;
126 QTimer *m_updateTimer; 124 QTimer *m_updateTimer;
127 int m_lastFillExtent; 125 sv_frame_t m_lastFillExtent;
128 bool m_exiting; 126 bool m_exiting;
129 static PowerOfSqrtTwoZoomConstraint m_zoomConstraint; 127 static PowerOfSqrtTwoZoomConstraint m_zoomConstraint;
130 128
131 mutable SampleBlock m_directRead; 129 mutable SampleBlock m_directRead;
132 mutable int m_lastDirectReadStart; 130 mutable sv_frame_t m_lastDirectReadStart;
133 mutable int m_lastDirectReadCount; 131 mutable sv_frame_t m_lastDirectReadCount;
134 mutable QMutex m_directReadMutex; 132 mutable QMutex m_directReadMutex;
135 }; 133 };
136 134
137 #endif 135 #endif