From 6ec9e1a9962a9d3fe82540287899c2356e882784 Mon Sep 17 00:00:00 2001 From: Markus Schmidt Date: Tue, 3 Jul 2018 13:43:48 +0200 Subject: [PATCH] Analyzer: fix crash if host didn't set srate before opening the UI (QTractor) --- src/analyzer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/analyzer.cpp b/src/analyzer.cpp index d9ee44738..4520c93d6 100644 --- a/src/analyzer.cpp +++ b/src/analyzer.cpp @@ -366,7 +366,7 @@ void analyzer::draw(int subindex, float *data, int points, bool fftdone) const int _last = -1; // used for mode 10 (parallel spectralizer) to prevent overwriting real values with INFINITY float posneg = 1; int __speed = 16 - (int)_speed; - if (lintrans < 0) { + if (lintrans < 0 && srate) { // accuracy was changed so we have to recalc linear transition int _lintrans = (int)((float)points * log((20.f + 2.f * \ (float)srate / (float)_accuracy) / 20.f) / log(1000.f)); @@ -399,7 +399,7 @@ void analyzer::draw(int subindex, float *data, int points, bool fftdone) const // we have logarithmic view enabled _iter = std::max(1, (int)floor(freq * (float)_accuracy / (float)srate)); } - if(_iter > iter) { + if(_iter > iter && srate) { // we are flipping one step further in drawing if(fftdone and i) { // ################################ @@ -770,6 +770,9 @@ void analyzer::draw(int subindex, float *data, int points, bool fftdone) const data[i / 2] = INFINITY; data[points / 2 + i / 2] = INFINITY; } + else { + data[i] = INFINITY; + } } } }