comparison data/fileio/WavFileReader.cpp @ 187:89b05b679dc3

* Fixes to update logic in writable wave file model
author Chris Cannam
date Thu, 12 Oct 2006 16:10:49 +0000
parents 570794f6f6a7
children f86b74d1b143
comparison
equal deleted inserted replaced
186:06ad01f3e553 187:89b05b679dc3
34 34
35 m_fileInfo.format = 0; 35 m_fileInfo.format = 0;
36 m_fileInfo.frames = 0; 36 m_fileInfo.frames = 0;
37 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo); 37 m_file = sf_open(m_path.toLocal8Bit(), SFM_READ, &m_fileInfo);
38 38
39 if (!m_file || m_fileInfo.channels <= 0) { 39 if (!m_file || (!fileUpdating && m_fileInfo.channels <= 0)) {
40 std::cerr << "WavFileReader::initialize: Failed to open file (" 40 std::cerr << "WavFileReader::initialize: Failed to open file ("
41 << sf_strerror(m_file) << ")" << std::endl; 41 << sf_strerror(m_file) << ")" << std::endl;
42 42
43 if (m_file) { 43 if (m_file) {
44 m_error = QString("Couldn't load audio file '%1':\n%2") 44 m_error = QString("Couldn't load audio file '%1':\n%2")
48 .arg(m_path); 48 .arg(m_path);
49 } 49 }
50 return; 50 return;
51 } 51 }
52 52
53 m_frameCount = m_fileInfo.frames; 53 if (m_fileInfo.channels > 0) {
54 m_channelCount = m_fileInfo.channels; 54 m_frameCount = m_fileInfo.frames;
55 m_sampleRate = m_fileInfo.samplerate; 55 m_channelCount = m_fileInfo.channels;
56 m_sampleRate = m_fileInfo.samplerate;
57 }
56 58
57 std::cerr << "WavFileReader: Frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << std::endl; 59 std::cerr << "WavFileReader: Frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << std::endl;
58 60
59 } 61 }
60 62
80 } 82 }
81 83
82 std::cerr << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << std::endl; 84 std::cerr << "WavFileReader::updateFrameCount: now " << m_fileInfo.frames << std::endl;
83 85
84 m_frameCount = m_fileInfo.frames; 86 m_frameCount = m_fileInfo.frames;
87
88 if (m_channelCount == 0) {
89 m_channelCount = m_fileInfo.channels;
90 m_sampleRate = m_fileInfo.samplerate;
91 }
85 92
86 if (m_frameCount != prevCount) emit frameCountChanged(); 93 if (m_frameCount != prevCount) emit frameCountChanged();
87 } 94 }
88 95
89 void 96 void