Skip to content

Commit

Permalink
cleaned up filter GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
hsetlik committed Apr 16, 2021
1 parent c353ff7 commit a355193
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
32 changes: 25 additions & 7 deletions Source/FilterPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@
*/

#include "FilterPanel.h"
FilterPanel::FilterPanel() : cutoffLabel(&cutoffSlider, ""), resonanceLabel(&resonanceSlider, "")
FilterPanel::FilterPanel() : cutoffLabel(&cutoffSlider, "", 12.0f), resonanceLabel(&resonanceSlider, "", 12.0f)
{
addAndMakeVisible(&cutoffSlider);
cutoffSlider.setSliderStyle(juce::Slider::Rotary);
cutoffSlider.setTextBoxStyle(juce::Slider::NoTextBox, false, 10, 4);
cutoffSlider.setRange(0.0f, 15000.0f);
cutoffSlider.setValue(2500.0f);
addAndMakeVisible(&cutoffLabel);
cutoffSlider.setTooltip("Filter Cutoff");

addAndMakeVisible(&resonanceSlider);
resonanceSlider.setSliderStyle(juce::Slider::Rotary);
resonanceSlider.setTextBoxStyle(juce::Slider::NoTextBox, false, 1, 1);
resonanceSlider.setRange(0.0f, 20.0f);
resonanceSlider.setValue(1.0f);
addAndMakeVisible(&resonanceLabel);
resonanceSlider.setTooltip("Filter Resonance");

addAndMakeVisible(&filterToggle);
filterToggle.setButtonText("Filter Bypass");
filterToggle.setClickingTogglesState(true);
filterToggle.setColour(juce::TextButton::buttonColourId, UXPalette::lightRed);
filterToggle.setColour(juce::TextButton::buttonOnColourId, UXPalette::lightRed);
filterToggle.addListener(this);

addAndMakeVisible(&filterType);
filterType.setButtonText("Low Pass");
Expand All @@ -43,14 +46,29 @@ FilterPanel::FilterPanel() : cutoffLabel(&cutoffSlider, ""), resonanceLabel(&res

void FilterPanel::buttonClicked(juce::Button *b)
{
auto str = filterType.getButtonText();
if(str == "Low Pass")
if(b == &filterType)
{
filterType.setButtonText("High Pass");
auto str = filterType.getButtonText();
if(str == "Low Pass")
{
filterType.setButtonText("High Pass");
}
else
{
filterType.setButtonText("Low Pass");
}
}
else
if(b == &filterToggle)
{
filterType.setButtonText("Low Pass");
auto str = filterToggle.getButtonText();
if(str == "Filter Bypass")
{
filterToggle.setButtonText("Filter On");
}
else
{
filterToggle.setButtonText("Filter Bypass");
}
}
}

Expand Down
6 changes: 0 additions & 6 deletions Source/FmVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ void FmVoice::applyLfo(int index)
{
LfoProcessor* thisLfo = lfoBank[index];
lfoValue = thisLfo->getSampleValue();
/*
if(lfoValue < lfoMin)
lfoMin = lfoValue;
if(lfoValue > lfoMax)
lfoMax = lfoValue;
*/
if(thisLfo->target > 0)
{
if(thisLfo->target % 2 != 0)
Expand Down
10 changes: 8 additions & 2 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ juce::AudioProcessorValueTreeState::ParameterLayout createLayout(int numOperator
auto toggleId = "filterToggleParam";
auto toggleName = "Bypass Filter";

layout.add(std::make_unique<juce::AudioParameterFloat>(cutoffId, cutoffName, 0.01f, 15000.0f , 2500.0f));
layout.add(std::make_unique<juce::AudioParameterFloat>(resonanceId, resonanceName, 0.001f, 20.0f , 1.0f));
juce::NormalisableRange<float> cutoffRange(1.0f, 15000.0f, 0.5f, 0.5f);
cutoffRange.setSkewForCentre(700.0f);

juce::NormalisableRange<float> resonanceRange(0.0f, 20.0f, 0.01f, 0.01f);
resonanceRange.setSkewForCentre(2.0f);

layout.add(std::make_unique<juce::AudioParameterFloat>(cutoffId, cutoffName, cutoffRange, 2500.0f));
layout.add(std::make_unique<juce::AudioParameterFloat>(resonanceId, resonanceName, resonanceRange, 1.0f));
layout.add(std::make_unique<juce::AudioParameterBool>(typeId, typeName, false));
layout.add(std::make_unique<juce::AudioParameterBool>(toggleId, toggleName, false));

Expand Down
4 changes: 2 additions & 2 deletions Source/SliderSubclasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class EnvLabel : public juce::Label, public juce::Slider::Listener
{
public:
EnvLabel(juce::Slider* sliderToAttach, juce::String suff) : attachSlider(sliderToAttach), suffix(suff)
EnvLabel(juce::Slider* sliderToAttach, juce::String suff, float fontSize = 8.0f) : attachSlider(sliderToAttach), suffix(suff)
{
auto robotoLightItalic = juce::Font("Roboto Light", 8.0f, 0).withStyle(juce::Font::FontStyleFlags::italic);
auto robotoLightItalic = juce::Font("Roboto Light", fontSize, 0).withStyle(juce::Font::FontStyleFlags::italic);
setEditable(true);
setFont(robotoLightItalic);
attachSlider->addListener(this);
Expand Down

0 comments on commit a355193

Please sign in to comment.