@@ -285,7 +285,7 @@ class SpectrumAnalyzerDemo
285285 // Update FFT info display
286286 if (fftInfoLabel)
287287 {
288- yup::String fftText = " FFT: " + yup::String (currentFFTSize) + " , Overlap: " + yup::String (currentOverlapPercent) + " % " ;
288+ yup::String fftText = " FFT: " + yup::String (currentFFTSize);
289289 fftInfoLabel->setText (fftText, yup::dontSendNotification);
290290 }
291291 }
@@ -302,10 +302,7 @@ class SpectrumAnalyzerDemo
302302 for (int sample = 0 ; sample < numSamples; ++sample)
303303 {
304304 // Generate audio sample using signal generator
305- float audioSample = signalGenerator.getNextSample ();
306-
307- // Scale final output
308- audioSample *= masterVolume;
305+ const float audioSample = signalGenerator.getNextSample ();
309306
310307 // Output to all channels
311308 for (int channel = 0 ; channel < numOutputChannels; ++channel)
@@ -316,7 +313,7 @@ class SpectrumAnalyzerDemo
316313 }
317314 }
318315
319- void audioDeviceAboutToStart (yup::AudioIODevice* device) override
316+ void audioDeviceAboutToStart (yup::AudioIODevice* device) override
320317 {
321318 double sampleRate = device->getCurrentSampleRate ();
322319
@@ -349,7 +346,7 @@ class SpectrumAnalyzerDemo
349346 // Signal type selector
350347 signalTypeCombo = std::make_unique<yup::ComboBox> (" SignalType" );
351348 signalTypeCombo->addItem (" Single Tone" , 1 );
352- signalTypeCombo->addItem (" Frequency Sweep" , 2 );
349+ signalTypeCombo->addItem (" Sweep" , 2 );
353350 signalTypeCombo->addItem (" White Noise" , 3 );
354351 signalTypeCombo->addItem (" Pink Noise" , 4 );
355352 signalTypeCombo->addItem (" Brown Noise" , 5 );
@@ -398,43 +395,28 @@ class SpectrumAnalyzerDemo
398395 fftSizeCombo = std::make_unique<yup::ComboBox> (" FFTSize" );
399396 int fftSizeId = 1 ;
400397 for (int size = 32 ; size <= 16384 ; size *= 2 )
401- {
402398 fftSizeCombo->addItem (yup::String (size), fftSizeId++);
403- }
404- fftSizeCombo->setSelectedId (9 ); // 2048 (default)
399+ fftSizeCombo->setSelectedId (8 );
405400 fftSizeCombo->onSelectedItemChanged = [this ]
406401 {
407402 updateFFTSize ();
408403 };
409404 addAndMakeVisible (*fftSizeCombo);
410405
411- // Overlap selector
412- overlapCombo = std::make_unique<yup::ComboBox> (" Overlap" );
413- overlapCombo->addItem (" 0%" , 1 );
414- overlapCombo->addItem (" 25%" , 2 );
415- overlapCombo->addItem (" 50%" , 3 );
416- overlapCombo->addItem (" 75%" , 4 );
417- overlapCombo->setSelectedId (4 ); // 75% default
418- overlapCombo->onSelectedItemChanged = [this ]
419- {
420- updateOverlap ();
421- };
422- addAndMakeVisible (*overlapCombo);
423-
424406 // Window type selector
425407 windowTypeCombo = std::make_unique<yup::ComboBox> (" WindowType" );
426408 windowTypeCombo->addItem (" Rectangular" , 1 );
427409 windowTypeCombo->addItem (" Hann" , 2 );
428410 windowTypeCombo->addItem (" Hamming" , 3 );
429411 windowTypeCombo->addItem (" Blackman" , 4 );
430- windowTypeCombo->addItem (" Blackman -Harris" , 5 );
412+ windowTypeCombo->addItem (" B -Harris" , 5 );
431413 windowTypeCombo->addItem (" Kaiser" , 6 );
432414 windowTypeCombo->addItem (" Gaussian" , 7 );
433415 windowTypeCombo->addItem (" Tukey" , 8 );
434416 windowTypeCombo->addItem (" Bartlett" , 9 );
435417 windowTypeCombo->addItem (" Welch" , 10 );
436418 windowTypeCombo->addItem (" Flat-top" , 11 );
437- windowTypeCombo->setSelectedId (2 ); // Hann
419+ windowTypeCombo->setSelectedId (4 );
438420 windowTypeCombo->onSelectedItemChanged = [this ]
439421 {
440422 updateWindowType ();
@@ -478,7 +460,7 @@ class SpectrumAnalyzerDemo
478460 addAndMakeVisible (*amplitudeLabel);
479461
480462 fftInfoLabel = std::make_unique<yup::Label> (" FFTInfoLabel" );
481- fftInfoLabel->setText (" FFT: 2048, Overlap: 75% " );
463+ fftInfoLabel->setText (" FFT: 2048" );
482464 fftInfoLabel->setColor (yup::Label::Style::textFillColorId, yup::Colors::lightgray);
483465 fftInfoLabel->setFont (statusFont);
484466 addAndMakeVisible (*fftInfoLabel);
@@ -494,23 +476,15 @@ class SpectrumAnalyzerDemo
494476 // Create parameter labels with proper font sizing
495477 auto labelFont = font.withHeight (12 .0f );
496478
497- for (const auto & labelText : { " Signal Type:" , " Frequency:" , " Amplitude:" , " Sweep Duration:" ,
498- " FFT Size:" , " Overlap: " , " Window:" , " Display:" , " Release:" })
479+ for (const auto & labelText : { " Signal Type:" , " Frequency:" , " Amplitude:" , " Sweep Duration:" ,
480+ " FFT Size:" , " Window:" , " Display:" , " Release:" })
499481 {
500482 auto label = parameterLabels.add (std::make_unique<yup::Label> (labelText));
501483 label->setText (labelText);
502484 label->setColor (yup::Label::Style::textFillColorId, yup::Colors::lightgray);
503485 label->setFont (labelFont);
504486 addAndMakeVisible (*label);
505487 }
506-
507- // Initialize parameters
508- currentFrequency = 440.0 ;
509- currentAmplitude = 0 .5f ;
510- sweepDurationSeconds = 10.0 ;
511- masterVolume = 0 .3f ;
512- currentFFTSize = 2048 ;
513- currentOverlapPercent = 75 ;
514488 }
515489
516490 void setupAudio ()
@@ -547,26 +521,23 @@ class SpectrumAnalyzerDemo
547521 parameterLabels[3 ]->setBounds (sweepSection.removeFromTop (labelHeight));
548522 sweepDurationSlider->setBounds (sweepSection.removeFromTop (controlHeight));
549523
550- parameterLabels[8 ]->setBounds (smoothingSection.removeFromTop (labelHeight));
524+ parameterLabels[7 ]->setBounds (smoothingSection.removeFromTop (labelHeight));
551525 releaseSlider->setBounds (smoothingSection.removeFromTop (controlHeight));
552526
553527 // Second row: FFT controls
554528 auto row2 = bounds.removeFromTop (rowHeight);
555529 auto fftSizeSection = row2.removeFromLeft (colWidth);
556- auto overlapSection = row2.removeFromLeft (colWidth);
557530 auto windowSection = row2.removeFromLeft (colWidth);
558531 auto displaySection = row2.removeFromLeft (colWidth);
532+ row2.removeFromLeft (colWidth); // Skip unused column
559533
560534 parameterLabels[4 ]->setBounds (fftSizeSection.removeFromTop (labelHeight));
561535 fftSizeCombo->setBounds (fftSizeSection.removeFromTop (controlHeight));
562536
563- parameterLabels[5 ]->setBounds (overlapSection.removeFromTop (labelHeight));
564- overlapCombo->setBounds (overlapSection.removeFromTop (controlHeight));
565-
566- parameterLabels[6 ]->setBounds (windowSection.removeFromTop (labelHeight));
537+ parameterLabels[5 ]->setBounds (windowSection.removeFromTop (labelHeight));
567538 windowTypeCombo->setBounds (windowSection.removeFromTop (controlHeight));
568539
569- parameterLabels[7 ]->setBounds (displaySection.removeFromTop (labelHeight));
540+ parameterLabels[6 ]->setBounds (displaySection.removeFromTop (labelHeight));
570541 displayTypeCombo->setBounds (displaySection.removeFromTop (controlHeight));
571542
572543 // Third row: Status labels
@@ -607,23 +578,8 @@ class SpectrumAnalyzerDemo
607578 int selectedId = fftSizeCombo->getSelectedId ();
608579 currentFFTSize = 32 << (selectedId - 1 ); // 32, 64, 128, 256, ..., 16384
609580
610- // Update the analyzer component with the new FFT size
611- analyzerComponent.setFFTSize (currentFFTSize);
612- }
613-
614- void updateOverlap ()
615- {
616- switch (overlapCombo->getSelectedId ())
617- {
618- case 1 : currentOverlapPercent = 0 ; break ;
619- case 2 : currentOverlapPercent = 25 ; break ;
620- case 3 : currentOverlapPercent = 50 ; break ;
621- case 4 : currentOverlapPercent = 75 ; break ;
622- }
623-
624- // Update the analyzer component with the new overlap factor
625- float overlapFactor = float (currentOverlapPercent) / 100 .0f ;
626- analyzerComponent.setOverlapFactor (overlapFactor);
581+ // Update the analyzer state with the new FFT size
582+ analyzerState.setFftSize (currentFFTSize);
627583 }
628584
629585 void updateWindowType ()
@@ -680,7 +636,6 @@ class SpectrumAnalyzerDemo
680636
681637 // FFT controls
682638 std::unique_ptr<yup::ComboBox> fftSizeCombo;
683- std::unique_ptr<yup::ComboBox> overlapCombo;
684639 std::unique_ptr<yup::ComboBox> windowTypeCombo;
685640 std::unique_ptr<yup::ComboBox> displayTypeCombo;
686641 std::unique_ptr<yup::Slider> releaseSlider;
@@ -696,7 +651,5 @@ class SpectrumAnalyzerDemo
696651 double currentFrequency = 440.0 ;
697652 float currentAmplitude = 0 .5f ;
698653 double sweepDurationSeconds = 10.0 ;
699- float masterVolume = 0 .3f ;
700- int currentFFTSize = 2048 ;
701- int currentOverlapPercent = 75 ;
654+ int currentFFTSize = 4096 ;
702655};
0 commit comments