comparison data/model/WaveFileModel.cpp @ 290:92e8dbde73cd

* Revert revision 713. We do like QStrings after all.
author Chris Cannam
date Fri, 24 Aug 2007 11:41:48 +0000
parents 7b96b3bd4bae
children 8c5762634f42
comparison
equal deleted inserted replaced
289:3020904de772 290:92e8dbde73cd
44 m_fillThread(0), 44 m_fillThread(0),
45 m_updateTimer(0), 45 m_updateTimer(0),
46 m_lastFillExtent(0), 46 m_lastFillExtent(0),
47 m_exiting(false) 47 m_exiting(false)
48 { 48 {
49 m_reader = AudioFileReaderFactory::createReader(path.toStdString()); 49 m_reader = AudioFileReaderFactory::createReader(path);
50 setObjectName(m_reader->getTitle().c_str()); 50 setObjectName(m_reader->getTitle());
51 if (objectName() == "") setObjectName(QFileInfo(path).fileName()); 51 if (objectName() == "") setObjectName(QFileInfo(path).fileName());
52 if (isOK()) fillCache(); 52 if (isOK()) fillCache();
53 } 53 }
54 54
55 WaveFileModel::WaveFileModel(QString path, QString originalLocation) : 55 WaveFileModel::WaveFileModel(QString path, QString originalLocation) :
58 m_fillThread(0), 58 m_fillThread(0),
59 m_updateTimer(0), 59 m_updateTimer(0),
60 m_lastFillExtent(0), 60 m_lastFillExtent(0),
61 m_exiting(false) 61 m_exiting(false)
62 { 62 {
63 m_reader = AudioFileReaderFactory::createReader(path.toStdString()); 63 m_reader = AudioFileReaderFactory::createReader(path);
64 setObjectName(m_reader->getTitle().c_str()); 64 setObjectName(m_reader->getTitle());
65 if (objectName() == "") setObjectName(QFileInfo(originalLocation).fileName()); 65 if (objectName() == "") setObjectName(QFileInfo(originalLocation).fileName());
66 if (isOK()) fillCache(); 66 if (isOK()) fillCache();
67 } 67 }
68 68
69 WaveFileModel::WaveFileModel(QString path, AudioFileReader *reader) : 69 WaveFileModel::WaveFileModel(QString path, AudioFileReader *reader) :
73 m_updateTimer(0), 73 m_updateTimer(0),
74 m_lastFillExtent(0), 74 m_lastFillExtent(0),
75 m_exiting(false) 75 m_exiting(false)
76 { 76 {
77 m_reader = reader; 77 m_reader = reader;
78 setObjectName(m_reader->getTitle().c_str()); 78 setObjectName(m_reader->getTitle());
79 if (objectName() == "") setObjectName(QFileInfo(path).fileName()); 79 if (objectName() == "") setObjectName(QFileInfo(path).fileName());
80 fillCache(); 80 fillCache();
81 } 81 }
82 82
83 WaveFileModel::~WaveFileModel() 83 WaveFileModel::~WaveFileModel()
169 #ifdef DEBUG_WAVE_FILE_MODEL 169 #ifdef DEBUG_WAVE_FILE_MODEL
170 // std::cerr << "WaveFileModel::getValues(" << channel << ", " 170 // std::cerr << "WaveFileModel::getValues(" << channel << ", "
171 // << start << ", " << end << "): calling reader" << std::endl; 171 // << start << ", " << end << "): calling reader" << std::endl;
172 #endif 172 #endif
173 173
174 AudioFileReader::SampleBlock frames; 174 SampleBlock frames;
175 m_reader->getInterleavedFrames(start, end - start, frames); 175 m_reader->getInterleavedFrames(start, end - start, frames);
176 176
177 size_t i = 0; 177 size_t i = 0;
178 178
179 int ch0 = channel, ch1 = channel, channels = getChannelCount(); 179 int ch0 = channel, ch1 = channel, channels = getChannelCount();
211 assert(end >= start); 211 assert(end >= start);
212 } 212 }
213 213
214 if (!m_reader || !m_reader->isOK()) return 0; 214 if (!m_reader || !m_reader->isOK()) return 0;
215 215
216 AudioFileReader::SampleBlock frames; 216 SampleBlock frames;
217 m_reader->getInterleavedFrames(start, end - start, frames); 217 m_reader->getInterleavedFrames(start, end - start, frames);
218 218
219 size_t i = 0; 219 size_t i = 0;
220 220
221 int ch0 = channel, ch1 = channel, channels = getChannelCount(); 221 int ch0 = channel, ch1 = channel, channels = getChannelCount();
270 // for stereo files, in two separate calls to this method. 270 // for stereo files, in two separate calls to this method.
271 // We could fairly trivially handle this for most cases that 271 // We could fairly trivially handle this for most cases that
272 // matter by putting a single cache in getInterleavedFrames 272 // matter by putting a single cache in getInterleavedFrames
273 // for short queries. 273 // for short queries.
274 274
275 AudioFileReader::SampleBlock frames; 275 SampleBlock frames;
276 m_reader->getInterleavedFrames(start, end - start, frames); 276 m_reader->getInterleavedFrames(start, end - start, frames);
277 float max = 0.0, min = 0.0, total = 0.0; 277 float max = 0.0, min = 0.0, total = 0.0;
278 size_t i = 0, count = 0; 278 size_t i = 0, count = 0;
279 279
280 while (i < end - start) { 280 while (i < end - start) {
476 cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) * 476 cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) *
477 sqrt(2) + 0.01)); 477 sqrt(2) + 0.01));
478 478
479 size_t frame = 0; 479 size_t frame = 0;
480 size_t readBlockSize = 16384; 480 size_t readBlockSize = 16384;
481 AudioFileReader::SampleBlock block; 481 SampleBlock block;
482 482
483 if (!m_model.isOK()) return; 483 if (!m_model.isOK()) return;
484 484
485 size_t channels = m_model.getChannelCount(); 485 size_t channels = m_model.getChannelCount();
486 bool updating = m_model.m_reader->isUpdating(); 486 bool updating = m_model.m_reader->isUpdating();