From 14f8273e13bd94d5cd59f7102b5fd970af8dafd5 Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Wed, 5 Nov 2025 12:34:48 +0400 Subject: [PATCH] Revert "spectrum: store own channel count" This reverts commit 6f501a91b24ebb544d2216fbbae219d0e64534f5. --- src/gui/gui.h | 3 +-- src/gui/spectrum.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index 96b34ec7a..92465b2e3 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2770,7 +2770,7 @@ class FurnaceGUI { fftw_complex* tunerFFTOutBuf; fftw_plan tunerPlan; struct SpectrumSettings { - int bins, chans; + int bins; float xZoom, xOffset; float yOffset; fftw_plan plan[DIV_MAX_OUTPUTS]; @@ -2782,7 +2782,6 @@ class FurnaceGUI { bool showXGrid, showYGrid, showXScale, showYScale; SpectrumSettings(): bins(4096), - chans(0), xZoom(1.0f), xOffset(0.0f), yOffset(0.0f), diff --git a/src/gui/spectrum.cpp b/src/gui/spectrum.cpp index baf283b75..1e4dfddb9 100644 --- a/src/gui/spectrum.cpp +++ b/src/gui/spectrum.cpp @@ -110,10 +110,10 @@ void FurnaceGUI::drawSpectrum() { prevPos=pos; } } + int chans=e->getAudioDescGot().outChans; if (spectrum.update) { spectrum.update=false; spectrum.running=true; - spectrum.chans=e->getAudioDescGot().outChans; // save our own channel count in case it changes at around line 157 for (int i=0; i=0; z--) { + for (int z=spectrum.mono?0:(chans-1); z>=0; z--) { // get buffer memset(spectrum.in[z],0,sizeof(double)*spectrum.bins); int needle=e->oscReadPos-spectrum.bins; @@ -165,10 +165,10 @@ void FurnaceGUI::drawSpectrum() { int pos=(needle+j)&0x7fff; double sample=0.0; if (spectrum.mono) { - for (int i=0; ioscBuf[i][pos]; } - sample/=spectrum.chans; + sample/=chans; } else { sample+=e->oscBuf[z][pos]; }