Mercurial > hg > svcore
comparison data/model/WaveFileModel.cpp @ 285:20028c634494
* change some QStrings to std::strings etc
author | Chris Cannam |
---|---|
date | Thu, 09 Aug 2007 16:29:29 +0000 |
parents | 7802b0e2b0ff |
children | 7b96b3bd4bae |
comparison
equal
deleted
inserted
replaced
284:41d64b873d87 | 285:20028c634494 |
---|---|
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); | 49 m_reader = AudioFileReaderFactory::createReader(path.toStdString()); |
50 setObjectName(m_reader->getTitle()); | 50 setObjectName(m_reader->getTitle().c_str()); |
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); | 63 m_reader = AudioFileReaderFactory::createReader(path.toStdString()); |
64 setObjectName(m_reader->getTitle()); | 64 setObjectName(m_reader->getTitle().c_str()); |
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()); | 78 setObjectName(m_reader->getTitle().c_str()); |
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 SampleBlock frames; | 174 AudioFileReader::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 SampleBlock frames; | 216 AudioFileReader::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 SampleBlock frames; | 275 AudioFileReader::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 SampleBlock block; | 481 AudioFileReader::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(); |