00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef QwavPEAKVECTOR_H_
00019 #define QwavPEAKVECTOR_H_
00020
00021
00022
00023
00024
00025 #include "qwavstereopeakupdater.h"
00026 #include "qwavdefines.h"
00027 #include "qwavpeakinterpolator.h"
00028
00029
00030
00031
00032
00033 #include <vector>
00034 #include <map>
00035
00036 using namespace std;
00037
00038 Qwav_BEGIN_NAMESPACE
00039
00040
00041
00042
00043
00049 class QWAV_EXPORTIMPORT QwavPeakInfo
00050 {
00051
00052 public:
00053 QwavPeakInfo(Float minP=0.0f, Float maxP=0.0f,
00054 Float minA=0.0f, Float maxA=0.0f)
00055 :
00056 minPeak(minP), maxPeak(maxP), minAvg(minA), maxAvg(maxA) {}
00057
00058 Float minPeak;
00059 Float maxPeak;
00060 Float minAvg;
00061 Float maxAvg;
00062 };
00063
00064
00065
00066
00067
00068
00069 typedef vector<QwavPeakInfo> QwavPeakInfoVector;
00070 typedef map<int,QwavPeakInfoVector> QwavBlockSizeMap;
00071
00072
00073
00074
00075
00076 class QwavPeakUpdater;
00077 class QwavWaveDataInterface;
00078
00079
00080
00081
00082
00095 class QwavPeakVector
00096 {
00097 public:
00098 QwavPeakVector(void);
00099 QwavPeakVector(QwavWaveDataInterface* wave);
00100 ~QwavPeakVector();
00101
00102 bool setWave(QwavWaveDataInterface* wave);
00103
00104 inline const QwavBlockSizeMap& getBlockSizeMap(uint channel=1) const;
00105 inline QwavBlockSizeMap& getBlockSizeMap(uint channel=1);
00106
00107 inline QwavPeakInfo getPeak(QwavPeakInterpolator* s,
00108 int pixel,
00109 int nPixels,
00110 Float zoomFac=1.0,
00111 uint channel=1 ) const;
00112
00113 inline void setPeakUpdateStrategy(QwavPeakUpdater* s);
00114 inline QwavPeakUpdater* peakUpdateStrategy() const;
00115 void updatePeaks(void);
00116
00117 inline uint getNrOfSamples(void) const;
00118 uint getNrOfChannels(void) const;
00119 const Float& operator[] (uint index) const;
00120
00121 bool writePeakFile(const string& filename);
00122
00123 static const int maxBlockSize = 262144;
00124
00125 protected:
00126
00127 private:
00128 QwavWaveDataInterface* _wave;
00129 vector<QwavBlockSizeMap> _hierPeaks;
00130
00131 Float _fSP;
00132 Float _fPS;
00133 uint _nS;
00134
00135 QwavPeakUpdater* _updatePeakStrategy;
00136
00137 protected:
00138
00139 };
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 const QwavBlockSizeMap& QwavPeakVector::getBlockSizeMap(uint channel) const
00152 {
00153 return _hierPeaks[channel-1];
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 QwavBlockSizeMap& QwavPeakVector::getBlockSizeMap(uint channel)
00163 {
00164 return _hierPeaks[channel-1];
00165 }
00166
00167
00168
00169
00170
00171
00172
00177 void QwavPeakVector::setPeakUpdateStrategy( QwavPeakUpdater* s )
00178 {
00179 if( s->getName() != _updatePeakStrategy->getName() )
00180 {
00181 delete _updatePeakStrategy;
00182 _updatePeakStrategy = s;
00183 updatePeaks();
00184 }
00185 }
00186
00187
00188
00189
00190
00191
00195 uint QwavPeakVector::getNrOfSamples() const
00196 {
00197 return uint(_nS);
00198 }
00199
00200
00201
00202
00203
00204 QwavPeakUpdater* QwavPeakVector::peakUpdateStrategy() const
00205 {
00206 return _updatePeakStrategy;
00207 }
00208
00209
00210
00211
00212
00246 QwavPeakInfo QwavPeakVector::getPeak(QwavPeakInterpolator* s,
00247 int pixel, int firstSample, Float zoomFac, uint channel) const
00248 {
00249 return s->getPeak(this, pixel, firstSample, zoomFac, channel);
00250
00251 }
00252
00253
00254 Qwav_END_NAMESPACE
00255
00256 #endif // QwavPEAKVECTOR_H_
00257