Mercurial > hg > svcore
comparison data/model/FFTModel.cpp @ 1186:12a8daa89970 spectrogram-minor-refactor
Mid-refactor to pull out the bulk of paintDrawBuffer into chunks
author | Chris Cannam |
---|---|
date | Mon, 13 Jun 2016 16:17:44 +0100 |
parents | 444d133b5ab7 |
children | 6d09ad2ab21f |
comparison
equal
deleted
inserted
replaced
1185:69c84a66727b | 1186:12a8daa89970 |
---|---|
145 auto col = getFFTColumn(x); | 145 auto col = getFFTColumn(x); |
146 for (int i = 0; i < count; ++i) { | 146 for (int i = 0; i < count; ++i) { |
147 values[i] = abs(col[minbin + i]); | 147 values[i] = abs(col[minbin + i]); |
148 } | 148 } |
149 return true; | 149 return true; |
150 } | |
151 | |
152 float | |
153 FFTModel::getNormalizedMagnitudesAt(int x, float *values, int minbin, int count) const | |
154 { | |
155 if (!getMagnitudesAt(x, values, minbin, count)) return false; | |
156 if (count == 0) count = getHeight(); | |
157 float max = 0.f; | |
158 for (int i = 0; i < count; ++i) { | |
159 if (values[i] > max) max = values[i]; | |
160 } | |
161 if (max > 0.f) { | |
162 for (int i = 0; i < count; ++i) { | |
163 values[i] /= max; | |
164 } | |
165 } | |
166 return max; | |
167 } | 150 } |
168 | 151 |
169 bool | 152 bool |
170 FFTModel::getPhasesAt(int x, float *values, int minbin, int count) const | 153 FFTModel::getPhasesAt(int x, float *values, int minbin, int count) const |
171 { | 154 { |