diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-07-17 17:50:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-07-17 17:50:38 +0300 |
commit | 842bd06107983bf1775e9c1bbafc8cbe43ffb164 (patch) | |
tree | 4808bed3ae63572f092686f2e93ff44a2676abaa /src/transient_detector.cpp | |
parent | 1151d5831f19a9f24dd0c545a4968606712a62d2 (diff) | |
download | atracdenc-842bd06107983bf1775e9c1bbafc8cbe43ffb164.tar.gz |
Experimental implementation of gain control.atrac3_gaincontrol
Diffstat (limited to 'src/transient_detector.cpp')
-rw-r--r-- | src/transient_detector.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/transient_detector.cpp b/src/transient_detector.cpp index b0e4aab..d7695f1 100644 --- a/src/transient_detector.cpp +++ b/src/transient_detector.cpp @@ -9,7 +9,7 @@ using std::vector; static TFloat calculateRMS(const TFloat* in, uint32_t n) { TFloat s = 0; for (uint32_t i = 0; i < n; i++) { - s += in[i] * in[i]; + s += (in[i] * in[i]); } s /= n; return sqrt(s); @@ -68,14 +68,14 @@ bool TTransientDetector::Detect(const TFloat* buf) { return trans; } -std::vector<TFloat> AnalyzeGain(const TFloat* in, const uint32_t len, const uint32_t maxPoints) { +std::vector<TFloat> AnalyzeGain(const TFloat* in, const uint32_t len, const uint32_t maxPoints, bool useRms) { vector<TFloat> res; const uint32_t step = len / maxPoints; for (uint32_t pos = 0; pos < len; pos += step) { - TFloat rms = calculatePeak(in + pos, step); + TFloat rms = useRms ? calculateRMS(in + pos, step) : calculatePeak(in + pos, step); res.emplace_back(rms); } return res; } -} +} //namespace NAtracDEnc |