Skip to content

Commit

Permalink
Added filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
AugsEU committed Jun 15, 2020
1 parent a44692c commit cf3e1d7
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 78 deletions.
3 changes: 2 additions & 1 deletion Augs Synth.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
<FILE id="KJrcZj" name="stb_vorbis.c" compile="1" resource="0" file="../../Lib/cpp/Maximilian/stb_vorbis.c"/>
<FILE id="hzI9Xo" name="stb_vorbis.h" compile="0" resource="0" file="../../Lib/cpp/Maximilian/stb_vorbis.h"/>
</GROUP>
<FILE id="e7qASm" name="AugsFilter.h" compile="0" resource="0" file="Source/AugsFilter.h"/>
<FILE id="lZayIM" name="AugsFilter.cpp" compile="1" resource="0" file="Source/AugsFilter.cpp"/>
<FILE id="l81Afv" name="AugsSound.h" compile="0" resource="0" file="Source/AugsSound.h"/>
<FILE id="qHIS5a" name="AugsVoice.cpp" compile="1" resource="0" file="Source/AugsVoice.cpp"/>
<FILE id="rXWPqX" name="AugsVoice.h" compile="0" resource="0" file="Source/AugsVoice.h"/>
<FILE id="ZPkh1a" name="Main.h" compile="0" resource="0" file="Source/Main.h"/>
<FILE id="dBCWXj" name="EnvelopeGenerator.cpp" compile="1" resource="0"
file="../../../../Downloads/Synth/VST/wdl-ol/IPlugExamples/SpaceBass/EnvelopeGenerator.cpp"/>
<FILE id="OQtD4J" name="EnvelopeGenerator.h" compile="1" resource="0"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ Augs Synth is a VST plugin made with the JUCE framework. So far it has:

* Distortion settings

* Filter settings

