Mercurial > hg > svcore
comparison data/model/WaveFileModel.cpp @ 843:e802e550a1f2
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 13:35:08 +0000 |
parents | 33fca917c800 |
children | 2896b8872834 59e7fe1b1003 |
comparison
equal
deleted
inserted
replaced
842:23d3a6eca5c3 | 843:e802e550a1f2 |
---|---|
30 | 30 |
31 #include <cassert> | 31 #include <cassert> |
32 | 32 |
33 //#define DEBUG_WAVE_FILE_MODEL 1 | 33 //#define DEBUG_WAVE_FILE_MODEL 1 |
34 | 34 |
35 using std::cerr; | |
36 using std::endl; | |
37 | |
38 PowerOfSqrtTwoZoomConstraint | 35 PowerOfSqrtTwoZoomConstraint |
39 WaveFileModel::m_zoomConstraint; | 36 WaveFileModel::m_zoomConstraint; |
40 | 37 |
41 WaveFileModel::WaveFileModel(FileSource source, size_t targetRate) : | 38 WaveFileModel::WaveFileModel(FileSource source, size_t targetRate) : |
42 m_source(source), | 39 m_source(source), |
189 // Always read these directly from the file. | 186 // Always read these directly from the file. |
190 // This is used for e.g. audio playback. | 187 // This is used for e.g. audio playback. |
191 // Could be much more efficient (although compiler optimisation will help) | 188 // Could be much more efficient (although compiler optimisation will help) |
192 | 189 |
193 #ifdef DEBUG_WAVE_FILE_MODEL | 190 #ifdef DEBUG_WAVE_FILE_MODEL |
194 std::cout << "WaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl; | 191 cout << "WaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << endl; |
195 #endif | 192 #endif |
196 | 193 |
197 if (start >= m_startFrame) { | 194 if (start >= m_startFrame) { |
198 start -= m_startFrame; | 195 start -= m_startFrame; |
199 } else { | 196 } else { |
251 size_t | 248 size_t |
252 WaveFileModel::getData(int channel, size_t start, size_t count, | 249 WaveFileModel::getData(int channel, size_t start, size_t count, |
253 double *buffer) const | 250 double *buffer) const |
254 { | 251 { |
255 #ifdef DEBUG_WAVE_FILE_MODEL | 252 #ifdef DEBUG_WAVE_FILE_MODEL |
256 std::cout << "WaveFileModel::getData(double)[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl; | 253 cout << "WaveFileModel::getData(double)[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << endl; |
257 #endif | 254 #endif |
258 | 255 |
259 if (start > m_startFrame) { | 256 if (start > m_startFrame) { |
260 start -= m_startFrame; | 257 start -= m_startFrame; |
261 } else { | 258 } else { |
309 WaveFileModel::getData(size_t fromchannel, size_t tochannel, | 306 WaveFileModel::getData(size_t fromchannel, size_t tochannel, |
310 size_t start, size_t count, | 307 size_t start, size_t count, |
311 float **buffer) const | 308 float **buffer) const |
312 { | 309 { |
313 #ifdef DEBUG_WAVE_FILE_MODEL | 310 #ifdef DEBUG_WAVE_FILE_MODEL |
314 std::cout << "WaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << ", " << buffer << std::endl; | 311 cout << "WaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << ", " << buffer << endl; |
315 #endif | 312 #endif |
316 | 313 |
317 size_t channels = getChannelCount(); | 314 size_t channels = getChannelCount(); |
318 | 315 |
319 if (fromchannel > tochannel) { | 316 if (fromchannel > tochannel) { |
320 std::cerr << "ERROR: WaveFileModel::getData: fromchannel (" | 317 cerr << "ERROR: WaveFileModel::getData: fromchannel (" |
321 << fromchannel << ") > tochannel (" << tochannel << ")" | 318 << fromchannel << ") > tochannel (" << tochannel << ")" |
322 << std::endl; | 319 << endl; |
323 return 0; | 320 return 0; |
324 } | 321 } |
325 | 322 |
326 if (tochannel >= channels) { | 323 if (tochannel >= channels) { |
327 std::cerr << "ERROR: WaveFileModel::getData: tochannel (" | 324 cerr << "ERROR: WaveFileModel::getData: tochannel (" |
328 << tochannel << ") >= channel count (" << channels << ")" | 325 << tochannel << ") >= channel count (" << channels << ")" |
329 << std::endl; | 326 << endl; |
330 return 0; | 327 return 0; |
331 } | 328 } |
332 | 329 |
333 if (fromchannel == tochannel) { | 330 if (fromchannel == tochannel) { |
334 return getData(fromchannel, start, count, buffer[0]); | 331 return getData(fromchannel, start, count, buffer[0]); |
700 | 697 |
701 if (updating && (frame + readBlockSize > m_frameCount)) break; | 698 if (updating && (frame + readBlockSize > m_frameCount)) break; |
702 | 699 |
703 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); | 700 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); |
704 | 701 |
705 // std::cerr << "block is " << block.size() << std::endl; | 702 // cerr << "block is " << block.size() << endl; |
706 | 703 |
707 for (int i = 0; i < readBlockSize; ++i) { | 704 for (int i = 0; i < readBlockSize; ++i) { |
708 | 705 |
709 if (channels * i + channels > block.size()) break; | 706 if (channels * i + channels > block.size()) break; |
710 | 707 |
753 if (m_model.m_exiting) break; | 750 if (m_model.m_exiting) break; |
754 | 751 |
755 m_fillExtent = frame; | 752 m_fillExtent = frame; |
756 } | 753 } |
757 | 754 |
758 // std::cerr << "WaveFileModel: inner loop ended" << std::endl; | 755 // cerr << "WaveFileModel: inner loop ended" << endl; |
759 | 756 |
760 first = false; | 757 first = false; |
761 if (m_model.m_exiting) break; | 758 if (m_model.m_exiting) break; |
762 if (updating) { | 759 if (updating) { |
763 // std::cerr << "sleeping..." << std::endl; | 760 // cerr << "sleeping..." << endl; |
764 sleep(1); | 761 sleep(1); |
765 } | 762 } |
766 } | 763 } |
767 | 764 |
768 if (!m_model.m_exiting) { | 765 if (!m_model.m_exiting) { |