Skip to content

Commit 99779bf

Browse files
committed
More work
1 parent dd4acc1 commit 99779bf

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

examples/graphics/source/examples/FilterDemo.h

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ class PhaseResponseDisplay : public yup::Component
148148
else
149149
label = yup::String (freq, 0);
150150

151-
g.fillFittedText (label, font, { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
151+
g.fillFittedText (label, font.withHeight (10.0f), { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
152152
}
153153

154154
// Phase labels
155155
for (double phase : { -180.0, -90.0, 0.0, 90.0, 180.0 })
156156
{
157157
float y = phaseToY (phase, bounds);
158158
yup::String label = yup::String (phase, 0) + "°";
159-
g.fillFittedText (label, font, { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
159+
g.fillFittedText (label, font.withHeight (10.0f), { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
160160
}
161161
}
162162

@@ -259,15 +259,15 @@ class GroupDelayDisplay : public yup::Component
259259
else
260260
label = yup::String (freq, 0);
261261

262-
g.fillFittedText (label, font, { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
262+
g.fillFittedText (label, font.withHeight (10.0f), { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
263263
}
264264

265265
// Delay labels
266266
for (double delay : { 0.0, 1.0, 5.0, 10.0, 50.0 })
267267
{
268268
float y = delayToY (delay, bounds);
269269
yup::String label = yup::String (delay, 1) + " smp";
270-
g.fillFittedText (label, font, { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
270+
g.fillFittedText (label, font.withHeight (10.0f), { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
271271
}
272272
}
273273

@@ -378,15 +378,15 @@ class StepResponseDisplay : public yup::Component
378378
{
379379
float x = bounds.getX() + i * bounds.getWidth() / 5.0f;
380380
yup::String label = yup::String (i * 20.0f, 0) + " smp"; // 20 samples per division
381-
g.fillFittedText (label, font, { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
381+
g.fillFittedText (label, font.withHeight (10.0f), { x - 20, bounds.getBottom() - 15, 40, 15 }, yup::Justification::center);
382382
}
383383

384384
// Amplitude labels
385385
for (double amp : { 0.0, 0.5, 1.0 })
386386
{
387387
float y = amplitudeToY (amp, bounds);
388388
yup::String label = yup::String (amp, 1);
389-
g.fillFittedText (label, font, { bounds.getX() + 5, y - 8, 40, 16 }, yup::Justification::left);
389+
g.fillFittedText (label, font.withHeight (10.0f), { bounds.getX() + 5, y - 8, 40, 16 }, yup::Justification::left);
390390
}
391391
}
392392

@@ -484,22 +484,22 @@ class PolesZerosDisplay : public yup::Component
484484
g.fillFittedText ("Poles & Zeros", font, bounds.removeFromTop (20), yup::Justification::center);
485485

486486
// Axis labels
487-
g.fillFittedText ("Real", font, { bounds.getRight() - 40, center.getY() - 8, 35, 16 }, yup::Justification::right);
488-
g.fillFittedText ("Imag", font, { center.getX() - 20, bounds.getY() + 5, 40, 16 }, yup::Justification::center);
487+
g.fillFittedText ("Real", font.withHeight (10.0f), { bounds.getRight() - 40, center.getY() - 8, 35, 16 }, yup::Justification::right);
488+
g.fillFittedText ("Imag", font.withHeight (10.0f), { center.getX() - 20, bounds.getY() + 5, 40, 16 }, yup::Justification::center);
489489

490490
// Legend
491491
auto legendY = bounds.getY() + 30;
492492
g.setStrokeColor (yup::Color (0xFF00FF88));
493493
g.setStrokeWidth (2.0f);
494494
g.strokeEllipse (bounds.getX() + 10, legendY, 8, 8);
495-
g.fillFittedText ("Zeros", font, { bounds.getX() + 25, legendY - 2, 40, 16 }, yup::Justification::left);
495+
g.fillFittedText ("Zeros", font.withHeight (10.0f), { bounds.getX() + 25, legendY - 2, 40, 16 }, yup::Justification::left);
496496

497497
g.setStrokeColor (yup::Color (0xFFFF4444));
498498
g.setStrokeWidth (3.0f);
499499
legendY += 20;
500500
g.strokeLine ({ bounds.getX() + 9, legendY + 1 }, { bounds.getX() + 17, legendY + 9 });
501501
g.strokeLine ({ bounds.getX() + 9, legendY + 9 }, { bounds.getX() + 17, legendY + 1 });
502-
g.fillFittedText ("Poles", font, { bounds.getX() + 25, legendY + 1, 40, 16 }, yup::Justification::left);
502+
g.fillFittedText ("Poles", font.withHeight (10.0f), { bounds.getX() + 25, legendY + 1, 40, 16 }, yup::Justification::left);
503503
}
504504

505505
std::vector<std::complex<double>> poles;
@@ -535,6 +535,12 @@ class FrequencyResponsePlot : public yup::Component
535535
updateResponseData();
536536
}
537537

538+
const std::vector<yup::Point<float>>& getPhaseData() const { return phaseData; }
539+
540+
const std::vector<yup::Point<float>>& getGroupDelayData() const { return groupDelayData; }
541+
542+
const std::vector<yup::Point<float>>& getStepResponseData() const { return stepResponseData; }
543+
538544
void updateResponseData()
539545
{
540546
if (! filter)
@@ -735,7 +741,7 @@ class FrequencyResponsePlot : public yup::Component
735741
{
736742
float y = dbToY (db, bounds);
737743
yup::String label = yup::String (db, 0) + " dB";
738-
g.fillFittedText (label, font, { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
744+
g.fillFittedText (label, font.withHeight (10.0f), { bounds.getX() + 5, y - 8, 60, 16 }, yup::Justification::left);
739745
}
740746
}
741747

@@ -760,14 +766,6 @@ class FrequencyResponsePlot : public yup::Component
760766
double sampleRate;
761767
double minFreq, maxFreq;
762768
double minDb, maxDb;
763-
764-
public:
765-
// Accessor methods for the new display widgets
766-
const std::vector<yup::Point<float>>& getPhaseData() const { return phaseData; }
767-
768-
const std::vector<yup::Point<float>>& getGroupDelayData() const { return groupDelayData; }
769-
770-
const std::vector<yup::Point<float>>& getStepResponseData() const { return stepResponseData; }
771769
};
772770

773771
//==============================================================================
@@ -981,6 +979,9 @@ class FilterDemo
981979
inputData.resize (device->getCurrentBufferSizeSamples());
982980
renderData.resize (inputData.size());
983981
readPos = 0;
982+
983+
// Store sample rate for parameter updates
984+
currentSampleRate = sampleRate;
984985
}
985986

986987
void audioDeviceStopped() override
@@ -1249,15 +1250,15 @@ class FilterDemo
12491250
// Update parameters based on filter type
12501251
if (auto bf = std::dynamic_pointer_cast<yup::ButterworthFilter<float>> (currentFilter))
12511252
{
1252-
bf->setParameters (getFilterType (responseTypeId), order, freq, 44100.0);
1253+
bf->setParameters (getFilterType (responseTypeId), order, freq, currentSampleRate);
12531254
}
12541255
else if (auto rf = std::dynamic_pointer_cast<yup::RbjFilter<float>> (currentFilter))
12551256
{
1256-
rf->setParameters (getRbjType (responseTypeId), freq, q, gain, 44100.0);
1257+
rf->setParameters (getRbjType (responseTypeId), freq, q, gain, currentSampleRate);
12571258
}
12581259
else if (auto svf = std::dynamic_pointer_cast<yup::StateVariableFilter<float>> (currentFilter))
12591260
{
1260-
svf->setParameters (freq, q, 44100.0);
1261+
svf->setParameters (freq, q, currentSampleRate);
12611262
svf->setMode (getSvfMode (responseTypeId));
12621263
}
12631264
else if (auto moog = std::dynamic_pointer_cast<yup::MoogLadder<float>> (currentFilter))
@@ -1475,6 +1476,7 @@ class FilterDemo
14751476
WhiteNoiseGenerator noiseGenerator;
14761477
yup::SmoothedValue<float> outputGain { 0.5f };
14771478

1479+
double currentSampleRate = 44100.0;
14781480
// Filter instances
14791481
std::shared_ptr<yup::ButterworthFilter<float>> butterworthFilter;
14801482
std::shared_ptr<yup::RbjFilter<float>> rbjFilter;

0 commit comments

Comments
 (0)