Mercurial > hg > svcore
comparison data/model/FFTModel.h @ 929:59e7fe1b1003 warnfix_no_size_t
Unsigned removals and warning fixes in data/
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 14:33:42 +0100 |
parents | 948271d124ac |
children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
928:6a94bb528e9d | 929:59e7fe1b1003 |
---|---|
56 * number if possible, as that is likely to be requested first. | 56 * number if possible, as that is likely to be requested first. |
57 */ | 57 */ |
58 FFTModel(const DenseTimeValueModel *model, | 58 FFTModel(const DenseTimeValueModel *model, |
59 int channel, | 59 int channel, |
60 WindowType windowType, | 60 WindowType windowType, |
61 size_t windowSize, | 61 int windowSize, |
62 size_t windowIncrement, | 62 int windowIncrement, |
63 size_t fftSize, | 63 int fftSize, |
64 bool polar, | 64 bool polar, |
65 StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, | 65 StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, |
66 size_t fillFromColumn = 0); | 66 int fillFromColumn = 0); |
67 ~FFTModel(); | 67 ~FFTModel(); |
68 | 68 |
69 inline float getMagnitudeAt(size_t x, size_t y) { | 69 inline float getMagnitudeAt(int x, int y) { |
70 return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift); | 70 return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift); |
71 } | 71 } |
72 inline float getNormalizedMagnitudeAt(size_t x, size_t y) { | 72 inline float getNormalizedMagnitudeAt(int x, int y) { |
73 return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift); | 73 return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift); |
74 } | 74 } |
75 inline float getMaximumMagnitudeAt(size_t x) { | 75 inline float getMaximumMagnitudeAt(int x) { |
76 return m_server->getMaximumMagnitudeAt(x << m_xshift); | 76 return m_server->getMaximumMagnitudeAt(x << m_xshift); |
77 } | 77 } |
78 inline float getPhaseAt(size_t x, size_t y) { | 78 inline float getPhaseAt(int x, int y) { |
79 return m_server->getPhaseAt(x << m_xshift, y << m_yshift); | 79 return m_server->getPhaseAt(x << m_xshift, y << m_yshift); |
80 } | 80 } |
81 inline void getValuesAt(size_t x, size_t y, float &real, float &imaginary) { | 81 inline void getValuesAt(int x, int y, float &real, float &imaginary) { |
82 m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary); | 82 m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary); |
83 } | 83 } |
84 inline bool isColumnAvailable(size_t x) const { | 84 inline bool isColumnAvailable(int x) const { |
85 return m_server->isColumnReady(x << m_xshift); | 85 return m_server->isColumnReady(x << m_xshift); |
86 } | 86 } |
87 | 87 |
88 inline bool getMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { | 88 inline bool getMagnitudesAt(int x, float *values, int minbin = 0, int count = 0) { |
89 return m_server->getMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); | 89 return m_server->getMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); |
90 } | 90 } |
91 inline bool getNormalizedMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { | 91 inline bool getNormalizedMagnitudesAt(int x, float *values, int minbin = 0, int count = 0) { |
92 return m_server->getNormalizedMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); | 92 return m_server->getNormalizedMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); |
93 } | 93 } |
94 inline bool getPhasesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { | 94 inline bool getPhasesAt(int x, float *values, int minbin = 0, int count = 0) { |
95 return m_server->getPhasesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); | 95 return m_server->getPhasesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); |
96 } | 96 } |
97 inline bool getValuesAt(size_t x, float *reals, float *imaginaries, size_t minbin = 0, size_t count = 0) { | 97 inline bool getValuesAt(int x, float *reals, float *imaginaries, int minbin = 0, int count = 0) { |
98 return m_server->getValuesAt(x << m_xshift, reals, imaginaries, minbin << m_yshift, count, getYRatio()); | 98 return m_server->getValuesAt(x << m_xshift, reals, imaginaries, minbin << m_yshift, count, getYRatio()); |
99 } | 99 } |
100 | 100 |
101 inline size_t getFillExtent() const { return m_server->getFillExtent(); } | 101 inline int getFillExtent() const { return m_server->getFillExtent(); } |
102 | 102 |
103 // DenseThreeDimensionalModel and Model methods: | 103 // DenseThreeDimensionalModel and Model methods: |
104 // | 104 // |
105 inline virtual size_t getWidth() const { | 105 inline virtual int getWidth() const { |
106 return m_server->getWidth() >> m_xshift; | 106 return m_server->getWidth() >> m_xshift; |
107 } | 107 } |
108 inline virtual size_t getHeight() const { | 108 inline virtual int getHeight() const { |
109 // If there is no y-shift, the server's height (based on its | 109 // If there is no y-shift, the server's height (based on its |
110 // fftsize/2 + 1) is correct. If there is a shift, then the | 110 // fftsize/2 + 1) is correct. If there is a shift, then the |
111 // server is using a larger fft size than we want, so we shift | 111 // server is using a larger fft size than we want, so we shift |
112 // it right as many times as necessary, but then we need to | 112 // it right as many times as necessary, but then we need to |
113 // re-add the "+1" part (because ((fftsize*2)/2 + 1) / 2 != | 113 // re-add the "+1" part (because ((fftsize*2)/2 + 1) / 2 != |
114 // fftsize/2 + 1). | 114 // fftsize/2 + 1). |
115 return (m_server->getHeight() >> m_yshift) + (m_yshift > 0 ? 1 : 0); | 115 return (m_server->getHeight() >> m_yshift) + (m_yshift > 0 ? 1 : 0); |
116 } | 116 } |
117 virtual float getValueAt(size_t x, size_t y) const { | 117 virtual float getValueAt(int x, int y) const { |
118 return const_cast<FFTModel *>(this)->getMagnitudeAt(x, y); | 118 return const_cast<FFTModel *>(this)->getMagnitudeAt(x, y); |
119 } | 119 } |
120 virtual bool isOK() const { | 120 virtual bool isOK() const { |
121 return m_server && m_server->getModel(); | 121 return m_server && m_server->getModel(); |
122 } | 122 } |
123 virtual size_t getStartFrame() const { | 123 virtual int getStartFrame() const { |
124 return 0; | 124 return 0; |
125 } | 125 } |
126 virtual size_t getEndFrame() const { | 126 virtual int getEndFrame() const { |
127 return getWidth() * getResolution() + getResolution(); | 127 return getWidth() * getResolution() + getResolution(); |
128 } | 128 } |
129 virtual size_t getSampleRate() const; | 129 virtual int getSampleRate() const; |
130 virtual size_t getResolution() const { | 130 virtual int getResolution() const { |
131 return m_server->getWindowIncrement() << m_xshift; | 131 return m_server->getWindowIncrement() << m_xshift; |
132 } | 132 } |
133 virtual size_t getYBinCount() const { | 133 virtual int getYBinCount() const { |
134 return getHeight(); | 134 return getHeight(); |
135 } | 135 } |
136 virtual float getMinimumLevel() const { | 136 virtual float getMinimumLevel() const { |
137 return 0.f; // Can't provide | 137 return 0.f; // Can't provide |
138 } | 138 } |
139 virtual float getMaximumLevel() const { | 139 virtual float getMaximumLevel() const { |
140 return 1.f; // Can't provide | 140 return 1.f; // Can't provide |
141 } | 141 } |
142 virtual Column getColumn(size_t x) const; | 142 virtual Column getColumn(int x) const; |
143 virtual QString getBinName(size_t n) const; | 143 virtual QString getBinName(int n) const; |
144 | 144 |
145 virtual bool shouldUseLogValueScale() const { | 145 virtual bool shouldUseLogValueScale() const { |
146 return true; // Although obviously it's up to the user... | 146 return true; // Although obviously it's up to the user... |
147 } | 147 } |
148 | 148 |
149 /** | 149 /** |
150 * Calculate an estimated frequency for a stable signal in this | 150 * Calculate an estimated frequency for a stable signal in this |
151 * bin, using phase unwrapping. This will be completely wrong if | 151 * bin, using phase unwrapping. This will be completely wrong if |
152 * the signal is not stable here. | 152 * the signal is not stable here. |
153 */ | 153 */ |
154 virtual bool estimateStableFrequency(size_t x, size_t y, float &frequency); | 154 virtual bool estimateStableFrequency(int x, int y, float &frequency); |
155 | 155 |
156 enum PeakPickType | 156 enum PeakPickType |
157 { | 157 { |
158 AllPeaks, /// Any bin exceeding its immediate neighbours | 158 AllPeaks, /// Any bin exceeding its immediate neighbours |
159 MajorPeaks, /// Peaks picked using sliding median window | 159 MajorPeaks, /// Peaks picked using sliding median window |
160 MajorPitchAdaptivePeaks /// Bigger window for higher frequencies | 160 MajorPitchAdaptivePeaks /// Bigger window for higher frequencies |
161 }; | 161 }; |
162 | 162 |
163 typedef std::set<size_t> PeakLocationSet; // bin | 163 typedef std::set<int> PeakLocationSet; // bin |
164 typedef std::map<size_t, float> PeakSet; // bin -> freq | 164 typedef std::map<int, float> PeakSet; // bin -> freq |
165 | 165 |
166 /** | 166 /** |
167 * Return locations of peak bins in the range [ymin,ymax]. If | 167 * Return locations of peak bins in the range [ymin,ymax]. If |
168 * ymax is zero, getHeight()-1 will be used. | 168 * ymax is zero, getHeight()-1 will be used. |
169 */ | 169 */ |
170 virtual PeakLocationSet getPeaks(PeakPickType type, size_t x, | 170 virtual PeakLocationSet getPeaks(PeakPickType type, int x, |
171 size_t ymin = 0, size_t ymax = 0); | 171 int ymin = 0, int ymax = 0); |
172 | 172 |
173 /** | 173 /** |
174 * Return locations and estimated stable frequencies of peak bins. | 174 * Return locations and estimated stable frequencies of peak bins. |
175 */ | 175 */ |
176 virtual PeakSet getPeakFrequencies(PeakPickType type, size_t x, | 176 virtual PeakSet getPeakFrequencies(PeakPickType type, int x, |
177 size_t ymin = 0, size_t ymax = 0); | 177 int ymin = 0, int ymax = 0); |
178 | 178 |
179 virtual int getCompletion() const { return m_server->getFillCompletion(); } | 179 virtual int getCompletion() const { return m_server->getFillCompletion(); } |
180 virtual QString getError() const { return m_server->getError(); } | 180 virtual QString getError() const { return m_server->getError(); } |
181 | 181 |
182 virtual Model *clone() const; | 182 virtual Model *clone() const; |
197 FFTDataServer *m_server; | 197 FFTDataServer *m_server; |
198 int m_xshift; | 198 int m_xshift; |
199 int m_yshift; | 199 int m_yshift; |
200 | 200 |
201 FFTDataServer *getServer(const DenseTimeValueModel *, | 201 FFTDataServer *getServer(const DenseTimeValueModel *, |
202 int, WindowType, size_t, size_t, size_t, | 202 int, WindowType, int, int, int, |
203 bool, StorageAdviser::Criteria, size_t); | 203 bool, StorageAdviser::Criteria, int); |
204 | 204 |
205 size_t getPeakPickWindowSize(PeakPickType type, size_t sampleRate, | 205 int getPeakPickWindowSize(PeakPickType type, int sampleRate, |
206 size_t bin, float &percentile) const; | 206 int bin, float &percentile) const; |
207 | 207 |
208 size_t getYRatio() { | 208 int getYRatio() { |
209 size_t ys = m_yshift; | 209 int ys = m_yshift; |
210 size_t r = 1; | 210 int r = 1; |
211 while (ys) { --ys; r <<= 1; } | 211 while (ys) { --ys; r <<= 1; } |
212 return r; | 212 return r; |
213 } | 213 } |
214 }; | 214 }; |
215 | 215 |