![Picture of the synth so far](https://i.imgur.com/KFI3yDD.png)
![Picture of the synth so far](https://i.imgur.com/8oLwSsH.png)
31 changes: 31 additions & 0 deletions Source/AugsFilter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
==============================================================================
Filter.cpp
Created: 15 Jun 2020 9:51:45pm
Author: August
==============================================================================
*/

#include "AugsFilter.h"

void AugsFilter::ProcessSample(double& Sample)
{
switch (mMode)
{
case FILTER_LOW_PASS:
Sample = mFilter.lores(Sample, mFreq, mRes);
break;
case FILTER_HIGH_PASS:
Sample = mFilter.hires(Sample, mFreq, mRes);
break;
case FILTER_BAND_PASS:
Sample = mFilter.bandpass(Sample, mFreq, mRes);
break;
case FILTER_OFF:
return;
default:
return;
}
}
38 changes: 38 additions & 0 deletions Source/AugsFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
==============================================================================
Filter.h
Created: 15 Jun 2020 9:51:57pm
Author: August
==============================================================================
*/

#pragma once
#include "maximilian.h"


class AugsFilter
{
public:
enum FilterMode
{
FILTER_LOW_PASS = 0,
FILTER_HIGH_PASS,
FILTER_BAND_PASS,
FILTER_OFF,
kNumOscillatorModes
};
inline void setFreq(double newFreq) { mFreq = newFreq; }
inline void setRes(double newRes) { mRes = newRes; };
inline void setMode(FilterMode newMode) { mMode = newMode; }
void ProcessSample(double& Sample);

AugsFilter() : mMode(FILTER_OFF), mFreq(0.0), mRes(1.0) {}
~AugsFilter() {}
private:
FilterMode mMode;
double mFreq;
double mRes;
maxiFilter mFilter;
};
8 changes: 3 additions & 5 deletions Source/AugsVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ void AugsVoice::setEnvelope(double a, double d, double s, double r)
mEnv.setStageValue(EnvelopeGenerator::EnvelopeStage::ENVELOPE_STAGE_RELEASE, r);
}

void AugsVoice::setOsc(Oscillator::OscillatorMode mode)
{
mOsc.setMode(mode);
}

void AugsVoice::stopNote(float /*velocity*/, bool allowTailOff)
{

Expand All @@ -51,12 +46,15 @@ void AugsVoice::renderNextBlock(AudioBuffer<float>& outputBuffer, int startSampl
double SampleVal = mOsc.nextSample();
double EnvValue = mEnv.nextSample();
SampleVal = SampleVal * EnvValue * mVelocity;
mFilter.ProcessSample(SampleVal);

if ((mEnv.getCurrentStage() == EnvelopeGenerator::EnvelopeStage::ENVELOPE_STAGE_OFF) || (EnvValue < minimumValue))
{
clearCurrentNote();
mEnv.enterStage(EnvelopeGenerator::EnvelopeStage::ENVELOPE_STAGE_OFF);
SampleVal = 0;
}

for (int channel = 0; channel < outputBuffer.getNumChannels(); channel++)
{
outputBuffer.addSample(channel, startSample, SampleVal);
Expand Down
19 changes: 17 additions & 2 deletions Source/AugsVoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

#include <JuceHeader.h>
#include <cmath>
#include "Main.h"

#include "Oscillator.h"
#include "PolyBLEPOscillator.h"
#include "EnvelopeGenerator.h"
#include "AugsSound.h"
#include "Defs.h"
#include "AugsFilter.h"

class AugsVoice : public SynthesiserVoice
{
Expand All @@ -14,14 +20,23 @@ class AugsVoice : public SynthesiserVoice
void controllerMoved(int controllerNumber, int newControllerValue) override;
void renderNextBlock(AudioBuffer< float >& outputBuffer, int startSample, int numSamples) override;
void setEnvelope(double a, double d, double s, double r);
void setOsc(Oscillator::OscillatorMode mode);
inline void setOsc(Oscillator::OscillatorMode mode) { mOsc.setMode(mode); }
inline void setFilter(double Freq, double Res, int Mode)
{
mFilter.setFreq(Freq);
mFilter.setRes(Res);
mFilter.setMode(static_cast<AugsFilter::FilterMode>(Mode));
}
AugsVoice() :mVelocity(0.0), minimumValue(0.0000001)
{}
~AugsVoice()
{}
private:
const double minimumValue;
double mVelocity;

PolyBLEPOscillator mOsc;

AugsFilter mFilter;
EnvelopeGenerator mEnv;
};
21 changes: 12 additions & 9 deletions Source/Defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ typedef struct
const double skewFactor;
} FloatParam_Properties;

#define NUM_FLOAT_PARAMS 8
#define NUM_FLOAT_PARAMS 11
const FloatParam_Properties FloatParamProps[NUM_FLOAT_PARAMS] =
{ {"EnvAttack", "Attack", 0.0, 3.0, 0.1, 0.6},
{"EnvDecay", "Decay", 0.0, 3.0, 0.1, 0.7},
{"EnvSustain", "Sustain", 0.0, 1.0, 0.5, 0.5},
{"EnvRelease", "Release", 0.0, 7.0, 0.1, 0.7},
{"Volume", "Volume", 0.0, 0.5, 0.1, 0.2},
{"Osc_select", "Wave form",0.0, 3.0, 0.0, 1.0},
{"InnerDist", "Inner dist",0.0, 0.6, 0.0, 0.8},
{"OuterDist", "Outer dist",0.0, 0.99, 0.0, 1.1} };
{ {"EnvAttack", "Attack", 0.0, 3.0, 0.1, 0.6},//0
{"EnvDecay", "Decay", 0.0, 3.0, 0.1, 0.7},//1
{"EnvSustain", "Sustain", 0.0, 1.0, 0.5, 0.5},//2
{"EnvRelease", "Release", 0.0, 7.0, 0.1, 0.7},//3
{"Volume", "Volume", 0.0, 0.5, 0.1, 0.2},//4
{"Osc_select", "Wave form",0.0, 3.0, 0.0, 1.0},//5
{"PowDist", "Pow dist", 0.4, 5.0, 1.0, 0.7},
{"TrimDist", "Trim dist",0.0, 0.99, 0.0, 2.3},
{"FilterSel", "Filter type",0.0, 3.0, 3.0, 1.0},//8
{"CutOff", "Cut Off", 50.0, 20000.0,0.0, 0.2},
{"FiltRes", "Res", 1.0, 10.0, 1.0, 0.7}, };

22 changes: 0 additions & 22 deletions Source/Main.h

This file was deleted.

56 changes: 42 additions & 14 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void AugsSynthAudioProcessorEditor::InitGUI()
InitSlider(AttackSlider, FloatParamProps[0].minVal, FloatParamProps[0].maxVal, 0.01);
AttackSlider.setTextValueSuffix("s");
AtkSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[0].ID, AttackSlider);

InitSlider(DecaySlider, FloatParamProps[1].minVal, FloatParamProps[1].maxVal, 1.0);
DecaySlider.setTextValueSuffix("s");
DecaySliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[1].ID, DecaySlider);
Expand All @@ -51,25 +51,37 @@ void AugsSynthAudioProcessorEditor::InitGUI()
InitSlider(ReleaseSlider, FloatParamProps[3].minVal, FloatParamProps[3].maxVal, 0.01);
ReleaseSlider.setTextValueSuffix("s");
RelSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[3].ID, ReleaseSlider);

