comparison data/fileio/WavFileReader.cpp @ 843:e802e550a1f2

Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author Chris Cannam
date Tue, 26 Nov 2013 13:35:08 +0000
parents f0558e69a074
children 59e7fe1b1003
comparison
equal deleted inserted replaced
842:23d3a6eca5c3 843:e802e550a1f2
38 m_fileInfo.format = 0; 38 m_fileInfo.format = 0;
39 m_fileInfo.frames = 0; 39 m_fileInfo.frames = 0;
40 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); 40 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo);
41 41
42 if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) { 42 if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) {
43 std::cerr << "WavFileReader::initialize: Failed to open file at \"" 43 cerr << "WavFileReader::initialize: Failed to open file at \""
44 << m_path << "\" (" 44 << m_path << "\" ("
45 << sf_strerror(m_file) << ")" << std::endl; 45 << sf_strerror(m_file) << ")" << endl;
46 46
47 if (m_file) { 47 if (m_file) {
48 m_error = QString("Couldn't load audio file '%1':\n%2") 48 m_error = QString("Couldn't load audio file '%1':\n%2")
49 .arg(m_path).arg(sf_strerror(m_file)); 49 .arg(m_path).arg(sf_strerror(m_file));
50 } else { 50 } else {
65 // Our m_seekable reports whether a file is rapidly seekable, 65 // Our m_seekable reports whether a file is rapidly seekable,
66 // so things like Ogg don't qualify. We cautiously report 66 // so things like Ogg don't qualify. We cautiously report
67 // every file type of "at least" the historical period of Ogg 67 // every file type of "at least" the historical period of Ogg
68 // or FLAC as non-seekable. 68 // or FLAC as non-seekable.
69 int type = m_fileInfo.format & SF_FORMAT_TYPEMASK; 69 int type = m_fileInfo.format & SF_FORMAT_TYPEMASK;
70 // std::cerr << "WavFileReader: format type is " << type << " (flac, ogg are " << SF_FORMAT_FLAC << ", " << SF_FORMAT_OGG << ")" << std::endl; 70 // cerr << "WavFileReader: format type is " << type << " (flac, ogg are " << SF_FORMAT_FLAC << ", " << SF_FORMAT_OGG << ")" << endl;
71 if (type >= SF_FORMAT_FLAC || type >= SF_FORMAT_OGG) { 71 if (type >= SF_FORMAT_FLAC || type >= SF_FORMAT_OGG) {
72 // std::cerr << "WavFileReader: Recording as non-seekable" << std::endl; 72 // cerr << "WavFileReader: Recording as non-seekable" << endl;
73 m_seekable = false; 73 m_seekable = false;
74 } 74 }
75 } 75 }
76 76
77 // std::cerr << "WavFileReader: Frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", seekable " << m_seekable << std::endl; 77 // cerr << "WavFileReader: Frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", seekable " << m_seekable << endl;
78 78
79 } 79 }
80 80
81 WavFileReader::~WavFileReader() 81 WavFileReader::~WavFileReader()
82 { 82 {
93 93
94 if (m_file) { 94 if (m_file) {
95 sf_close(m_file); 95 sf_close(m_file);
96 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); 96 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo);
97 if (!m_file || m_fileInfo.channels <= 0) { 97 if (!m_file || m_fileInfo.channels <= 0) {
98 std::cerr << "WavFileReader::updateFrameCount: Failed to open file at \"" << m_path << "\" (" 98 cerr << "WavFileReader::updateFrameCount: Failed to open file at \"" << m_path << "\" ("
99 << sf_strerror(m_file) << ")" << std::endl; 99 << sf_strerror(m_file) << ")" << endl;
100 } 100 }
101 } 101 }
102 102
103 // SVDEBUG << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << endl; 103 // SVDEBUG << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << endl;
104 104
108 m_channelCount = m_fileInfo.channels; 108 m_channelCount = m_fileInfo.channels;
109 m_sampleRate = m_fileInfo.samplerate; 109 m_sampleRate = m_fileInfo.samplerate;
110 } 110 }
111 111
112 if (m_frameCount != prevCount) { 112 if (m_frameCount != prevCount) {
113 // std::cerr << "frameCountChanged" << std::endl; 113 // cerr << "frameCountChanged" << endl;
114 emit frameCountChanged(); 114 emit frameCountChanged();
115 } 115 }
116 } 116 }
117 117
118 void 118 void
149 sf_count_t readCount = 0; 149 sf_count_t readCount = 0;
150 150
151 if (start != m_lastStart || count != m_lastCount) { 151 if (start != m_lastStart || count != m_lastCount) {
152 152
153 if (sf_seek(m_file, start, SEEK_SET) < 0) { 153 if (sf_seek(m_file, start, SEEK_SET) < 0) {
154 // std::cerr << "sf_seek failed" << std::endl; 154 // cerr << "sf_seek failed" << endl;
155 return; 155 return;
156 } 156 }
157 157
158 if (count * m_fileInfo.channels > m_bufsiz) { 158 if (count * m_fileInfo.channels > m_bufsiz) {
159 // std::cerr << "WavFileReader: Reallocating buffer for " << count 159 // cerr << "WavFileReader: Reallocating buffer for " << count
160 // << " frames, " << m_fileInfo.channels << " channels: " 160 // << " frames, " << m_fileInfo.channels << " channels: "
161 // << m_bufsiz << " floats" << std::endl; 161 // << m_bufsiz << " floats" << endl;
162 m_bufsiz = count * m_fileInfo.channels; 162 m_bufsiz = count * m_fileInfo.channels;
163 delete[] m_buffer; 163 delete[] m_buffer;
164 m_buffer = new float[m_bufsiz]; 164 m_buffer = new float[m_bufsiz];
165 } 165 }
166 166
167 if ((readCount = sf_readf_float(m_file, m_buffer, count)) < 0) { 167 if ((readCount = sf_readf_float(m_file, m_buffer, count)) < 0) {
168 // std::cerr << "sf_readf_float failed" << std::endl; 168 // cerr << "sf_readf_float failed" << endl;
169 return; 169 return;
170 } 170 }
171 171
172 m_lastStart = start; 172 m_lastStart = start;
173 m_lastCount = readCount; 173 m_lastCount = readCount;
174 } 174 }
175 175
176 for (size_t i = 0; i < count * m_fileInfo.channels; ++i) { 176 for (size_t i = 0; i < count * m_fileInfo.channels; ++i) {
177 if (i >= m_bufsiz) { 177 if (i >= m_bufsiz) {
178 std::cerr << "INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i << " >= " << m_bufsiz << std::endl; 178 cerr << "INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i << " >= " << m_bufsiz << endl;
179 } 179 }
180 results.push_back(m_buffer[i]); 180 results.push_back(m_buffer[i]);
181 } 181 }
182 182
183 return; 183 return;