Skip to content

Commit

Permalink
removes the filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bboettcher3 committed Jan 15, 2024
1 parent 8be5f77 commit ba5ac69
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 93 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ set(SOURCE_COMPONENTS
Source/Components/RainbowLookAndFeel.h
Source/Components/RainbowLookAndFeel.cpp
Source/Components/MeterLookAndFeel.h
Source/Components/FilterControl.h
Source/Components/FilterControl.cpp
Source/Components/Modulators/LFOs.h
Source/Components/Modulators/LFOs.cpp
Source/Components/Modulators/Envelopes.h
Expand Down
18 changes: 1 addition & 17 deletions Source/DSP/GranularSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ void GranularSynth::prepareToPlay(double sampleRate, int samplesPerBlock) {
mSampleRate = sampleRate;

const juce::dsp::ProcessSpec filtConfig = {sampleRate, (juce::uint32)samplesPerBlock, (unsigned int)getTotalNumOutputChannels()};
mParameters.global.filter.prepare(filtConfig);
mMeterSource.resize(getTotalNumOutputChannels(), sampleRate * 0.1 / samplesPerBlock);
mReferenceTone.prepareToPlay(samplesPerBlock, sampleRate);
mParameters.prepareModSources(samplesPerBlock, sampleRate);
Expand Down Expand Up @@ -174,15 +173,8 @@ void GranularSynth::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuf
auto totalNumOutputChannels = getTotalNumOutputChannels();
const int bufferNumSample = buffer.getNumSamples();

// Update mod source values once per block
mParameters.processModSources();

// Apply modulations to filter parameters
float filtCutoff0To1 = mParameters.global.filterCutoff->convertTo0to1(mParameters.global.filterCutoff->get());
float filtRes0To1 = mParameters.global.filterRes->convertTo0to1(mParameters.global.filterRes->get());
mParameters.applyModulations(mParameters.global.filterCutoff, filtCutoff0To1);
mParameters.applyModulations(mParameters.global.filterRes, filtRes0To1);
mParameters.global.filter.setCutoffFrequency(mParameters.global.filterCutoff->convertFrom0to1(filtCutoff0To1));
mParameters.global.filter.setResonance(mParameters.global.filterRes->convertFrom0to1(filtRes0To1));

mKeyboardState.processNextMidiBuffer(midiMessages, 0, bufferNumSample, true);
for (const auto& messageMeta : midiMessages) {
Expand Down Expand Up @@ -255,14 +247,6 @@ void GranularSynth::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuf
}
}
}
// Process filter and optionally use for output
const int filtType = mParameters.global.filterType->getIndex();
for (int ch = 0; ch < buffer.getNumChannels(); ++ch) {
const float filterOutput = mParameters.global.filter.processSample(ch, bufferChannels[ch][i]);
if (filtType != Utils::FilterType::NO_FILTER) {
bufferChannels[ch][i] = filterOutput;
}
}
mTotalSamps++;
}

Expand Down
12 changes: 0 additions & 12 deletions Source/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@