//
//Volume slider
InitSlider(VolumeSlider, FloatParamProps[4].minVal, FloatParamProps[4].maxVal, 0.01, Slider::SliderStyle::LinearVertical);
VolumeSlider.setPopupDisplayEnabled(false,false,nullptr);
VolumeSlider.setPopupDisplayEnabled(false, false, nullptr);
VolSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[4].ID, VolumeSlider);

//
//Osc selection
addAndMakeVisible(OscSelect);
OscSelect.addItemList({"Sine","Saw","Square","Triangle"},1);
OscSelect.addItemList({ "Sine","Saw","Square","Triangle" }, 1);
OscSelectAttach = std::make_unique<AudioProcessorValueTreeState::ComboBoxAttachment>(processor.mParamTree, FloatParamProps[5].ID, OscSelect);

//distortion
InitSlider(InnerDistortionSlider, FloatParamProps[6].minVal, FloatParamProps[6].maxVal);
InDistortAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[6].ID, InnerDistortionSlider);
InitSlider(PowerDistortionSlider, FloatParamProps[6].minVal, FloatParamProps[6].maxVal);
PowDistortAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[6].ID, PowerDistortionSlider);

InitSlider(TrimDistortionSlider, FloatParamProps[7].minVal, FloatParamProps[7].maxVal);
TrimDistortAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[7].ID, TrimDistortionSlider);

//Filter
addAndMakeVisible(FilterSelect);
FilterSelect.addItemList({ "Low pass", "High pass", "Band pass", "Off" }, 1);
FilterSelectAttach = std::make_unique<AudioProcessorValueTreeState::ComboBoxAttachment>(processor.mParamTree, FloatParamProps[8].ID, FilterSelect);

InitSlider(CutOffSlider, FloatParamProps[9].minVal, FloatParamProps[9].maxVal);
CutOffAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[9].ID, CutOffSlider);

InitSlider(ResonanceSlider, FloatParamProps[10].minVal, FloatParamProps[10].maxVal);
ResAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[10].ID, ResonanceSlider);

InitSlider(OuterDistortionSlider, FloatParamProps[7].minVal, FloatParamProps[7].maxVal);
OutDistortAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.mParamTree, FloatParamProps[7].ID, OuterDistortionSlider);
}

