comparison data/model/WritableWaveFileModel.cpp @ 1766:85b9b466a59f

Merge from branch by-id
author Chris Cannam
date Wed, 17 Jul 2019 14:24:51 +0100
parents 6d09d68165a4
children dffc70996f54
comparison
equal deleted inserted replaced
1730:649ac57c5a2d 1766:85b9b466a59f
17 17
18 #include "ReadOnlyWaveFileModel.h" 18 #include "ReadOnlyWaveFileModel.h"
19 19
20 #include "base/TempDirectory.h" 20 #include "base/TempDirectory.h"
21 #include "base/Exceptions.h" 21 #include "base/Exceptions.h"
22 #include "base/PlayParameterRepository.h"
22 23
23 #include "fileio/WavFileWriter.h" 24 #include "fileio/WavFileWriter.h"
24 #include "fileio/WavFileReader.h" 25 #include "fileio/WavFileReader.h"
25 26
26 #include <QDir> 27 #include <QDir>
94 try { 95 try {
95 // Temp dir is exclusive to this run of the application, 96 // Temp dir is exclusive to this run of the application,
96 // so the filename only needs to be unique within that - 97 // so the filename only needs to be unique within that -
97 // model ID should be ok 98 // model ID should be ok
98 QDir dir(TempDirectory::getInstance()->getPath()); 99 QDir dir(TempDirectory::getInstance()->getPath());
99 path = dir.filePath(QString("written_%1.wav").arg(getId())); 100 path = dir.filePath(QString("written_%1.wav")
101 .arg(getId().untyped));
100 } catch (const DirectoryCreationFailed &f) { 102 } catch (const DirectoryCreationFailed &f) {
101 SVCERR << "WritableWaveFileModel: Failed to create temporary directory" << endl; 103 SVCERR << "WritableWaveFileModel: Failed to create temporary directory" << endl;
102 return; 104 return;
103 } 105 }
104 } 106 }
124 if (m_normalisation != Normalisation::None) { 126 if (m_normalisation != Normalisation::None) {
125 127
126 // Temp dir is exclusive to this run of the application, so 128 // Temp dir is exclusive to this run of the application, so
127 // the filename only needs to be unique within that 129 // the filename only needs to be unique within that
128 QDir dir(TempDirectory::getInstance()->getPath()); 130 QDir dir(TempDirectory::getInstance()->getPath());
129 m_temporaryPath = dir.filePath(QString("prenorm_%1.wav").arg(getId())); 131 m_temporaryPath = dir.filePath(QString("prenorm_%1.wav")
132 .arg(getId().untyped));
130 133
131 m_temporaryWriter = new WavFileWriter 134 m_temporaryWriter = new WavFileWriter
132 (m_temporaryPath, m_sampleRate, m_channels, 135 (m_temporaryPath, m_sampleRate, m_channels,
133 WavFileWriter::WriteToTarget); 136 WavFileWriter::WriteToTarget);
134 137
156 m_model->setStartFrame(m_startFrame); 159 m_model->setStartFrame(m_startFrame);
157 160
158 connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); 161 connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged()));
159 connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), 162 connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
160 this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); 163 this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)));
164
165 PlayParameterRepository::getInstance()->addPlayable
166 (getId().untyped, this);
161 } 167 }
162 168
163 WritableWaveFileModel::~WritableWaveFileModel() 169 WritableWaveFileModel::~WritableWaveFileModel()
164 { 170 {
171 PlayParameterRepository::getInstance()->removePlayable
172 (getId().untyped);
173
165 delete m_model; 174 delete m_model;
166 delete m_targetWriter; 175 delete m_targetWriter;
167 delete m_temporaryWriter; 176 delete m_temporaryWriter;
168 delete m_reader; 177 delete m_reader;
169 } 178 }
245 normaliseToTarget(); 254 normaliseToTarget();
246 } 255 }
247 256
248 m_reader->updateDone(); 257 m_reader->updateDone();
249 m_proportion = 100; 258 m_proportion = 100;
250 emit modelChanged(); 259 emit modelChanged(getId());
251 emit writeCompleted(); 260 emit writeCompleted(getId());
252 } 261 }
253 262
254 void 263 void
255 WritableWaveFileModel::normaliseToTarget() 264 WritableWaveFileModel::normaliseToTarget()
256 { 265 {