From be8cde6ce396a3fd0db239218f78633f1aa34a1e Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 13 Dec 2015 14:09:04 -0500 Subject: [PATCH] More zoom tweaks, fix half-band tuner step --- src/process/SpectrumVisualProcessor.cpp | 24 +++++++++++++----------- src/visual/TuningCanvas.cpp | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/process/SpectrumVisualProcessor.cpp b/src/process/SpectrumVisualProcessor.cpp index da54ed2..54a86d0 100644 --- a/src/process/SpectrumVisualProcessor.cpp +++ b/src/process/SpectrumVisualProcessor.cpp @@ -186,17 +186,19 @@ void SpectrumVisualProcessor::process() { if (is_view.load()) { long freqDiff = shiftFrequency - lastShiftFrequency; - double binPerHz = double(bandwidth) / double(fftSizeInternal); - - int numShift = round(double(abs(freqDiff)) / binPerHz); - - if (numShift < fftSizeInternal/2) { - if (freqDiff > 0) { - memmove(&fft_result_ma[0], &fft_result_ma[numShift], (fftSizeInternal-numShift) * sizeof(double)); - memmove(&fft_result_maa[0], &fft_result_maa[numShift], (fftSizeInternal-numShift) * sizeof(double)); - } else { - memmove(&fft_result_ma[numShift], &fft_result_ma[0], (fftSizeInternal-numShift) * sizeof(double)); - memmove(&fft_result_maa[numShift], &fft_result_maa[0], (fftSizeInternal-numShift) * sizeof(double)); + if (lastBandwidth!=0) { + double binPerHz = double(lastBandwidth) / double(fftSizeInternal); + + int numShift = floor(double(abs(freqDiff)) / binPerHz); + + if (numShift < fftSizeInternal/2 && numShift) { + if (freqDiff > 0) { + memmove(&fft_result_ma[0], &fft_result_ma[numShift], (fftSizeInternal-numShift) * sizeof(double)); + memmove(&fft_result_maa[0], &fft_result_maa[numShift], (fftSizeInternal-numShift) * sizeof(double)); + } else { + memmove(&fft_result_ma[numShift], &fft_result_ma[0], (fftSizeInternal-numShift) * sizeof(double)); + memmove(&fft_result_maa[numShift], &fft_result_maa[0], (fftSizeInternal-numShift) * sizeof(double)); + } } } } diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 4efd5ad..37073c2 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -162,7 +162,7 @@ void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) { double exp = pow(10, exponent); long long amount = up?exp:-exp; - if (halfBand && exp == 1) { + if (halfBand) { amount *= 2; }