comparison data/model/WaveFileModel.cpp @ 429:6036b38177e2

* Fix crash when running Generator
author Chris Cannam
date Wed, 18 Jun 2008 13:40:10 +0000
parents 52303ec15cd2
children d3faa6447c5b
comparison
equal deleted inserted replaced
428:3e1d190048f4 429:6036b38177e2
186 { 186 {
187 // Always read these directly from the file. 187 // Always read these directly from the file.
188 // This is used for e.g. audio playback. 188 // This is used for e.g. audio playback.
189 // Could be much more efficient (although compiler optimisation will help) 189 // Could be much more efficient (although compiler optimisation will help)
190 190
191 #ifdef DEBUG_WAVE_FILE_MODEL
192 std::cout << "WaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl;
193 #endif
194
191 if (start >= m_startFrame) { 195 if (start >= m_startFrame) {
192 start -= m_startFrame; 196 start -= m_startFrame;
193 } else { 197 } else {
194 for (size_t i = 0; i < count; ++i) buffer[i] = 0.f; 198 for (size_t i = 0; i < count; ++i) buffer[i] = 0.f;
195 if (count <= m_startFrame - start) { 199 if (count <= m_startFrame - start) {
244 248
245 size_t 249 size_t
246 WaveFileModel::getData(int channel, size_t start, size_t count, 250 WaveFileModel::getData(int channel, size_t start, size_t count,
247 double *buffer) const 251 double *buffer) const
248 { 252 {
253 #ifdef DEBUG_WAVE_FILE_MODEL
254 std::cout << "WaveFileModel::getData(double)[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl;
255 #endif
256
249 if (start > m_startFrame) { 257 if (start > m_startFrame) {
250 start -= m_startFrame; 258 start -= m_startFrame;
251 } else { 259 } else {
252 for (size_t i = 0; i < count; ++i) buffer[i] = 0.0; 260 for (size_t i = 0; i < count; ++i) buffer[i] = 0.0;
253 if (count <= m_startFrame - start) { 261 if (count <= m_startFrame - start) {
298 size_t 306 size_t
299 WaveFileModel::getData(size_t fromchannel, size_t tochannel, 307 WaveFileModel::getData(size_t fromchannel, size_t tochannel,
300 size_t start, size_t count, 308 size_t start, size_t count,
301 float **buffer) const 309 float **buffer) const
302 { 310 {
311 #ifdef DEBUG_WAVE_FILE_MODEL
312 std::cout << "WaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << ", " << buffer << std::endl;
313 #endif
314
303 size_t channels = getChannelCount(); 315 size_t channels = getChannelCount();
304 316
305 if (fromchannel > tochannel) { 317 if (fromchannel > tochannel) {
306 std::cerr << "ERROR: WaveFileModel::getData: fromchannel (" 318 std::cerr << "ERROR: WaveFileModel::getData: fromchannel ("
307 << fromchannel << ") > tochannel (" << tochannel << ")" 319 << fromchannel << ") > tochannel (" << tochannel << ")"