Mercurial > hg > svcore
diff base/ColumnOp.h @ 1195:c118d2022ffa spectrogram-minor-refactor
Scale range matching
author | Chris Cannam |
---|---|
date | Mon, 01 Aug 2016 15:06:16 +0100 |
parents | 927d329252bf |
children | fbe0fd84cb50 |
line wrap: on
line diff
--- a/base/ColumnOp.h Wed Jul 20 13:40:23 2016 +0100 +++ b/base/ColumnOp.h Mon Aug 01 15:06:16 2016 +0100 @@ -52,18 +52,26 @@ typedef std::vector<float> Column; /** + * Scale the given column using the given gain multiplier. + */ + static Column applyGain(const Column &in, float gain) { + + if (gain == 1.f) { + return in; + } + Column out; + out.reserve(in.size()); + for (auto v: in) { + out.push_back(v * gain); + } + return out; + } + + /** * Scale an FFT output by half the FFT size. */ static Column fftScale(const Column &in, int fftSize) { - - Column out; - out.reserve(in.size()); - float scale = 2.f / float(fftSize); - for (auto v: in) { - out.push_back(v * scale); - } - - return out; + return applyGain(in, 2.f / float(fftSize)); } /** @@ -144,22 +152,6 @@ } /** - * Scale the given column using the given gain multiplier. - */ - static Column applyGain(const Column &in, float gain) { - - if (gain == 1.f) { - return in; - } - Column out; - out.reserve(in.size()); - for (auto v: in) { - out.push_back(v * gain); - } - return out; - } - - /** * Distribute the given column into a target vector of a different * size, optionally using linear interpolation. The binfory vector * contains a mapping from y coordinate (i.e. index into the