comparison data/model/WaveFileModel.cpp @ 179:0ed2b2e26b44

* Tidy up inheritance hierarchy of model classes -- remove ZoomConstraint as a base class (make it a member instead) and remove virtual inheritances of QObject (no longer necessary).
author Chris Cannam
date Thu, 05 Oct 2006 11:03:06 +0000
parents aff66ec5aea4
children bd1260261412
comparison
equal deleted inserted replaced
178:0e266fa2510f 179:0ed2b2e26b44
30 30
31 #include <cassert> 31 #include <cassert>
32 32
33 using std::cerr; 33 using std::cerr;
34 using std::endl; 34 using std::endl;
35
36 PowerOfSqrtTwoZoomConstraint
37 WaveFileModel::m_zoomConstraint;
35 38
36 WaveFileModel::WaveFileModel(QString path) : 39 WaveFileModel::WaveFileModel(QString path) :
37 m_path(path), 40 m_path(path),
38 m_myReader(true), 41 m_myReader(true),
39 m_fillThread(0), 42 m_fillThread(0),
219 std::cerr << "WARNING: Internal error: end <= start in WaveFileModel::getRanges (end = " << end << ", start = " << start << ", blocksize = " << blockSize << ")" << std::endl; 222 std::cerr << "WARNING: Internal error: end <= start in WaveFileModel::getRanges (end = " << end << ", start = " << start << ", blocksize = " << blockSize << ")" << std::endl;
220 return ranges; 223 return ranges;
221 } 224 }
222 225
223 int cacheType = 0; 226 int cacheType = 0;
224 int power = getMinCachePower(); 227 int power = m_zoomConstraint.getMinCachePower();
225 blockSize = getNearestBlockSize(blockSize, cacheType, power, 228 blockSize = m_zoomConstraint.getNearestBlockSize
226 ZoomConstraint::RoundUp); 229 (blockSize, cacheType, power, ZoomConstraint::RoundUp);
227 230
228 size_t channels = getChannelCount(); 231 size_t channels = getChannelCount();
229 232
230 if (cacheType != 0 && cacheType != 1) { 233 if (cacheType != 0 && cacheType != 1) {
231 234
275 const RangeBlock &cache = m_cache[cacheType]; 278 const RangeBlock &cache = m_cache[cacheType];
276 279
277 size_t cacheBlock, div; 280 size_t cacheBlock, div;
278 281
279 if (cacheType == 0) { 282 if (cacheType == 0) {
280 cacheBlock = (1 << getMinCachePower()); 283 cacheBlock = (1 << m_zoomConstraint.getMinCachePower());
281 div = (1 << power) / cacheBlock; 284 div = (1 << power) / cacheBlock;
282 } else { 285 } else {
283 cacheBlock = ((unsigned int)((1 << getMinCachePower()) * sqrt(2) + 0.01)); 286 cacheBlock = ((unsigned int)((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2) + 0.01));
284 div = ((unsigned int)((1 << power) * sqrt(2) + 0.01)) / cacheBlock; 287 div = ((unsigned int)((1 << power) * sqrt(2) + 0.01)) / cacheBlock;
285 } 288 }
286 289
287 size_t startIndex = start / cacheBlock; 290 size_t startIndex = start / cacheBlock;
288 size_t endIndex = end / cacheBlock; 291 size_t endIndex = end / cacheBlock;
440 443
441 void 444 void
442 WaveFileModel::RangeCacheFillThread::run() 445 WaveFileModel::RangeCacheFillThread::run()
443 { 446 {
444 size_t cacheBlockSize[2]; 447 size_t cacheBlockSize[2];
445 cacheBlockSize[0] = (1 << m_model.getMinCachePower()); 448 cacheBlockSize[0] = (1 << m_model.m_zoomConstraint.getMinCachePower());
446 cacheBlockSize[1] = ((unsigned int)((1 << m_model.getMinCachePower()) * 449 cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) *
447 sqrt(2) + 0.01)); 450 sqrt(2) + 0.01));
448 451
449 size_t frame = 0; 452 size_t frame = 0;
450 size_t readBlockSize = 16384; 453 size_t readBlockSize = 16384;
451 SampleBlock block; 454 SampleBlock block;