Mercurial > hg > svcore
comparison data/model/FFTModel.cpp @ 1569:c2c8e071e24f
Comment
author | Chris Cannam |
---|---|
date | Wed, 07 Nov 2018 15:46:20 +0000 |
parents | 36b4872e894a |
children | 5fe24e4af12c |
comparison
equal
deleted
inserted
replaced
1568:2b532ff7f22e | 1569:c2c8e071e24f |
---|---|
124 } | 124 } |
125 | 125 |
126 float | 126 float |
127 FFTModel::getMagnitudeAt(int x, int y) const | 127 FFTModel::getMagnitudeAt(int x, int y) const |
128 { | 128 { |
129 if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) return 0.f; | 129 if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) { |
130 return 0.f; | |
131 } | |
130 auto col = getFFTColumn(x); | 132 auto col = getFFTColumn(x); |
131 return abs(col[y]); | 133 return abs(col[y]); |
132 } | 134 } |
133 | 135 |
134 float | 136 float |
316 // The small cache (i.e. the m_cached deque) is for cases where | 318 // The small cache (i.e. the m_cached deque) is for cases where |
317 // values are looked up individually, and for e.g. peak-frequency | 319 // values are looked up individually, and for e.g. peak-frequency |
318 // spectrograms where values from two consecutive columns are | 320 // spectrograms where values from two consecutive columns are |
319 // needed at once. This cache gets essentially no hits when | 321 // needed at once. This cache gets essentially no hits when |
320 // scrolling through a magnitude spectrogram, but 95%+ hits with a | 322 // scrolling through a magnitude spectrogram, but 95%+ hits with a |
321 // peak-frequency spectrogram. | 323 // peak-frequency spectrogram or spectrum. |
322 for (const auto &incache : m_cached) { | 324 for (const auto &incache : m_cached) { |
323 if (incache.n == n) { | 325 if (incache.n == n) { |
324 inSmallCache.hit(); | 326 inSmallCache.hit(); |
325 return incache.col; | 327 return incache.col; |
326 } | 328 } |