Skip to content

Commit c2609cb

Browse files
committed
More eye candy
1 parent 48dff24 commit c2609cb

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

modules/yup_audio_gui/displays/yup_SpectrumAnalyzerComponent.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SpectrumAnalyzerComponent::SpectrumAnalyzerComponent (SpectrumAnalyzerState& sta
3232

3333
initializeFFTBuffers();
3434
generateWindow();
35+
3536
startTimerHz (30); // 30 FPS updates by default
3637
}
3738

@@ -56,15 +57,21 @@ void SpectrumAnalyzerComponent::initializeFFTBuffers()
5657
//==============================================================================
5758
void SpectrumAnalyzerComponent::timerCallback()
5859
{
60+
if (! isShowing())
61+
return;
62+
5963
bool hasNewData = false;
6064
int fftCount = 0;
61-
const int maxFFTsPerFrame = 8; // Limit to prevent blocking UI thread
65+
66+
constexpr int maxFFTsPerFrame = 4; // Limit to prevent blocking UI thread
6267

6368
// Process multiple FFT frames with overlap for better responsiveness
6469
while (analyzerState.isFFTDataReady() && fftCount < maxFFTsPerFrame)
6570
{
6671
processFFT();
72+
6773
hasNewData = true;
74+
6875
++fftCount;
6976
}
7077

@@ -281,9 +288,29 @@ void SpectrumAnalyzerComponent::drawLinesSpectrum (Graphics& g, const Rectangle<
281288
spectrumPath.startNewSubPath (bounds.getX(), firstY);
282289
computeSpectrumPath (spectrumPath, bounds, false);
283290

284-
g.setStrokeColor (Color (0xFF00ff40));
285-
g.setStrokeWidth (2.0f);
291+
auto filledPath = spectrumPath.createStrokePolygon (4.0f);
292+
auto lineColor = Color (0xFF00a840);
293+
286294
g.setStrokeJoin (StrokeJoin::Round);
295+
296+
g.setFillColor (lineColor);
297+
g.setFeather (8.0f);
298+
g.fillPath (filledPath);
299+
300+
g.setFillColor (lineColor.brighter (0.2f));
301+
g.setFeather (4.0f);
302+
g.fillPath (filledPath);
303+
304+
g.setStrokeColor (lineColor.withAlpha (0.8f));
305+
g.setStrokeWidth (2.0f);
306+
g.strokePath (spectrumPath);
307+
308+
g.setStrokeColor (lineColor.brighter (0.3f));
309+
g.setStrokeWidth (1.0f);
310+
g.strokePath (spectrumPath);
311+
312+
g.setStrokeColor (yup::Colors::white.withAlpha (0.9f));
313+
g.setStrokeWidth (0.5f);
287314
g.strokePath (spectrumPath);
288315
}
289316

0 commit comments

Comments
 (0)