Mercurial > hg > svcore
comparison base/MagnitudeRange.h @ 1194:238780e92f86 spectrogram-minor-refactor
Toward updating mag cache
author | Chris Cannam |
---|---|
date | Wed, 20 Jul 2016 13:40:23 +0100 |
parents | 12a8daa89970 |
children | 4d0d94ba2ea7 |
comparison
equal
deleted
inserted
replaced
1193:927d329252bf | 1194:238780e92f86 |
---|---|
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef MAGNITUDE_RANGE_H | 16 #ifndef MAGNITUDE_RANGE_H |
17 #define MAGNITUDE_RANGE_H | 17 #define MAGNITUDE_RANGE_H |
18 | |
19 #include <vector> | |
18 | 20 |
19 /** | 21 /** |
20 * Maintain a min and max value, and update them when supplied a new | 22 * Maintain a min and max value, and update them when supplied a new |
21 * data point. | 23 * data point. |
22 */ | 24 */ |
41 } else { | 43 } else { |
42 m_max = m_min = f; | 44 m_max = m_min = f; |
43 changed = true; | 45 changed = true; |
44 } | 46 } |
45 return changed; | 47 return changed; |
46 } | 48 } |
49 bool sample(const std::vector<float> &ff) { | |
50 bool changed = false; | |
51 for (auto f: ff) { | |
52 if (sample(f)) { | |
53 changed = true; | |
54 } | |
55 } | |
56 return changed; | |
57 } | |
47 bool sample(const MagnitudeRange &r) { | 58 bool sample(const MagnitudeRange &r) { |
48 bool changed = false; | 59 bool changed = false; |
49 if (isSet()) { | 60 if (isSet()) { |
50 if (r.m_min < m_min) { m_min = r.m_min; changed = true; } | 61 if (r.m_min < m_min) { m_min = r.m_min; changed = true; } |
51 if (r.m_max > m_max) { m_max = r.m_max; changed = true; } | 62 if (r.m_max > m_max) { m_max = r.m_max; changed = true; } |