Mercurial > hg > svcore
comparison base/ColumnOp.h @ 1429:48e9f538e6e9
Untabify
| author | Chris Cannam |
|---|---|
| date | Thu, 01 Mar 2018 18:02:22 +0000 |
| parents | 9ef1cc26024c |
| children | 1b688ab5f1b3 |
comparison
equal
deleted
inserted
replaced
| 1428:87ae75da6527 | 1429:48e9f538e6e9 |
|---|---|
| 58 /** | 58 /** |
| 59 * Scale the given column using the given gain multiplier. | 59 * Scale the given column using the given gain multiplier. |
| 60 */ | 60 */ |
| 61 static Column applyGain(const Column &in, double gain) { | 61 static Column applyGain(const Column &in, double gain) { |
| 62 if (gain == 1.0) return in; | 62 if (gain == 1.0) return in; |
| 63 Column out; | 63 Column out; |
| 64 out.reserve(in.size()); | 64 out.reserve(in.size()); |
| 65 for (auto v: in) out.push_back(float(v * gain)); | 65 for (auto v: in) out.push_back(float(v * gain)); |
| 66 return out; | 66 return out; |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Shift the values in the given column by the given offset. | 70 * Shift the values in the given column by the given offset. |
| 71 */ | 71 */ |
| 72 static Column applyShift(const Column &in, float offset) { | 72 static Column applyShift(const Column &in, float offset) { |
| 73 if (offset == 0.f) return in; | 73 if (offset == 0.f) return in; |
| 74 Column out; | 74 Column out; |
| 75 out.reserve(in.size()); | 75 out.reserve(in.size()); |
| 76 for (auto v: in) out.push_back(v + offset); | 76 for (auto v: in) out.push_back(v + offset); |
| 77 return out; | 77 return out; |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Scale an FFT output downward by half the FFT size. | 81 * Scale an FFT output downward by half the FFT size. |
| 82 */ | 82 */ |
| 93 return in[0] >= in[1]; | 93 return in[0] >= in[1]; |
| 94 } | 94 } |
| 95 if (!in_range_for(in, ix+1)) { | 95 if (!in_range_for(in, ix+1)) { |
| 96 return in[ix] > in[ix-1]; | 96 return in[ix] > in[ix-1]; |
| 97 } | 97 } |
| 98 if (in[ix] < in[ix+1]) { | 98 if (in[ix] < in[ix+1]) { |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 if (in[ix] <= in[ix-1]) { | 101 if (in[ix] <= in[ix-1]) { |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 return true; | 104 return true; |
| 105 } | 105 } |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * Return a column containing only the local peak values (all | 108 * Return a column containing only the local peak values (all |
| 109 * others zero). | 109 * others zero). |
| 128 * source column ("in") may be a partial column; it's assumed to | 128 * source column ("in") may be a partial column; it's assumed to |
| 129 * contain enough bins to span the destination range, starting | 129 * contain enough bins to span the destination range, starting |
| 130 * with the bin of index minbin. | 130 * with the bin of index minbin. |
| 131 */ | 131 */ |
| 132 static Column distribute(const Column &in, | 132 static Column distribute(const Column &in, |
| 133 int h, | 133 int h, |
| 134 const std::vector<double> &binfory, | 134 const std::vector<double> &binfory, |
| 135 int minbin, | 135 int minbin, |
| 136 bool interpolate); | 136 bool interpolate); |
| 137 | 137 |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif | 140 #endif |
| 141 | 141 |
