comparison data/model/WritableWaveFileModel.cpp @ 1124:efea94b04d5a 3.0-integration

Merge from branch recording
author Chris Cannam
date Thu, 20 Aug 2015 13:15:19 +0100
parents 4d9816ba0ebe 133747edd76c
children e994747fb9dd
comparison
equal deleted inserted replaced
1118:fbc43d5dc3d1 1124:efea94b04d5a
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "WritableWaveFileModel.h" 16 #include "WritableWaveFileModel.h"
17 17
18 #include "ReadOnlyWaveFileModel.h"
19
18 #include "base/TempDirectory.h" 20 #include "base/TempDirectory.h"
19 #include "base/Exceptions.h" 21 #include "base/Exceptions.h"
20 22
21 #include "fileio/WavFileWriter.h" 23 #include "fileio/WavFileWriter.h"
22 #include "fileio/WavFileReader.h" 24 #include "fileio/WavFileReader.h"
74 delete m_reader; 76 delete m_reader;
75 m_reader = 0; 77 m_reader = 0;
76 return; 78 return;
77 } 79 }
78 80
79 m_model = new WaveFileModel(source, m_reader); 81 m_model = new ReadOnlyWaveFileModel(source, m_reader);
80 if (!m_model->isOK()) { 82 if (!m_model->isOK()) {
81 cerr << "WritableWaveFileModel: Error in creating wave file model" << endl; 83 cerr << "WritableWaveFileModel: Error in creating wave file model" << endl;
82 delete m_model; 84 delete m_model;
83 m_model = 0; 85 m_model = 0;
84 delete m_reader; 86 delete m_reader;
213 void 215 void
214 WritableWaveFileModel::toXml(QTextStream &out, 216 WritableWaveFileModel::toXml(QTextStream &out,
215 QString indent, 217 QString indent,
216 QString extraAttributes) const 218 QString extraAttributes) const
217 { 219 {
218 // We don't actually write the data to XML. We just write a brief 220 // The assumption here is that the underlying wave file has
219 // description of the model. Any code that uses this class is 221 // already been saved somewhere (its location is available through
220 // going to need to be aware that it will have to make separate 222 // getLocation()) and that the code that uses this class is
221 // arrangements for the audio file itself. 223 // dealing with the problem of making sure it remains available.
224 // We just write this out as if it were a normal wave file.
222 225
223 Model::toXml 226 Model::toXml
224 (out, indent, 227 (out, indent,
225 QString("type=\"writablewavefile\" file=\"%1\" channels=\"%2\" %3") 228 QString("type=\"wavefile\" file=\"%1\" subtype=\"writable\" %2")
226 .arg(encodeEntities(m_writer->getPath())) 229 .arg(encodeEntities(m_writer->getPath()))
227 .arg(m_model->getChannelCount()).arg(extraAttributes)); 230 .arg(extraAttributes));
228 } 231 }
229 232