Skip to content

Commit

Permalink
PR comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelMaryamLocke committed Jan 19, 2024
1 parent b0cce36 commit 2509dc6
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 48 deletions.
13 changes: 6 additions & 7 deletions src/gui/BandSplitter/BandSplitterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BandSplitterEditor::BandSplitterEditor (State& pluginState,
spectrumTasks),
slopePicker (pluginState, *params.slope),
extraState (bandSplitterExtraState),
triStateButton (*params.threeBandOnOff, *params.fourBandOnOff, pluginState)
triStateButton (pluginState)
{
addAndMakeVisible (bandSplitterPlot);
addAndMakeVisible (slopePicker);
Expand Down Expand Up @@ -47,13 +47,12 @@ void BandSplitterEditor::resized()
triStateButton.setBounds (getWidth() - pad - dim, pad, dim, dim);
}

BandSplitterEditor::TriStateButton::TriStateButton (chowdsp::BoolParameter& threeBandOnOff, chowdsp::BoolParameter& fourBandOnOff, State& pluginState) : juce::Button ("TriState"),
threeBandOnOffParam (threeBandOnOff),
fourBandOnOffParam (fourBandOnOff),
triStateButtonAttachment (threeBandOnOff, fourBandOnOff, pluginState, *this, currentState)
BandSplitterEditor::TriStateButton::TriStateButton (State& pluginState) : juce::Button ("TriState"),
triStateButtonAttachment (pluginState, *this, currentState)
{
currentState = (threeBandOnOffParam.get() && fourBandOnOffParam.get()) ? std::make_pair (BandState::FourBands, 4) : threeBandOnOffParam.get() ? std::make_pair (BandState::ThreeBands, 3)
: std::make_pair (BandState::TwoBands, 2);
currentState = (pluginState.params.bandSplitParams->threeBandOnOff.get() && pluginState.params.bandSplitParams->fourBandOnOff.get()) ? std::make_pair (BandState::FourBands, 4)
: pluginState.params.bandSplitParams->threeBandOnOff.get() ? std::make_pair (BandState::ThreeBands, 3)
: std::make_pair (BandState::TwoBands, 2);
}

void BandSplitterEditor::TriStateButton::paintButton (juce::Graphics& g, bool, bool)
Expand Down
6 changes: 3 additions & 3 deletions src/gui/BandSplitter/BandSplitterEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class BandSplitterEditor : public juce::Component

