comparison data/fileio/WavFileWriter.cpp @ 1520:954d0cf29ca7 import-audio-data

Switch the normalisation option in WritableWaveFileModel from normalising on read to normalising on write, so that the saved file is already normalised and therefore can be read again without having to remember to normalise it
author Chris Cannam
date Wed, 12 Sep 2018 13:56:56 +0100
parents b837ccdd4946
children 8988b27ebf38
comparison
equal deleted inserted replaced
1519:fbe8afdfa8a6 1520:954d0cf29ca7
18 #include "model/DenseTimeValueModel.h" 18 #include "model/DenseTimeValueModel.h"
19 #include "base/Selection.h" 19 #include "base/Selection.h"
20 #include "base/TempWriteFile.h" 20 #include "base/TempWriteFile.h"
21 #include "base/Exceptions.h" 21 #include "base/Exceptions.h"
22 #include "base/Debug.h" 22 #include "base/Debug.h"
23
24 #include <bqvec/Allocators.h>
25 #include <bqvec/VectorOps.h>
23 26
24 #include <QFileInfo> 27 #include <QFileInfo>
25 28
26 #include <iostream> 29 #include <iostream>
27 #include <cmath> 30 #include <cmath>
194 .arg(written).arg(count); 197 .arg(written).arg(count);
195 } 198 }
196 199
197 return isOK(); 200 return isOK();
198 } 201 }
199 202
203 bool
204 WavFileWriter::putInterleavedFrames(const floatvec_t &frames)
205 {
206 sv_frame_t count = frames.size() / m_channels;
207 float **samples = breakfastquay::allocate_channels<float>(m_channels, count);
208 breakfastquay::v_deinterleave(samples, frames.data(), m_channels, count);
209 bool result = writeSamples(samples, count);
210 breakfastquay::deallocate_channels(samples, m_channels);
211 return result;
212 }
213
200 bool 214 bool
201 WavFileWriter::close() 215 WavFileWriter::close()
202 { 216 {
203 if (m_file) { 217 if (m_file) {
204 sf_close(m_file); 218 sf_close(m_file);