comparison data/model/WaveFileModel.cpp @ 266:2268963dabd1

* FFT: fix invalid write of normalisation factor in compact mode of disc cache * FFT: fix range problem for normalisation factor in compact mode (it was stored as an unsigned scaled from an assumed float range of 0->1, which is not very plausible and not accurate enough even if true -- use a float instead) * Spectrogram: fix vertical zoom behaviour for log frequency spectrograms: make the thing in the middle of the display remain in the middle after zoom * Overview widget: don't update the detailed waveform if still decoding the audio file (too expensive to do all those redraws)
author Chris Cannam
date Fri, 08 Jun 2007 15:19:50 +0000
parents e08f486e8d8c
children fa612dc181af
comparison
equal deleted inserted replaced
265:e08f486e8d8c 266:2268963dabd1
94 bool 94 bool
95 WaveFileModel::isReady(int *completion) const 95 WaveFileModel::isReady(int *completion) const
96 { 96 {
97 bool ready = (isOK() && (m_fillThread == 0)); 97 bool ready = (isOK() && (m_fillThread == 0));
98 double c = double(m_lastFillExtent) / double(getEndFrame() - getStartFrame()); 98 double c = double(m_lastFillExtent) / double(getEndFrame() - getStartFrame());
99 static int prevCompletion = 0;
99 if (completion) { 100 if (completion) {
100 *completion = int(c * 100.0 + 0.01); 101 *completion = int(c * 100.0 + 0.01);
101 if (m_reader) { 102 if (m_reader) {
102 int decodeCompletion = m_reader->getDecodeCompletion(); 103 int decodeCompletion = m_reader->getDecodeCompletion();
103 // std::cerr << "decodeCompletion " << decodeCompletion << ", completion " << *completion << std::endl; 104 if (decodeCompletion < 90) *completion = decodeCompletion;
104 // if (decodeCompletion < *completion) *completion = decodeCompletion; 105 else *completion = std::min(*completion, decodeCompletion);
105 if (decodeCompletion < 100) *completion = decodeCompletion;
106 } 106 }
107 if (*completion != 0 &&
108 *completion != 100 &&
109 prevCompletion != 0 &&
110 prevCompletion > *completion) {
111 // just to avoid completion going backwards
112 *completion = prevCompletion;
113 }
114 prevCompletion = *completion;
107 } 115 }
108 #ifdef DEBUG_WAVE_FILE_MODEL 116 #ifdef DEBUG_WAVE_FILE_MODEL
109 std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl; 117 std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl;
110 #endif 118 #endif
111 return ready; 119 return ready;