comparison data/fft/FFTMemoryCache.h @ 548:1469caaa8e67

* Finer locking in fft caches; fix displayed bin ranges in spectrogram
author Chris Cannam
date Thu, 05 Feb 2009 12:05:28 +0000
parents 3cc4b7cd2aa5
children 59e7fe1b1003
comparison
equal deleted inserted replaced
547:806e3c72b5df 548:1469caaa8e67
20 #include "FFTCacheWriter.h" 20 #include "FFTCacheWriter.h"
21 #include "FFTCacheStorageType.h" 21 #include "FFTCacheStorageType.h"
22 #include "base/ResizeableBitset.h" 22 #include "base/ResizeableBitset.h"
23 #include "base/Profiler.h" 23 #include "base/Profiler.h"
24 24
25 #include <QMutex> 25 #include <QReadWriteLock>
26 26
27 /** 27 /**
28 * In-memory FFT cache. For this we want to cache magnitude with 28 * In-memory FFT cache. For this we want to cache magnitude with
29 * enough resolution to have gain applied afterwards and determine 29 * enough resolution to have gain applied afterwards and determine
30 * whether something is a peak or not, and also cache phase rather 30 * whether something is a peak or not, and also cache phase rather
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 bool haveSetColumnAt(size_t x) const { 122 bool haveSetColumnAt(size_t x) const {
123 m_colsetMutex.lock(); 123 m_colsetLock.lockForRead();
124 bool have = m_colset.get(x); 124 bool have = m_colset.get(x);
125 m_colsetMutex.unlock(); 125 m_colsetLock.unlock();
126 return have; 126 return have;
127 } 127 }
128 128
129 void setColumnAt(size_t x, float *mags, float *phases, float factor); 129 void setColumnAt(size_t x, float *mags, float *phases, float factor);
130 130
147 float **m_freal; 147 float **m_freal;
148 float **m_fimag; 148 float **m_fimag;
149 float *m_factor; 149 float *m_factor;
150 FFTCache::StorageType m_storageType; 150 FFTCache::StorageType m_storageType;
151 ResizeableBitset m_colset; 151 ResizeableBitset m_colset;
152 mutable QMutex m_colsetMutex; 152 mutable QReadWriteLock m_colsetLock;
153 153
154 void initialise(); 154 void initialise();
155 155
156 void setNormalizationFactor(size_t x, float factor) { 156 void setNormalizationFactor(size_t x, float factor) {
157 if (x < m_width) m_factor[x] = factor; 157 if (x < m_width) m_factor[x] = factor;