comparison data/fileio/WavFileWriter.cpp @ 1428:87ae75da6527

Convert some cerrs to SVCERRs. Apart from anything else, this makes MSVC2017 happy
author Chris Cannam
date Thu, 01 Mar 2018 14:43:40 +0000
parents 1bc6f70cb4c7
children 48e9f538e6e9
comparison
equal deleted inserted replaced
1427:622d193a00dc 1428:87ae75da6527
17 17
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 23
23 #include <QFileInfo> 24 #include <QFileInfo>
24 25
25 #include <iostream> 26 #include <iostream>
26 #include <cmath> 27 #include <cmath>
28 #include <string>
27 29
28 using namespace std; 30 using namespace std;
29 31
30 WavFileWriter::WavFileWriter(QString path, 32 WavFileWriter::WavFileWriter(QString path,
31 sv_samplerate_t sampleRate, 33 sv_samplerate_t sampleRate,
39 { 41 {
40 SF_INFO fileInfo; 42 SF_INFO fileInfo;
41 43
42 int fileRate = int(round(m_sampleRate)); 44 int fileRate = int(round(m_sampleRate));
43 if (m_sampleRate != sv_samplerate_t(fileRate)) { 45 if (m_sampleRate != sv_samplerate_t(fileRate)) {
44 cerr << "WavFileWriter: WARNING: Non-integer sample rate " 46 SVCERR << "WavFileWriter: WARNING: Non-integer sample rate "
45 << m_sampleRate << " presented, rounding to " << fileRate 47 << m_sampleRate << " presented, rounding to " << fileRate
46 << endl; 48 << endl;
47 } 49 }
48 fileInfo.samplerate = fileRate; 50 fileInfo.samplerate = fileRate;
49 fileInfo.channels = m_channels; 51 fileInfo.channels = m_channels;
59 m_file = sf_wchar_open((LPCWSTR)writePath.utf16(), SFM_WRITE, &fileInfo); 61 m_file = sf_wchar_open((LPCWSTR)writePath.utf16(), SFM_WRITE, &fileInfo);
60 #else 62 #else
61 m_file = sf_open(writePath.toLocal8Bit(), SFM_WRITE, &fileInfo); 63 m_file = sf_open(writePath.toLocal8Bit(), SFM_WRITE, &fileInfo);
62 #endif 64 #endif
63 if (!m_file) { 65 if (!m_file) {
64 cerr << "WavFileWriter: Failed to open file (" 66 SVCERR << "WavFileWriter: Failed to open file ("
65 << sf_strerror(m_file) << ")" << endl; 67 << sf_strerror(m_file) << ")" << endl;
66 m_error = QString("Failed to open audio file '%1' for writing") 68 m_error = QString("Failed to open audio file '%1' for writing")
67 .arg(writePath); 69 .arg(writePath);
68 } 70 }
69 } catch (FileOperationFailed &f) { 71 } catch (FileOperationFailed &f) {