@@ -727,7 +727,7 @@ class FrequencyResponsePlot : public yup::Component
727727 else
728728 label = yup::String (freq, 0 );
729729
730- g.fillFittedText (label, font, { x - 20 , bounds.getBottom () - 15 , 40 , 15 }, yup::Justification::center);
730+ g.fillFittedText (label, font, { x - 20 , bounds.getBottom () - 15 , 40 , 15 }, yup::Justification::center);
731731 }
732732
733733 // dB labels
@@ -772,6 +772,42 @@ class FrequencyResponsePlot : public yup::Component
772772
773773// ==============================================================================
774774
775+ class FilterOscilloscope : public yup ::Component
776+ {
777+ public:
778+ void setRenderData (const std::vector<float >& data, int newReadPos)
779+ {
780+ renderData = data;
781+ }
782+
783+ void paint (yup::Graphics& g) override
784+ {
785+ auto bounds = getLocalBounds ();
786+
787+ g.setFillColor (yup::Color (0xff101010 ));
788+ g.fillAll ();
789+
790+ if (renderData.empty ()) return ;
791+
792+ yup::Path path;
793+ float xStep = static_cast <float > (bounds.getWidth ()) / renderData.size ();
794+ float centerY = bounds.getHeight () * 0 .5f ;
795+
796+ path.moveTo (0 , centerY + renderData[0 ] * centerY);
797+ for (size_t i = 1 ; i < renderData.size (); ++i)
798+ path.lineTo (i * xStep, centerY + renderData[i] * centerY);
799+
800+ g.setStrokeColor (yup::Color (0xff4fc3f7 ));
801+ g.setStrokeWidth (2 .0f );
802+ g.strokePath (path);
803+ }
804+
805+ private:
806+ std::vector<float > renderData;
807+ };
808+
809+ // ==============================================================================
810+
775811class FilterDemo
776812 : public yup::Component
777813 , public yup::AudioIODeviceCallback
@@ -1269,10 +1305,10 @@ class FilterDemo
12691305 std::vector<std::complex <double >> zeros;
12701306
12711307 // Extract poles and zeros based on filter type
1272- if (auto biquad = std::dynamic_pointer_cast<yup::Biquad <float >> (currentFilter))
1308+ if (auto rbj = std::dynamic_pointer_cast<yup::RbjFilter <float >> (currentFilter))
12731309 {
12741310 // For biquad filters, calculate poles and zeros from coefficients
1275- calculateBiquadPolesZeros (biquad , poles, zeros);
1311+ calculateBiquadPolesZeros (rbj-> getCoefficients () , poles, zeros);
12761312 }
12771313 else if (auto butter = std::dynamic_pointer_cast<yup::ButterworthFilter<float >> (currentFilter))
12781314 {
@@ -1284,17 +1320,14 @@ class FilterDemo
12841320 polesZerosDisplay.updatePolesZeros (poles, zeros);
12851321 }
12861322
1287- void calculateBiquadPolesZeros (std::shared_ptr< yup::Biquad< float > > biquad,
1323+ void calculateBiquadPolesZeros (yup::BiquadCoefficients< double > biquad,
12881324 std::vector<std::complex <double >>& poles,
12891325 std::vector<std::complex <double >>& zeros)
12901326 {
1291- if (! biquad)
1292- return ;
1293-
12941327 // Get biquad coefficients (assuming they're accessible)
12951328 // This is a simplified version - you might need to access coefficients differently
1296- double a1 = 0.0 , a2 = 0.0 ; // Denominator coefficients
1297- double b0 = 1.0 , b1 = 0.0 , b2 = 0.0 ; // Numerator coefficients
1329+ double a1 = biquad. a1 , a2 = biquad. a2 ; // Denominator coefficients
1330+ double b0 = biquad. b0 , b1 = biquad. b1 , b2 = biquad. b2 ; // Numerator coefficients
12981331
12991332 // Calculate poles from denominator: 1 + a1*z^-1 + a2*z^-2 = 0
13001333 // Rearranged: z^2 + a1*z + a2 = 0
@@ -1473,41 +1506,7 @@ class FilterDemo
14731506 GroupDelayDisplay groupDelayDisplay;
14741507 StepResponseDisplay stepResponseDisplay;
14751508 PolesZerosDisplay polesZerosDisplay;
1476-
1477- class Oscilloscope : public yup ::Component
1478- {
1479- public:
1480- void setRenderData (const std::vector<float >& data, int newReadPos)
1481- {
1482- renderData = data;
1483- }
1484-
1485- void paint (yup::Graphics& g) override
1486- {
1487- auto bounds = getLocalBounds ();
1488-
1489- g.setFillColor (yup::Color (0xff101010 ));
1490- g.fillAll ();
1491-
1492- if (renderData.empty ())
1493- return ;
1494-
1495- yup::Path path;
1496- float xStep = static_cast <float > (bounds.getWidth ()) / renderData.size ();
1497- float centerY = bounds.getHeight () * 0 .5f ;
1498-
1499- path.moveTo (0 , centerY + renderData[0 ] * centerY);
1500- for (size_t i = 1 ; i < renderData.size (); ++i)
1501- path.lineTo (i * xStep, centerY + renderData[i] * centerY);
1502-
1503- g.setStrokeColor (yup::Color (0xff4fc3f7 ));
1504- g.setStrokeWidth (2 .0f );
1505- g.strokePath (path);
1506- }
1507-
1508- private:
1509- std::vector<float > renderData;
1510- } oscilloscope;
1509+ FilterOscilloscope oscilloscope;
15111510
15121511 // Audio buffer management
15131512 std::vector<float > inputData;
0 commit comments