void AugsSynthAudioProcessorEditor::InitSlider(Slider& MySlider, double Min, double Max, double Increment, Slider::SliderStyle style)
Expand Down Expand Up @@ -111,8 +123,16 @@ void AugsSynthAudioProcessorEditor::paint (Graphics& g)
g.drawRect(0, 470, 195, 80);
g.setColour(Colours::wheat);
g.drawSingleLineText("Distortion", 17, GUI_SPACING * 1 + 472);
g.drawSingleLineText("In", 17, GUI_SPACING * 2 + 473);
g.drawSingleLineText("Out", 17, GUI_SPACING * 3 + 473);
g.drawSingleLineText("Pow", 17, GUI_SPACING * 2 + 473);
g.drawSingleLineText("Trim", 17, GUI_SPACING * 3 + 473);

//ADSR
g.setColour(Colours::darkgrey);
g.drawRect(340, 0, 195, 80);
g.setColour(Colours::wheat);
g.drawSingleLineText("Filter", 335 + GUI_SPACING, GUI_SPACING);
g.drawSingleLineText("Cut", GUI_SPACING + 334, GUI_SPACING * 2 + 4);
g.drawSingleLineText("Res", GUI_SPACING + 334, GUI_SPACING * 3 + 4);

}

Expand All @@ -130,12 +150,20 @@ void AugsSynthAudioProcessorEditor::resized()
SustainSlider.setBounds(2 * GUI_SPACING, GUI_SPACING*3 + 10, SliderWidth, GUI_SPACING);
ReleaseSlider.setBounds(2 * GUI_SPACING, GUI_SPACING*4 + 10, SliderWidth, GUI_SPACING);

//Volume
VolumeSlider.setBounds(190 + GUI_SPACING, 20, GUI_SPACING, 100);

OscSelect.setBounds(245, 0, 90, 20);
//Osc selector
OscSelect.setBounds(245, 0, 95, 20);

//distortion
PowerDistortionSlider.setBounds(2 * GUI_SPACING, 500, SliderWidth, GUI_SPACING);
TrimDistortionSlider.setBounds(2 * GUI_SPACING, 500 + GUI_SPACING, SliderWidth, GUI_SPACING);

InnerDistortionSlider.setBounds(2 * GUI_SPACING, 500, SliderWidth, GUI_SPACING);
OuterDistortionSlider.setBounds(2 * GUI_SPACING, 500 + GUI_SPACING, SliderWidth, GUI_SPACING);
//Filter
FilterSelect.setBounds(245, 21, 95, 20);
CutOffSlider.setBounds(380, GUI_SPACING * 1 + 10, SliderWidth, GUI_SPACING);
ResonanceSlider.setBounds(380, GUI_SPACING * 2 + 10, SliderWidth, GUI_SPACING);
}

void AugsSynthAudioProcessorEditor::handleNoteOn(MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity)
Expand Down
25 changes: 18 additions & 7 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <JuceHeader.h>
#include "PluginProcessor.h"
#include "Main.h"
#include "Defs.h"

#define GUI_SPACING 20
#define SLIDER_TXT_WIDTH (int)(GUI_SPACING*2.75)
Expand Down Expand Up @@ -60,21 +60,32 @@ class AugsSynthAudioProcessorEditor : public AudioProcessorEditor, public MidiKe
ComboBox OscSelect;

//Distortion
Slider InnerDistortionSlider;
Slider OuterDistortionSlider;
Slider PowerDistortionSlider;
Slider TrimDistortionSlider;

//Filter settings
ComboBox FilterSelect;
Slider CutOffSlider;
Slider ResonanceSlider;

public:
//ADSR
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> AtkSliderAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> DecaySliderAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> SusSliderAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> RelSliderAttach;

//Volume
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> VolSliderAttach;

//Oscillator
std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> OscSelectAttach;

std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> InDistortAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> OutDistortAttach;
//Distortion
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> PowDistortAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> TrimDistortAttach;
//Filter
std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> FilterSelectAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> CutOffAttach;
std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> ResAttach;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AugsSynthAudioProcessorEditor)
};
Loading

0 comments on commit cf3e1d7

Please sign in to comment.