comparison data/model/WritableWaveFileModel.cpp @ 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
28 #include <iostream> 28 #include <iostream>
29 #include <stdint.h> 29 #include <stdint.h>
30 30
31 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 31 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1
32 32
33 WritableWaveFileModel::WritableWaveFileModel(int sampleRate, 33 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate,
34 int channels, 34 int channels,
35 QString path) : 35 QString path) :
36 m_model(0), 36 m_model(0),
37 m_writer(0), 37 m_writer(0),
38 m_reader(0), 38 m_reader(0),
84 return; 84 return;
85 } 85 }
86 m_model->setStartFrame(m_startFrame); 86 m_model->setStartFrame(m_startFrame);
87 87
88 connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); 88 connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged()));
89 connect(m_model, SIGNAL(modelChangedWithin(int, int)), 89 connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
90 this, SIGNAL(modelChangedWithin(int, int))); 90 this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)));
91 } 91 }
92 92
93 WritableWaveFileModel::~WritableWaveFileModel() 93 WritableWaveFileModel::~WritableWaveFileModel()
94 { 94 {
95 delete m_model; 95 delete m_model;
96 delete m_writer; 96 delete m_writer;
97 delete m_reader; 97 delete m_reader;
98 } 98 }
99 99
100 void 100 void
101 WritableWaveFileModel::setStartFrame(int startFrame) 101 WritableWaveFileModel::setStartFrame(sv_frame_t startFrame)
102 { 102 {
103 m_startFrame = startFrame; 103 m_startFrame = startFrame;
104 if (m_model) m_model->setStartFrame(startFrame); 104 if (m_model) m_model->setStartFrame(startFrame);
105 } 105 }
106 106
107 bool 107 bool
108 WritableWaveFileModel::addSamples(float **samples, int count) 108 WritableWaveFileModel::addSamples(float **samples, sv_frame_t count)
109 { 109 {
110 if (!m_writer) return false; 110 if (!m_writer) return false;
111 111
112 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL 112 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
113 // SVDEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl; 113 // SVDEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl;
160 if (completion == 100) { 160 if (completion == 100) {
161 if (m_reader) m_reader->updateDone(); 161 if (m_reader) m_reader->updateDone();
162 } 162 }
163 } 163 }
164 164
165 int 165 sv_frame_t
166 WritableWaveFileModel::getFrameCount() const 166 WritableWaveFileModel::getFrameCount() const
167 { 167 {
168 // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl; 168 // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl;
169 return m_frameCount; 169 return m_frameCount;
170 } 170 }
171 171
172 Model * 172 sv_frame_t
173 WritableWaveFileModel::clone() const 173 WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count,
174 {
175 assert(0); //!!!
176 return 0;
177 }
178
179 int
180 WritableWaveFileModel::getData(int channel, int start, int count,
181 float *buffer) const 174 float *buffer) const
182 { 175 {
183 if (!m_model || m_model->getChannelCount() == 0) return 0; 176 if (!m_model || m_model->getChannelCount() == 0) return 0;
184 return m_model->getData(channel, start, count, buffer); 177 return m_model->getData(channel, start, count, buffer);
185 } 178 }
186 179
187 int 180 sv_frame_t
188 WritableWaveFileModel::getData(int channel, int start, int count, 181 WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count,
189 double *buffer) const 182 double *buffer) const
190 { 183 {
191 if (!m_model || m_model->getChannelCount() == 0) return 0; 184 if (!m_model || m_model->getChannelCount() == 0) return 0;
192 return m_model->getData(channel, start, count, buffer); 185 return m_model->getData(channel, start, count, buffer);
193 } 186 }
194 187
195 int 188 sv_frame_t
196 WritableWaveFileModel::getData(int fromchannel, int tochannel, 189 WritableWaveFileModel::getData(int fromchannel, int tochannel,
197 int start, int count, 190 sv_frame_t start, sv_frame_t count,
198 float **buffers) const 191 float **buffers) const
199 { 192 {
200 if (!m_model || m_model->getChannelCount() == 0) return 0; 193 if (!m_model || m_model->getChannelCount() == 0) return 0;
201 return m_model->getData(fromchannel, tochannel, start, count, buffers); 194 return m_model->getData(fromchannel, tochannel, start, count, buffers);
202 } 195 }
207 if (!m_model) return desired; 200 if (!m_model) return desired;
208 return m_model->getSummaryBlockSize(desired); 201 return m_model->getSummaryBlockSize(desired);
209 } 202 }
210 203
211 void 204 void
212 WritableWaveFileModel::getSummaries(int channel, int start, int count, 205 WritableWaveFileModel::getSummaries(int channel, sv_frame_t start, sv_frame_t count,
213 RangeBlock &ranges, 206 RangeBlock &ranges,
214 int &blockSize) const 207 int &blockSize) const
215 { 208 {
216 ranges.clear(); 209 ranges.clear();
217 if (!m_model || m_model->getChannelCount() == 0) return; 210 if (!m_model || m_model->getChannelCount() == 0) return;
218 m_model->getSummaries(channel, start, count, ranges, blockSize); 211 m_model->getSummaries(channel, start, count, ranges, blockSize);
219 } 212 }
220 213
221 WritableWaveFileModel::Range 214 WritableWaveFileModel::Range
222 WritableWaveFileModel::getSummary(int channel, int start, int count) const 215 WritableWaveFileModel::getSummary(int channel, sv_frame_t start, sv_frame_t count) const
223 { 216 {
224 if (!m_model || m_model->getChannelCount() == 0) return Range(); 217 if (!m_model || m_model->getChannelCount() == 0) return Range();
225 return m_model->getSummary(channel, start, count); 218 return m_model->getSummary(channel, start, count);
226 } 219 }
227 220