void ParamGlobal::addParams(juce::AudioProcessor& p) {
// Global
// Filter
p.addParameter(filterCutoff =
new juce::AudioParameterFloat({ParamIDs::filterCutoff, 1}, "Filter Cutoff", ParamRanges::FILT_CUTOFF,
ParamDefaults::FILTER_LP_CUTOFF_DEFAULT_HZ));
filterCutoff->addListener(this);
p.addParameter(filterRes =
new juce::AudioParameterFloat({ParamIDs::filterResonance, 1}, "Filter Resonance",
ParamRanges::FILT_RESONANCE, ParamDefaults::FILTER_RESONANCE_DEFAULT));
filterRes->addListener(this);
p.addParameter(filterType =
new juce::AudioParameterChoice({ParamIDs::filterType, 1}, "Filter Type", FILTER_TYPE_NAMES, ParamDefaults::FILTER_TYPE_DEFAULT));
filterType->addListener(this);
// LFOs
p.addParameter(lfo1.shape =
new juce::AudioParameterChoice({ParamIDs::lfo1Shape, 1}, "LFO 1 Shape", LFO_SHAPE_NAMES, ParamDefaults::LFO_SHAPE_DEFAULT));
Expand Down
56 changes: 2 additions & 54 deletions Source/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

namespace ParamIDs {
// Global params
static juce::String filterCutoff{"filt_cutoff"};
static juce::String filterResonance{"filt_resonance"};
static juce::String filterType{"filt_type"};
static juce::String lfo1Shape{"lfo1_shape"};
static juce::String lfo1Rate{"lfo1_rate"};
static juce::String lfo1Phase{"lfo1_phase"};
Expand Down Expand Up @@ -143,11 +140,6 @@ static float ATTACK_DEFAULT_SEC = 0.2f;
static float DECAY_DEFAULT_SEC = 0.2f;
static float SUSTAIN_DEFAULT = 0.8f;
static float RELEASE_DEFAULT_SEC = 0.2f;
static float FILTER_LP_CUTOFF_DEFAULT_HZ = 1000.0f;
static float FILTER_HP_CUTOFF_DEFAULT_HZ = 100.0f;
static float FILTER_BP_CUTOFF_DEFAULT_HZ = 600.0f;
static float FILTER_RESONANCE_DEFAULT = 0.707f;
static int FILTER_TYPE_DEFAULT = 0;
static float GRAIN_SHAPE_DEFAULT = 0.5f;
static float GRAIN_TILT_DEFAULT = 0.5f;
static float GRAIN_RATE_DEFAULT = 10.0f;
Expand All @@ -165,7 +157,6 @@ static int REVERSE_DEFAULT = 0;
enum ParamType { GLOBAL, NOTE, GENERATOR };
static juce::Array<juce::String> PARAM_TYPE_NAMES{"global", "note", "generator"};
static juce::Array<juce::String> PITCH_CLASS_NAMES{"C", "Cs", "D", "Ds", "E", "F", "Fs", "G", "Gs", "A", "As", "B"};
static juce::Array<juce::String> FILTER_TYPE_NAMES{"none", "lowpass", "highpass", "bandpass"};
static juce::Array<juce::String> LFO_SHAPE_NAMES{"sine", "tri", "square", "saw"};

static constexpr int MAX_CANDIDATES = 6;
Expand Down Expand Up @@ -529,28 +520,19 @@ struct ParamsNote {
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParamsNote)
};

struct ParamGlobal : ParamCommon, public juce::AudioProcessorParameter::Listener {
struct ParamGlobal : ParamCommon {
ParamGlobal() : ParamCommon(ParamType::GLOBAL) {
filter.setType(juce::dsp::StateVariableTPTFilterType::lowpass);
filter.setCutoffFrequency(ParamDefaults::FILTER_LP_CUTOFF_DEFAULT_HZ);
// Default to using global parameters
for (auto& used : isUsed) {
used = true;
}
}
~ParamGlobal() {
filterType->removeListener(this);
filterCutoff->removeListener(this);
filterRes->removeListener(this);
}
~ParamGlobal() {}

void addParams(juce::AudioProcessor& p);

void resetParams() {
ParamCommon::resetParams();
ParamHelper::setParam(filterCutoff, ParamDefaults::FILTER_LP_CUTOFF_DEFAULT_HZ);
ParamHelper::setParam(filterRes, ParamDefaults::FILTER_RESONANCE_DEFAULT);
ParamHelper::setParam(filterType, ParamDefaults::FILTER_TYPE_DEFAULT);
ParamHelper::setParam(lfo1.shape, ParamDefaults::LFO_SHAPE_DEFAULT);
ParamHelper::setParam(lfo1.rate, ParamDefaults::LFO_RATE_DEFAULT);
ParamHelper::setParam(lfo1.phase, ParamDefaults::LFO_PHASE_DEFAULT);
Expand All @@ -562,45 +544,11 @@ struct ParamGlobal : ParamCommon, public juce::AudioProcessorParameter::Listener
ParamHelper::setParam(macro3.macro, ParamDefaults::MACRO_DEFAULT);
ParamHelper::setParam(macro4.macro, ParamDefaults::MACRO_DEFAULT);
}

void parameterValueChanged(int paramIdx, float) override {
if (paramIdx == filterType->getParameterIndex()) {
switch (filterType->getIndex()) {
case Utils::FilterType::LOWPASS: {
filter.setType(juce::dsp::StateVariableTPTFilterType::lowpass);
break;
}
case Utils::FilterType::HIGHPASS: {
filter.setType(juce::dsp::StateVariableTPTFilterType::highpass);
break;
}
case Utils::FilterType::BANDPASS: {
filter.setType(juce::dsp::StateVariableTPTFilterType::bandpass);
break;
}
default:
break;
}
} else if (paramIdx == filterCutoff->getParameterIndex()) {
filter.setCutoffFrequency(filterCutoff->get());
} else if (paramIdx == filterRes->getParameterIndex()) {
filter.setResonance(filterRes->get());
}
}
void parameterGestureChanged(int, bool) override {}

// Global parameters
juce::AudioParameterChoice* filterType;
juce::AudioParameterFloat* filterCutoff;
juce::AudioParameterFloat* filterRes;

// Global modulation sources
LFOModSource lfo1;
EnvModSource env1;
MacroModSource macro1, macro2, macro3, macro4;

// State variable filter for generator
juce::dsp::StateVariableTPTFilter<float> filter;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParamGlobal)
};
Expand Down
6 changes: 1 addition & 5 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ GRainbowAudioProcessorEditor::GRainbowAudioProcessorEditor(GranularSynth& synth)
mEnvAdsr(synth.getParams()),
mEnvGrain(synth.getParams()),
mAdjustPanel(synth.getParams()),
mFilterPanel(synth.getParams()),
mFx2(synth.getParams()),
mFx3(synth.getParams()),
mModEnvelopes(synth.getParams()),
mModLFOs(synth.getParams()),
mMasterPanel(synth.getParams(), synth.getMeterSource()),
mFilterControl(synth.getParams()),
mPianoPanel(synth.getKeyboardState(), synth.getParams()) {
mPianoPanel(synth.getKeyboardState(), synth.getParams()) {
setLookAndFeel(&mRainbowLookAndFeel);
mRainbowLookAndFeel.setColour(juce::ComboBox::ColourIds::backgroundColourId, Utils::GLOBAL_COLOUR);
mRainbowLookAndFeel.setColour(juce::PopupMenu::ColourIds::backgroundColourId, Utils::GLOBAL_COLOUR);
Expand Down Expand Up @@ -92,7 +90,6 @@ mPianoPanel(synth.getKeyboardState(), synth.getParams()) {

// FX tabs
mTabsFx.setTabBarDepth(Utils::TAB_HEIGHT);
mTabsFx.addTab("filter", Utils::BG_COLOUR, &mFilterPanel, false);
mTabsFx.addTab("FX 2", Utils::BG_COLOUR, &mFx2, false);
mTabsFx.addTab("FX 3", Utils::BG_COLOUR, &mFx3, false);
mTabsFx.setOutline(0);
Expand Down Expand Up @@ -164,7 +161,6 @@ mPianoPanel(synth.getKeyboardState(), synth.getParams()) {
addChildComponent(mProgressBar);
addChildComponent(mTrimSelection);

addAndMakeVisible(mFilterControl);
mMasterPanel.onRefToneOn = [this](){
mSynth.startReferenceTone(mParameters.getSelectedPitchClass());
};
Expand Down
3 changes: 0 additions & 3 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "Components/Modulators/Envelopes.h"
#include "Components/Modulators/LFOs.h"
#include "Components/MasterPanel.h"
#include "Components/FilterControl.h"
#include "Components/TrimSelection.h"
#include "Components/ArcSpectrogram.h"
#include "Components/Piano/PianoPanel.h"
Expand Down Expand Up @@ -81,12 +80,10 @@ class GRainbowAudioProcessorEditor : public juce::AudioProcessorEditor,
EnvelopeADSR mEnvAdsr;
EnvelopeGrain mEnvGrain;
AdjustPanel mAdjustPanel;
FilterControl mFilterPanel;
FxPanel mFx2, mFx3;
Envelopes mModEnvelopes;
LFOs mModLFOs;
MasterPanel mMasterPanel;
FilterControl mFilterControl;
PianoPanel mPianoPanel;
juce::SharedResourcePointer<juce::TooltipWindow> mTooltipWindow;
SettingsComponent mSettings;
Expand Down

0 comments on commit ba5ac69

Please sign in to comment.