From bde9d9a890406639efe3395e33a1231d11f196a9 Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Sat, 1 Nov 2025 16:07:01 +0400 Subject: [PATCH] add the remaining deletes, spectrum lines mult by dpiScale --- src/gui/gui.cpp | 8 ++++++++ src/gui/gui.h | 3 ++- src/gui/spectrum.cpp | 13 ++++++++++--- src/gui/tuner.cpp | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index e4f8f6a24..3cef5c3ba 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -8611,9 +8611,17 @@ bool FurnaceGUI::finish(bool saveConfig) { delete[] spectrum.in; spectrum.in=NULL; } + if (spectrum.plan) { + fftw_free(spectrum.plan); + spectrum.plan=NULL; + } if (spectrum.buffer) { fftw_free(spectrum.buffer); } + if (spectrum.plot) { + delete[] spectrum.plot; + spectrum.plot=NULL; + } return true; } diff --git a/src/gui/gui.h b/src/gui/gui.h index b2d85e7f1..d83a8da60 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2757,12 +2757,13 @@ class FurnaceGUI { bool update, running, mono; bool showXGrid, showYGrid, showXScale, showYScale; SpectrumSettings(): - bins(2048), + bins(4096), xZoom(1.0f), xOffset(0.0f), yOffset(0.0f), buffer(NULL), in(NULL), + plot(NULL), frequencies({}), update(true), running(false), diff --git a/src/gui/spectrum.cpp b/src/gui/spectrum.cpp index 7ec039f3a..f8db7cab1 100644 --- a/src/gui/spectrum.cpp +++ b/src/gui/spectrum.cpp @@ -75,7 +75,8 @@ void FurnaceGUI::drawSpectrum() { dl->AddLine( origin+ImVec2(0,size.y*((float)z/lines-offset)), origin+ImVec2(size.x,size.y*((float)z/lines-offset)), - 0x55ffffff); + 0x55ffffff, + dpiScale); } } // x grid @@ -104,7 +105,8 @@ void FurnaceGUI::drawSpectrum() { if (spectrum.showXGrid) dl->AddLine( origin+ImVec2(pos,0), origin+ImVec2(pos,size.y), - color); + color, + dpiScale); prevPos=pos; } } @@ -124,6 +126,10 @@ void FurnaceGUI::drawSpectrum() { delete[] spectrum.plot; spectrum.plot=NULL; } + if (spectrum.plan) { + fftw_free(spectrum.plan); + spectrum.plan=NULL; + } spectrum.buffer=(fftw_complex*)fftw_malloc(sizeof(fftw_complex)*spectrum.bins); if (!spectrum.buffer) spectrum.running=false; spectrum.in=new double[spectrum.bins]; @@ -131,6 +137,7 @@ void FurnaceGUI::drawSpectrum() { spectrum.plot=new ImVec2[spectrum.bins/2]; if (!spectrum.plot) spectrum.running=false; spectrum.plan=fftw_plan_dft_r2c_1d(spectrum.bins,spectrum.in,spectrum.buffer,FFTW_ESTIMATE); + if (!spectrum.plan) spectrum.running=false; spectrum.frequencies.clear(); float freq; float maxRate=e->getAudioDescGot().rate/2; @@ -175,7 +182,7 @@ void FurnaceGUI::drawSpectrum() { spectrum.plot[i].y=origin.y+size.y*(y-spectrum.yOffset); } ImGui::PushClipRect(origin,origin+size,true); - dl->AddPolyline(spectrum.plot,count,ImGui::GetColorU32(uiColors[spectrum.mono?GUI_COLOR_OSC_WAVE:GUI_COLOR_OSC_WAVE_CH0+z]),0,1.0f); + dl->AddPolyline(spectrum.plot,count,ImGui::GetColorU32(uiColors[spectrum.mono?GUI_COLOR_OSC_WAVE:GUI_COLOR_OSC_WAVE_CH0+z]),0,dpiScale); dl->PathFillConcave(ImGui::GetColorU32(uiColors[spectrum.mono?GUI_COLOR_OSC_WAVE:GUI_COLOR_OSC_WAVE_CH0+z])); ImGui::PopClipRect(); } diff --git a/src/gui/tuner.cpp b/src/gui/tuner.cpp index 126da2a58..78e61da5e 100644 --- a/src/gui/tuner.cpp +++ b/src/gui/tuner.cpp @@ -126,11 +126,12 @@ void FurnaceGUI::drawTuner() { ImU32 lowColor=ImGui::GetColorU32(uiColors[GUI_COLOR_TUNER_SCALE_LOW]); ImU32 highColor=ImGui::GetColorU32(uiColors[GUI_COLOR_TUNER_SCALE_HIGH]); + // needle bg ImGui::Dummy(ImVec2(size.x,boxHeight)); dl->AddRectFilledMultiColor(origin,origin+ImVec2(size.x/2.0f,boxHeight),highColor,lowColor,lowColor,highColor); dl->AddRectFilledMultiColor(origin+ImVec2(size.x/2.0f,0),origin+ImVec2(size.x,boxHeight),lowColor,highColor,highColor,lowColor); dl->AddLine(origin+ImVec2(size.x/2.0f,0),origin+ImVec2(size.x/2.0f,boxHeight),ImGui::GetColorU32(uiColors[GUI_COLOR_TUNER_NEEDLE]),2.0f*dpiScale); - + // needle float needleX=size.x*(0.5f+cents); dl->AddLine(origin+ImVec2(needleX,boxHeight-needleHeight),origin+ImVec2(needleX,needleHeight),ImGui::GetColorU32(uiColors[GUI_COLOR_TUNER_NEEDLE]),4.0f*dpiScale); // text