Skip to content

Commit 4bd54d7

Browse files
committed
More tweaks
1 parent c6d3383 commit 4bd54d7

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

modules/yup_audio_gui/displays/yup_SpectrumAnalyzerComponent.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ void SpectrumAnalyzerComponent::processFFT()
7979
// Update window if needed
8080
if (needsWindowUpdate)
8181
{
82-
generateWindow();
8382
needsWindowUpdate = false;
83+
84+
generateWindow();
8485
}
8586

8687
// Apply window function
@@ -312,31 +313,6 @@ void SpectrumAnalyzerComponent::drawFilledSpectrum (Graphics& g, const Rectangle
312313
g.strokePath (spectrumPath);
313314
}
314315

315-
void SpectrumAnalyzerComponent::computeSpectrumPath (Path spectrumPath, const Rectangle<float>& bounds, bool closePath)
316-
{
317-
float lastX = 0.0f;
318-
319-
// Draw the spectrum curve
320-
for (int i = 0; i < scopeSize; ++i)
321-
{
322-
const float proportion = float (i) / float (scopeSize - 1);
323-
const float frequency = std::pow (10.0f, logMinFrequency + proportion * (logMaxFrequency - logMinFrequency));
324-
const float x = frequencyToX (frequency, bounds);
325-
const float y = binToY (i, bounds.getHeight());
326-
327-
spectrumPath.lineTo (x, y);
328-
329-
lastX = x;
330-
}
331-
332-
// End at baseline at the last spectrum frequency
333-
if (closePath)
334-
{
335-
spectrumPath.lineTo (lastX, bounds.getBottom());
336-
spectrumPath.closeSubPath();
337-
}
338-
}
339-
340316
void SpectrumAnalyzerComponent::drawFrequencyGrid (Graphics& g, const Rectangle<float>& bounds)
341317
{
342318
auto font = ApplicationTheme::getGlobalTheme()->getDefaultFont().withHeight (10.0f);
@@ -450,12 +426,39 @@ void SpectrumAnalyzerComponent::resized()
450426
// Component has been resized - no specific action needed for now
451427
}
452428

429+
//==============================================================================
430+
void SpectrumAnalyzerComponent::computeSpectrumPath (Path spectrumPath, const Rectangle<float>& bounds, bool closePath)
431+
{
432+
float lastX = 0.0f;
433+
434+
// Draw the spectrum curve
435+
for (int i = 0; i < scopeSize; ++i)
436+
{
437+
const float proportion = float (i) / float (scopeSize - 1);
438+
const float frequency = std::pow (10.0f, logMinFrequency + proportion * (logMaxFrequency - logMinFrequency));
439+
const float x = frequencyToX (frequency, bounds);
440+
const float y = binToY (i, bounds.getHeight());
441+
442+
spectrumPath.lineTo (x, y);
443+
444+
lastX = x;
445+
}
446+
447+
// End at baseline at the last spectrum frequency
448+
if (closePath)
449+
{
450+
spectrumPath.lineTo (lastX, bounds.getBottom());
451+
spectrumPath.closeSubPath();
452+
}
453+
}
454+
453455
//==============================================================================
454456
void SpectrumAnalyzerComponent::setWindowType (WindowType type)
455457
{
456458
if (currentWindowType != type)
457459
{
458460
currentWindowType = type;
461+
459462
needsWindowUpdate = true;
460463
}
461464
}

0 commit comments

Comments
 (0)