comparison data/fft/FFTFileCache.h @ 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 91fdc752e540
children 02d2ad95ea52
comparison
equal deleted inserted replaced
265:e08f486e8d8c 266:2268963dabd1
95 } 95 }
96 96
97 void populateReadBuf(size_t x) const; 97 void populateReadBuf(size_t x) const;
98 98
99 float getNormalizationFactor(size_t col) const { 99 float getNormalizationFactor(size_t col) const {
100 size_t h = m_mfc->getHeight();
101 if (h < m_factorSize) return 0;
100 if (m_storageType != Compact) { 102 if (m_storageType != Compact) {
101 return getFromReadBufStandard(col, m_mfc->getHeight() - 1); 103 return getFromReadBufStandard(col, h - 1);
102 } else { 104 } else {
103 float factor; 105 union {
104 factor = getFromReadBufCompactUnsigned(col, m_mfc->getHeight() - 1); 106 float f;
105 return factor / 65535.0; 107 uint16_t u[2];
108 } factor;
109 if (!m_readbuf ||
110 !(m_readbufCol == col ||
111 (m_readbufWidth > 1 && m_readbufCol+1 == col))) {
112 populateReadBuf(col);
113 }
114 size_t ix = (col - m_readbufCol) * m_mfc->getHeight() + h;
115 factor.u[0] = ((uint16_t *)m_readbuf)[ix - 2];
116 factor.u[1] = ((uint16_t *)m_readbuf)[ix - 1];
117 return factor.f;
106 } 118 }
107 } 119 }
120
121 void setNormalizationFactorToWritebuf(float newfactor) {
122 size_t h = m_mfc->getHeight();
123 if (h < m_factorSize) return;
124 if (m_storageType != Compact) {
125 ((float *)m_writebuf)[h - 1] = newfactor;
126 } else {
127 union {
128 float f;
129 uint16_t u[2];
130 } factor;
131 factor.f = newfactor;
132 ((uint16_t *)m_writebuf)[h - 2] = factor.u[0];
133 ((uint16_t *)m_writebuf)[h - 1] = factor.u[1];
134 }
135 }
108 136
109 MatrixFile *m_mfc; 137 MatrixFile *m_mfc;
110 QMutex m_writeMutex; 138 QMutex m_writeMutex;
111 StorageType m_storageType; 139 StorageType m_storageType;
140 size_t m_factorSize;
112 }; 141 };
113 142
114 #endif 143 #endif