struct TriStateButton : public juce::Button
{
TriStateButton (chowdsp::BoolParameter& threeBandOnOff, chowdsp::BoolParameter& fourBandOnOff, State& pluginState);
TriStateButton (State& pluginState);
void paintButton (juce::Graphics& g, bool, bool) override;
chowdsp::BoolParameter& threeBandOnOffParam;
chowdsp::BoolParameter& fourBandOnOffParam;
// chowdsp::BoolParameter& threeBandOnOffParam;
// chowdsp::BoolParameter& fourBandOnOffParam;
gui::SharedFonts fonts;
TriStateButtonAttachment triStateButtonAttachment;
std::pair<BandState, int> currentState;
Expand Down
29 changes: 14 additions & 15 deletions src/gui/BandSplitter/BandSplitterPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ BandSplitterPlot::BandSplitterPlot (State& pluginState,
for (int bandIndex = 0; bandIndex < numBands; ++bandIndex)
setFilterActive (bandIndex, true);

getCutoffParam = [this](int bandIndex) -> const chowdsp::FreqHzParameter::Ptr& {
if (bandIndex < (numBands / 3))
return bandSplitterParams.cutoff;
else if (bandIndex <= numBands / 2)
return bandSplitterParams.cutoff2;
else
return bandSplitterParams.cutoff3;
};

callbacks +=
{
pluginState.addParameterListener (*bandSplitterParams.cutoff,
Expand Down Expand Up @@ -188,7 +179,7 @@ void BandSplitterPlot::updateCutoffFrequency()
{
for (int bandIndex = 0; bandIndex < numBands; ++bandIndex) //bands 0, 1, 2, 3, 4, 5
{
setCutoffParameter (bandIndex, getCutoffParam(bandIndex)->get());
setCutoffParameter (bandIndex, getCutoffParam(bandIndex, bandSplitterParams)->get());
updateFilterPlotPath (bandIndex);
}
}
Expand Down Expand Up @@ -223,7 +214,7 @@ void BandSplitterPlot::updateFilterSlope()

for (int bandIndex = 0; bandIndex < numBands; ++bandIndex)
{
setCutoffParameter (bandIndex, getCutoffParam(bandIndex)->get());
setCutoffParameter (bandIndex, getCutoffParam(bandIndex, bandSplitterParams)->get());
setQParameter (bandIndex, 0.5f);
updateFilterPlotPath (bandIndex);
}
Expand All @@ -249,16 +240,15 @@ void BandSplitterPlot::paintOverChildren (juce::Graphics& g)
g.strokePath (getPath (0), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (1), juce::PathStrokeType { 2.0f });

if (bandSplitterParams.threeBandOnOff->get())
{
if (bandSplitterParams.threeBandOnOff->get()) {
g.strokePath (getPath (2), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (3), juce::PathStrokeType { 2.0f });
}
if (bandSplitterParams.fourBandOnOff->get())
{
if (bandSplitterParams.fourBandOnOff->get()) {
g.strokePath (getPath (4), juce::PathStrokeType { 2.0f });
g.strokePath (getPath (5), juce::PathStrokeType { 2.0f });
}

}

void BandSplitterPlot::resized()
Expand Down Expand Up @@ -365,4 +355,13 @@ void BandSplitterPlot::setSpectrumColours()
}
}
}
const chowdsp::FreqHzParameter::Ptr& BandSplitterPlot::getCutoffParam (int bandIndex, const dsp::band_splitter::Params& bandParams)
{
if (bandIndex < (numBands / 3))
return bandParams.cutoff;
else if (bandIndex <= numBands / 2)
return bandParams.cutoff2;
else
return bandParams.cutoff3;
};
} // namespace gui::band_splitter
2 changes: 1 addition & 1 deletion src/gui/BandSplitter/BandSplitterPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BandSplitterPlot : public chowdsp::EQ::EqualizerPlot
void updateCutoffFrequency();
void updateFilterSlope();
void updateSpectrumPlots();
std::function<const chowdsp::FreqHzParameter::Ptr&(int)> getCutoffParam;
static const chowdsp::FreqHzParameter::Ptr& getCutoffParam(int bandIndex, const dsp::band_splitter::Params& params);

const dsp::band_splitter::Params& bandSplitterParams;
dsp::band_splitter::ExtraState& extraState;
Expand Down
29 changes: 12 additions & 17 deletions src/gui/BandSplitter/TriStateButtonAttachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

namespace gui::band_splitter
{
TriStateButtonAttachment::TriStateButtonAttachment (chowdsp::BoolParameter& threeBandParam,
chowdsp::BoolParameter& fourBandParam,
chowdsp::PluginState& pluginState,
TriStateButtonAttachment::TriStateButtonAttachment (State& pluginState,
juce::Button& triStateButton,
std::pair<BandState, int>& currentState)
: threeBandAttachment(threeBandParam, pluginState, [this](bool threeBandOn) { updateButtonState(); }),
: threeBandParam (pluginState.params.bandSplitParams->threeBandOnOff),
fourBandParam (pluginState.params.bandSplitParams->fourBandOnOff),
threeBandAttachment(threeBandParam, pluginState, [this](bool threeBandOn) { updateButtonState(); }),
fourBandAttachment(fourBandParam, pluginState, [this](bool fourBandOn) { updateButtonState(); }),
bandStateButton (&triStateButton),
um(pluginState.undoManager),
currentState (currentState),
threeBandParam (threeBandParam),
fourBandParam (fourBandParam)
um (pluginState.undoManager),
currentState (currentState)
{
updateButtonState();
bandStateButton->addListener (this);
Expand Down Expand Up @@ -46,21 +44,18 @@ void TriStateButtonAttachment::buttonClicked (juce::Button* button)

if (currentState.first == BandState::TwoBands)
{
threeBandParam.setValueNotifyingHost (true);
fourBandParam.setValueNotifyingHost (false);
threeBandAttachment.setValueAsCompleteGesture(true, um);
fourBandAttachment.setValueAsCompleteGesture(false, um);
}
else if (currentState.first == BandState::ThreeBands)
{
threeBandParam.setValueNotifyingHost (true);
fourBandParam.setValueNotifyingHost (true);
threeBandAttachment.setValueAsCompleteGesture(true, um);
fourBandAttachment.setValueAsCompleteGesture(true, um);
}
else if (currentState.first == BandState::FourBands)
{
threeBandParam.setValueNotifyingHost (false);
fourBandParam.setValueNotifyingHost (false);
threeBandAttachment.setValueAsCompleteGesture(false, um);
fourBandAttachment.setValueAsCompleteGesture(false, um);
}

threeBandAttachment.setValueAsCompleteGesture(threeBandParam.get(), um);
fourBandAttachment.setValueAsCompleteGesture(fourBandParam.get(), um);
}
} // namespace gui::band_splitter
9 changes: 4 additions & 5 deletions src/gui/BandSplitter/TriStateButtonAttachment.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#pragma once

#include "state/PluginState.h"
namespace gui::band_splitter
{
enum class BandState;
class TriStateButtonAttachment : public juce::Button::Listener
{
public:
TriStateButtonAttachment (chowdsp::BoolParameter& threeBandParam,
chowdsp::BoolParameter& fourBandParam,
chowdsp::PluginState& pluginState,
TriStateButtonAttachment (State& pluginState,
juce::Button& triStateButton,
std::pair<BandState, int>& currentState);

Expand All @@ -19,14 +18,14 @@ class TriStateButtonAttachment : public juce::Button::Listener
private:
void buttonClicked (juce::Button* button) override;

chowdsp::BoolParameter& threeBandParam;
chowdsp::BoolParameter& fourBandParam;
chowdsp::ParameterAttachment<chowdsp::BoolParameter> threeBandAttachment;
chowdsp::ParameterAttachment<chowdsp::BoolParameter> fourBandAttachment;

juce::Button* bandStateButton = nullptr;
juce::UndoManager* um = nullptr;
std::pair<BandState, int>& currentState;
chowdsp::BoolParameter& threeBandParam;
chowdsp::BoolParameter& fourBandParam;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TriStateButtonAttachment)
};
Expand Down

0 comments on commit 2509dc6

Please sign in to comment.