commit e7f13f9871f7e9e0c4d7760cf295f5e463ecd609
parent 5dc53892d2e68c9ac92a67a9ccbeff606add9f93
Author: Matt Demanett <matt@demanett.net>
Date: Sat, 19 Sep 2020 02:20:51 -0400
Analyzers: undo old "fix" for peak frequency calculation, that now looks very wrong.
Diffstat:
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/Ranalyzer.cpp b/src/Ranalyzer.cpp
@@ -121,7 +121,7 @@ void Ranalyzer::processAll(const ProcessArgs& args) {
out = inputs[TEST_INPUT].getVoltage();
}
else {
- out = _chirp.next() * 5.0f;
+ out = _chirp.next() * 10.0f;
}
_inputBuffer.push(out);
if (_bufferCount > 0) {
diff --git a/src/analyzer_base.cpp b/src/analyzer_base.cpp
@@ -188,15 +188,18 @@ float AnalyzerCore::getPeak(int channel) {
const int bandsPerBin = _size / _binsN;
const float fWidth = (APP->engine->getSampleRate() / 2.0f) / (float)(_size / bandsPerBin);
- float sum = 0.0f;
- float sumWeights = 0.0f;
- int i = std::max(0, maxBin - 1);
- int j = std::max(_binsN - 1, maxBin + 1);
- for (; i <= j; ++i) {
- sum += bins[i] * fWidth * i;
- sumWeights += bins[i];
- }
- return sum / sumWeights;
+
+ return (maxBin + 0.5f)*fWidth;
+ // ??
+ // float sum = 0.0f;
+ // float sumWeights = 0.0f;
+ // int i = std::max(0, maxBin - 1);
+ // int j = std::max(_binsN - 1, maxBin + 1);
+ // for (; i <= j; ++i) {
+ // sum += bins[i] * fWidth * i;
+ // sumWeights += bins[i];
+ // }
+ // return sum / sumWeights;
}
void AnalyzerCore::stepChannel(int channelIndex, Input& input) {