Skip to content

Commit

Permalink
added filter GUI panel
Browse files Browse the repository at this point in the history
  • Loading branch information
hsetlik committed Apr 16, 2021
1 parent 1d09e49 commit 70b6375
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 8 deletions.
2 changes: 2 additions & 0 deletions HexFm.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<FILE id="mPIM9v" name="upOn.png" compile="0" resource="1" file="PNGs/upOn.png"/>
</GROUP>
<GROUP id="{DFABB24D-7FEA-FB8A-D3A7-677009A3C90E}" name="Components">
<FILE id="FGThsI" name="FilterPanel.cpp" compile="1" resource="0" file="Source/FilterPanel.cpp"/>
<FILE id="GRqHRw" name="FilterPanel.h" compile="0" resource="0" file="Source/FilterPanel.h"/>
<FILE id="h7YqHj" name="GlobalColor.h" compile="0" resource="0" file="Source/GlobalColor.h"/>
<FILE id="Ma0iaK" name="AlgorithmGraphComponent.cpp" compile="1" resource="0"
file="Source/AlgorithmGraphComponent.cpp"/>
Expand Down
71 changes: 71 additions & 0 deletions Source/FilterPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
==============================================================================
FilterPanel.cpp
Created: 15 Apr 2021 11:30:08pm
Author: Hayden Setlik
==============================================================================
*/

#include "FilterPanel.h"
FilterPanel::FilterPanel() : cutoffLabel(&cutoffSlider, ""), resonanceLabel(&resonanceSlider, "")
{
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);

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);

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

addAndMakeVisible(&filterType);
filterType.setButtonText("Low Pass");
filterType.addListener(this);

cutoffSlider.setLookAndFeel(&look);
resonanceSlider.setLookAndFeel(&look);
filterToggle.setLookAndFeel(&look);
filterType.setLookAndFeel(&look);
}

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

void FilterPanel::resized()
{
//Component is square!!
auto dX = getWidth() / 10;
filterType.setBounds(dX, dX, 3 * dX, dX);
filterToggle.setBounds(6 * dX, dX, 3 * dX, dX);
cutoffSlider.setBounds(dX, 4 * dX, 3 * dX, 4 * dX);
cutoffLabel.setBounds(juce::Rectangle<int>(dX, 8 * dX, 3 * dX, dX).reduced(5));
resonanceSlider.setBounds(6 * dX, 4 * dX, 3 * dX, 4 * dX);
resonanceLabel.setBounds(juce::Rectangle<int>(6 * dX, 8 * dX, 3 * dX, dX).reduced(5));
}

void FilterPanel::paint(juce::Graphics &g)
{

}
51 changes: 51 additions & 0 deletions Source/FilterPanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
==============================================================================
FilterPanel.h
Created: 15 Apr 2021 11:30:08pm
Author: Hayden Setlik
==============================================================================
*/

#pragma once
#include <JuceHeader.h>
#include "RGBColor.h"
#include "GlobalColor.h"
#include "CustomLnF.h"
#include "SliderSubclasses.h"

class FilterPanel : public juce::Component, juce::Button::Listener
{
public:
FilterPanel();
~FilterPanel()
{
cutoffSlider.setLookAndFeel(nullptr);
resonanceSlider.setLookAndFeel(nullptr);
filterToggle.setLookAndFeel(nullptr);
filterType.setLookAndFeel(nullptr);
}
void attach(juce::AudioProcessorValueTreeState* t)
{
cutoffAttach.reset(new juce::AudioProcessorValueTreeState::SliderAttachment(*t, "cutoffParam", cutoffSlider));
resonanceAttach.reset(new juce::AudioProcessorValueTreeState::SliderAttachment(*t, "resonanceParam", resonanceSlider));
toggleAttach.reset(new juce::AudioProcessorValueTreeState::ButtonAttachment(*t, "filterToggleParam", filterToggle));
typeAttach.reset(new juce::AudioProcessorValueTreeState::ButtonAttachment(*t, "filterTypeParam", filterType));
}
void buttonClicked(juce::Button* b) override;
void resized() override;
void paint(juce::Graphics& g) override;
juce::Slider cutoffSlider;
juce::Slider resonanceSlider;
EnvLabel cutoffLabel;
EnvLabel resonanceLabel;
juce::TextButton filterToggle;
juce::TextButton filterType;
private:
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> cutoffAttach;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> resonanceAttach;
std::unique_ptr<juce::AudioProcessorValueTreeState::ButtonAttachment> toggleAttach;
std::unique_ptr<juce::AudioProcessorValueTreeState::ButtonAttachment> typeAttach;
LnF1 look;
};
4 changes: 4 additions & 0 deletions Source/LfoGroupComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once
#include <JuceHeader.h>
#include "LfoComponent.h"
#include "FilterPanel.h"
#include "WaveGraph.h"

class LfoGroupComponent : public juce::TabbedComponent
Expand All @@ -26,6 +27,7 @@ class LfoGroupComponent : public juce::TabbedComponent
auto tabName = "LFO " + juce::String(i + 1);
addTab(tabName, tabColor, children.getLast(), false);
}
addTab("Filter", tabColor, &fPanel, false);
}
~LfoGroupComponent() {}
void attachChildren(juce::AudioProcessorValueTreeState* pTree)
Expand All @@ -34,7 +36,9 @@ class LfoGroupComponent : public juce::TabbedComponent
{
children[i]->attachAll(pTree);
}
fPanel.attach(pTree);
}
private:
juce::OwnedArray<LfoComponent> children;
FilterPanel fPanel;
};
21 changes: 14 additions & 7 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ juce::AudioProcessorValueTreeState::ParameterLayout createLayout(int numOperator
layout.add(std::make_unique<juce::AudioParameterChoice>(targetId, targetName, targets, 0));
layout.add(std::make_unique<juce::AudioParameterChoice>(waveId, waveName, waveTypes, 0));
}
auto cutoffId = "cutoffParam";
auto cutoffName = "Filter Cutoff";
auto resonanceId = "resonanceParam";
auto resonanceName = "Filter Resonance";
auto typeId = "filterTypeParam";
auto typeName = "Filter Type";
auto toggleId = "filterToggleParam";
auto toggleName = "Bypass Filter";

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

return layout;
}

Expand Down Expand Up @@ -314,13 +328,6 @@ void HexFmAudioProcessor::setStateInformation (const void* data, int sizeInBytes
if (xmlState->hasTagName (tree.state.getType()))
tree.replaceState (juce::ValueTree::fromXml (*xmlState));
}

void HexFmAudioProcessor::applyBandLimiting(juce::AudioBuffer<float> &buffer)
{
//perform forward fft
//zero bins above nyquist
//reverse fft
}
//==============================================================================

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HexFmAudioProcessor : public juce::AudioProcessor
void getStateInformation (juce::MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
//==============================================================================
void applyBandLimiting(juce::AudioBuffer<float>& buffer);

//====================================================
juce::AudioProcessorValueTreeState tree;
FmVoice* thisVoice;
Expand Down

0 comments on commit 70b6375

Please sign in to comment.