Mercurial > hg > svcore
comparison data/model/WritableWaveFileModel.cpp @ 847:2d53205f70cd tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:37:01 +0000 |
parents | e802e550a1f2 |
children | 59e7fe1b1003 |
comparison
equal
deleted
inserted
replaced
841:226733f3cf3f | 847:2d53205f70cd |
---|---|
46 try { | 46 try { |
47 QDir dir(TempDirectory::getInstance()->getPath()); | 47 QDir dir(TempDirectory::getInstance()->getPath()); |
48 path = dir.filePath(QString("written_%1.wav") | 48 path = dir.filePath(QString("written_%1.wav") |
49 .arg((intptr_t)this)); | 49 .arg((intptr_t)this)); |
50 } catch (DirectoryCreationFailed f) { | 50 } catch (DirectoryCreationFailed f) { |
51 std::cerr << "WritableWaveFileModel: Failed to create temporary directory" << std::endl; | 51 cerr << "WritableWaveFileModel: Failed to create temporary directory" << endl; |
52 return; | 52 return; |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 // Write directly to the target file, so that we can do | 56 // Write directly to the target file, so that we can do |
57 // incremental writes and concurrent reads | 57 // incremental writes and concurrent reads |
58 m_writer = new WavFileWriter(path, sampleRate, channels, | 58 m_writer = new WavFileWriter(path, sampleRate, channels, |
59 WavFileWriter::WriteToTarget); | 59 WavFileWriter::WriteToTarget); |
60 if (!m_writer->isOK()) { | 60 if (!m_writer->isOK()) { |
61 std::cerr << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError() << std::endl; | 61 cerr << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError() << endl; |
62 delete m_writer; | 62 delete m_writer; |
63 m_writer = 0; | 63 m_writer = 0; |
64 return; | 64 return; |
65 } | 65 } |
66 | 66 |
67 FileSource source(m_writer->getPath()); | 67 FileSource source(m_writer->getPath()); |
68 | 68 |
69 m_reader = new WavFileReader(source, true); | 69 m_reader = new WavFileReader(source, true); |
70 if (!m_reader->getError().isEmpty()) { | 70 if (!m_reader->getError().isEmpty()) { |
71 std::cerr << "WritableWaveFileModel: Error in creating wave file reader" << std::endl; | 71 cerr << "WritableWaveFileModel: Error in creating wave file reader" << endl; |
72 delete m_reader; | 72 delete m_reader; |
73 m_reader = 0; | 73 m_reader = 0; |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 m_model = new WaveFileModel(source, m_reader); | 77 m_model = new WaveFileModel(source, m_reader); |
78 if (!m_model->isOK()) { | 78 if (!m_model->isOK()) { |
79 std::cerr << "WritableWaveFileModel: Error in creating wave file model" << std::endl; | 79 cerr << "WritableWaveFileModel: Error in creating wave file model" << endl; |
80 delete m_model; | 80 delete m_model; |
81 m_model = 0; | 81 m_model = 0; |
82 delete m_reader; | 82 delete m_reader; |
83 m_reader = 0; | 83 m_reader = 0; |
84 return; | 84 return; |
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; |
114 #endif | 114 #endif |
115 | 115 |
116 if (!m_writer->writeSamples(samples, count)) { | 116 if (!m_writer->writeSamples(samples, count)) { |
117 std::cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError() << std::endl; | 117 cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError() << endl; |
118 return false; | 118 return false; |
119 } | 119 } |
120 | 120 |
121 m_frameCount += count; | 121 m_frameCount += count; |
122 | 122 |