Skip to content

Commit

Permalink
Filter Plotting Component Added to Paint Filter Slopes and Chyron Cut…
Browse files Browse the repository at this point in the history
…off Names Adjusted For 3-Band/4-Band
  • Loading branch information
RachelMaryamLocke committed Jan 30, 2024
1 parent 7093ad4 commit fd2e7b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/gui/BandSplitter/BandSplitterChyron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ void BandSplitterChyron::updateValues()
if (bandState != dsp::band_splitter::BandState::TwoBands)
{
cutoffSliderMid.emplace (state, bandSplitterParams.cutoff2.get(), &hostContextProvider);
cutoffSliderMid->setName ("Cutoff Mid");
if (bandState == dsp::band_splitter::BandState::ThreeBands)
cutoffSliderMid->setName ("Cutoff High");
else
cutoffSliderMid->setName ("Cutoff Mid");
addAndMakeVisible (*cutoffSliderMid);
}
if (bandState == dsp::band_splitter::BandState::FourBands)
Expand Down
40 changes: 24 additions & 16 deletions src/gui/BandSplitter/BandSplitterPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState,
cutoff2Slider.setVisible (bandSplitterParams.threeBandOnOff->get());
cutoff3Slider.setVisible (bandSplitterParams.fourBandOnOff->get());

plotComp.setInterceptsMouseClicks (false, false);
plotComp.parent = this;
addAndMakeVisible (plotComp);

for (int bandIndex = 0; bandIndex < numBands; ++bandIndex)
setFilterActive (bandIndex, true);

Expand Down Expand Up @@ -244,28 +248,13 @@ void BandSplitterPlot::paintOverChildren (juce::Graphics& g)
{ 0.0f },
colours::majorLinesColour,
colours::minorLinesColour);

g.setColour (colours::plotColour);
g.strokePath (getPath (0), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (1), juce::PathStrokeType { 2.0f });

auto bandState = bandSplitterParams.getCurrentBandState();
if (bandState == BandState::FourBands || bandState == BandState::ThreeBands)
{
g.strokePath (getPath (2), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (3), juce::PathStrokeType { 2.0f });
}
if (bandState == BandState::FourBands)
{
g.strokePath (getPath (4), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (5), juce::PathStrokeType { 2.0f });
}
}

void BandSplitterPlot::resized()
{
chowdsp::EQ::EqualizerPlot::resized();

plotComp.setBounds (getLocalBounds());
const auto pad = proportionOfWidth (0.005f);
const auto chyronWidth = proportionOfWidth (0.20f);
const auto chyronHeight = proportionOfWidth (0.1f);
Expand Down Expand Up @@ -383,4 +372,23 @@ const chowdsp::FreqHzParameter::Ptr& BandSplitterPlot::getCutoffParam (int bandI
else
return bandParams.cutoff3;
};

void BandSplitterPlot::FilterPlotComp::paint (juce::Graphics& g)
{
g.setColour (colours::plotColour);
g.strokePath (parent->getPath (0), juce::PathStrokeType { 2.0f });
g.strokePath (parent->getPath (1), juce::PathStrokeType { 2.0f });

auto bandState = parent->bandSplitterParams.getCurrentBandState();
if (bandState == BandState::FourBands || bandState == BandState::ThreeBands)
{
g.strokePath (parent->getPath (2), juce::PathStrokeType { 2.0f });
g.strokePath (parent->getPath (3), juce::PathStrokeType { 2.0f });
}
if (bandState == BandState::FourBands)
{
g.strokePath (parent->getPath (4), juce::PathStrokeType { 2.0f });
g.strokePath (parent->getPath (5), juce::PathStrokeType { 2.0f });
}
}
} // namespace gui::band_splitter
9 changes: 9 additions & 0 deletions src/gui/BandSplitter/BandSplitterPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ class BandSplitterPlot : public chowdsp::EQ::EqualizerPlot
void updateSpectrumPlots();
static const chowdsp::FreqHzParameter::Ptr& getCutoffParam (int bandIndex, const dsp::band_splitter::Params& params);

struct FilterPlotComp : juce::Component
{
void paint (juce::Graphics& g);
void resized() { repaint(); }

BandSplitterPlot* parent = nullptr;
};

const dsp::band_splitter::Params& bandSplitterParams;
dsp::band_splitter::ExtraState& extraState;
chowdsp::ScopedCallbackList callbacks;
FilterPlotComp plotComp;

struct InternalSlider : juce::Slider
{
Expand Down

0 comments on commit fd2e7b6

Please sign in to comment.