Skip to content

Commit

Permalink
Added Limiter module and GUI Groups
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmemelord committed Feb 6, 2023
1 parent de2ab90 commit faec816
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 14 deletions.
3 changes: 3 additions & 0 deletions QuasoCompressor.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<FILE id="mhnrMB" name="Parameters.h" compile="0" resource="0" file="Source/Parameters/Parameters.h"/>
</GROUP>
<GROUP id="{2FCDF22E-12E8-C833-F580-A2D5C8080127}" name="GUI">
<GROUP id="{2933A0D2-F796-2453-8CE3-E15B4C2809B5}" name="Groups">
<FILE id="aTV8bt" name="Groups.cpp" compile="1" resource="0" file="Source/GUI/Groups/Groups.cpp"/>
</GROUP>
<GROUP id="{2F35E864-726F-E587-054A-5BD819F58A90}" name="LookAndFeel">
<FILE id="z0bHft" name="DialLAF.cpp" compile="1" resource="0" file="Source/GUI/LookAndFeel/DialLAF.cpp"/>
<FILE id="s7ERMe" name="DialLAF.h" compile="0" resource="0" file="Source/GUI/LookAndFeel/DialLAF.h"/>
Expand Down
20 changes: 20 additions & 0 deletions Source/GUI/Groups/Groups.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
==============================================================================
Groups.cpp
Created: 6 Feb 2023 7:43:46pm
Author: Utente
==============================================================================
*/

#include "../../PluginEditor.h"

void QuasoCompressorAudioProcessorEditor::setGroupProps(juce::GroupComponent& group)
{
addAndMakeVisible(group);
group.setColour(group.outlineColourId, juce::Colours::darkgrey);
ioGroup.setText("I/O");
compressorGroup.setText("Compressor");
limiterGroup.setText("Limiter");
}
2 changes: 2 additions & 0 deletions Source/GUI/Sliders/SliderProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void QuasoCompressorAudioProcessorEditor::attachSliders()
ratioAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, ratioID, ratioDial);
attackAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, attackID, attackDial);
releaseAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, releaseID, releaseDial);
limThreshAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, limThreshID, limThreshDial);
limReleaseAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, limReleaseID, limReleaseDial);
outputAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, outputID, outputDial);

}
Expand Down
6 changes: 6 additions & 0 deletions Source/Parameters/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ const juce::String attackName = "Attack";
const juce::String releaseID = "release";
const juce::String releaseName = "Release";

const juce::String limThreshID = "limThresh";
const juce::String limThreshName = "Limiter Thresh";

const juce::String limReleaseID = "limRelease";
const juce::String limReleaseName = "Limiter Release";

const juce::String outputID = "output";
const juce::String outputName = "Output";
6 changes: 6 additions & 0 deletions Source/Parameters/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ extern const juce::String attackName;
extern const juce::String releaseID;
extern const juce::String releaseName;

extern const juce::String limThreshID;
extern const juce::String limThreshName;

extern const juce::String limReleaseID;
extern const juce::String limReleaseName;

extern const juce::String outputID;
extern const juce::String outputName;
47 changes: 37 additions & 10 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ QuasoCompressorAudioProcessorEditor::QuasoCompressorAudioProcessorEditor (QuasoC
ratioDialLabel.setText("Ratio", juce::dontSendNotification);
attackDialLabel.setText("Attack", juce::dontSendNotification);
releaseDialLabel.setText("Release", juce::dontSendNotification);
limThreshDialLabel.setText("Threshold", juce::dontSendNotification);
limReleaseDialLabel.setText("Release", juce::dontSendNotification);
outputDialLabel.setText("Output", juce::dontSendNotification);

//setting the slider properties is called for every slider in the vector
Expand All @@ -30,13 +32,24 @@ QuasoCompressorAudioProcessorEditor::QuasoCompressorAudioProcessorEditor (QuasoC
dialLabels[i]->attachToComponent(dials[i], false);
}

for (int i = 0; i < groups.size(); i++)
{
setGroupProps(*groups[i]);
}

//some properties are different between dials like the textbox suffix
inputDial.setColour(juce::Slider::ColourIds::thumbColourId, juce::Colours::indianred.darker(0.3));
//inputDial.setColour(juce::Slider::ColourIds::thumbColourId, juce::Colours::indianred.darker(0.3));
inputDial.setTextValueSuffix(" dB");
threshDial.setTextValueSuffix(" dB");
attackDial.setTextValueSuffix(" ms");
releaseDial.setTextValueSuffix(" ms");
outputDial.setColour(juce::Slider::ColourIds::thumbColourId, juce::Colours::indianred.darker(0.3));
//limThreshDial.setColour(juce::Slider::ColourIds::thumbColourId,
//limThreshDial.findColour(juce::Slider::ColourIds::thumbColourId).withSaturation(0.85));
limThreshDial.setTextValueSuffix(" dB");
//limReleaseDial.setColour(juce::Slider::ColourIds::thumbColourId,
//limReleaseDial.findColour(juce::Slider::ColourIds::thumbColourId).withSaturation(0.85));
limReleaseDial.setTextValueSuffix(" ms");
//outputDial.setColour(juce::Slider::ColourIds::thumbColourId, juce::Colours::indianred.darker(0.3));
outputDial.setTextValueSuffix(" dB");


Expand All @@ -46,7 +59,7 @@ QuasoCompressorAudioProcessorEditor::QuasoCompressorAudioProcessorEditor (QuasoC

//the windows can be resized by mantaining the dafault 2:1 aspect ratio and only by 25% bigger or smaller
juce::AudioProcessorEditor::setResizable(true,true);
juce::AudioProcessorEditor::setResizeLimits(getWidth() * 0.75, getHeight() * 0.75, getWidth() * 1.25, getHeight() * 1.25);
juce::AudioProcessorEditor::setResizeLimits(getWidth(), getHeight(), getWidth() * 1.25, getHeight() * 1.25);
juce::AudioProcessorEditor::getConstrainer()->setFixedAspectRatio(2.0);
}

Expand All @@ -73,10 +86,11 @@ void QuasoCompressorAudioProcessorEditor::paint (juce::Graphics& g)

void QuasoCompressorAudioProcessorEditor::resized()
{
auto dialSize = getWidth() * 0.15;
auto mainLeftMargin = getWidth() * 0.25;
auto leftMargin = getWidth() * 0.02;
auto secondRowHeight = 1.5;
auto dialSize = getWidth() * 0.18;
auto mainLeftMargin = getWidth() * 0.3;
auto leftMargin = getWidth() * 0.03;
auto secondRowHeight = 1.3;
auto limiterMargin = 1.45;

////first row of GUI with input, thresh and ratio
//juce::FlexBox flexboxRowOne;
Expand Down Expand Up @@ -105,13 +119,26 @@ void QuasoCompressorAudioProcessorEditor::resized()
//
//flexboxRowTwo.items = itemArrayRowTwo;
//flexboxRowTwo.performLayout(getLocalBounds().withY(getHeight() * 0.5).withHeight(getHeight()*0.5));
inputDial.setBounds(leftMargin, 75, dialSize, dialSize);
threshDial.setBounds(mainLeftMargin, 75, dialSize, dialSize);
ratioDial.setBounds(threshDial.getX() + threshDial.getWidth(), 75, dialSize, dialSize);
inputDial.setBounds(leftMargin, 50, dialSize, dialSize);
threshDial.setBounds(mainLeftMargin, 50, dialSize, dialSize);
ratioDial.setBounds(threshDial.getX() + threshDial.getWidth(), 50, dialSize, dialSize);

ioGroup.setBounds(inputDial.getX(), inputDial.getY() * 0.1, inputDial.getWidth(),
inputDial.getY() + inputDial.getHeight() * 2.4);

outputDial.setBounds(leftMargin, inputDial.getY() + inputDial.getHeight() *secondRowHeight, dialSize, dialSize);
attackDial.setBounds(threshDial.getX(), outputDial.getY(), dialSize, dialSize);
releaseDial.setBounds(ratioDial.getX(), outputDial.getY(), dialSize, dialSize);

compressorGroup.setBounds(threshDial.getX(), threshDial.getY() * 0.1, threshDial.getWidth() * 2.0,
threshDial.getY() + threshDial.getHeight() * 2.4);

limThreshDial.setBounds(ratioDial.getX() + ratioDial.getWidth() * limiterMargin, inputDial.getY(), dialSize, dialSize);
limReleaseDial.setBounds(limThreshDial.getX(), inputDial.getY() +limThreshDial.getHeight()*secondRowHeight, dialSize, dialSize);

limiterGroup.setBounds(limThreshDial.getX(), limThreshDial.getY() * 0.1,
limThreshDial.getWidth(), limThreshDial.getY() + limThreshDial.getHeight() * 2.4);



}
28 changes: 27 additions & 1 deletion Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class QuasoCompressorAudioProcessorEditor : public juce::AudioProcessorEditor
juce::Slider ratioDial;
juce::Slider attackDial;
juce::Slider releaseDial;
juce::Slider limThreshDial;
juce::Slider limReleaseDial;
juce::Slider outputDial;

//using custom look and feel
Expand All @@ -53,29 +55,51 @@ class QuasoCompressorAudioProcessorEditor : public juce::AudioProcessorEditor
&ratioDial,
&attackDial,
&releaseDial,
&limThreshDial,
&limReleaseDial,
&outputDial
};

//labels
juce::Label inputDialLabel;
juce::Label threshDialLabel;
juce::Label ratioDialLabel;
juce::Label attackDialLabel;
juce::Label releaseDialLabel;
juce::Label limThreshDialLabel;
juce::Label limReleaseDialLabel;
juce::Label outputDialLabel;

//labels vector
std::vector<juce::Label*> dialLabels =
{
&inputDialLabel,
&threshDialLabel,
&ratioDialLabel,
&attackDialLabel,
&releaseDialLabel,
&limThreshDialLabel,
&limReleaseDialLabel,
&outputDialLabel
};

//method to set some properties common to every silder and label
//groups
juce::GroupComponent ioGroup;
juce::GroupComponent compressorGroup;
juce::GroupComponent limiterGroup;

//groups vector
std::vector<juce::GroupComponent*> groups =
{
&ioGroup,
&compressorGroup,
&limiterGroup
};

//method to set some properties common to every silder, label and group
void setCommonSliderProps(juce::Slider& slider);
void setCommonLabelProps(juce::Label& label);
void setGroupProps(juce::GroupComponent& group);

//setting up attachment
using Attachment = std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>;
Expand All @@ -85,6 +109,8 @@ class QuasoCompressorAudioProcessorEditor : public juce::AudioProcessorEditor
Attachment ratioAttach;
Attachment attackAttach;
Attachment releaseAttach;
Attachment limThreshAttach;
Attachment limReleaseAttach;
Attachment outputAttach;

//method to attach sliders to the apvts
Expand Down
22 changes: 19 additions & 3 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ QuasoCompressorAudioProcessor::QuasoCompressorAudioProcessor()
apvts.addParameterListener(ratioID, this);
apvts.addParameterListener(attackID, this);
apvts.addParameterListener(releaseID, this);
apvts.addParameterListener(limThreshID, this);
apvts.addParameterListener(limReleaseID, this);
apvts.addParameterListener(outputID, this);
}

Expand All @@ -43,6 +45,8 @@ QuasoCompressorAudioProcessor::~QuasoCompressorAudioProcessor()
apvts.removeParameterListener(ratioID, this);
apvts.removeParameterListener(attackID, this);
apvts.removeParameterListener(releaseID, this);
apvts.removeParameterListener(limThreshID, this);
apvts.removeParameterListener(limReleaseID, this);
apvts.removeParameterListener(outputID, this);

}
Expand All @@ -60,20 +64,27 @@ juce::AudioProcessorValueTreeState::ParameterLayout QuasoCompressorAudioProcesso
juce::NormalisableRange<float> releaseRange = juce::NormalisableRange<float>( 5.0f, 5000.0f, 1.0f);
releaseRange.setSkewForCentre(160.0f);

juce::NormalisableRange<float> limReleaseRange = juce::NormalisableRange<float>(1.0f, 1000.0f, 1.0f);
releaseRange.setSkewForCentre(250.0f);

//parameters are created
auto pInput = std::make_unique<juce::AudioParameterFloat>(inputID, inputName, -60.0f, 24.0f, 0.0f);
auto pThresh = std::make_unique<juce::AudioParameterFloat>(threshID, threshName, -60.0f, 10.0f, 0.0f);
auto pThresh = std::make_unique<juce::AudioParameterFloat>(threshID, threshName, -60.0f, 12.0f, 0.0f);
auto pRatio = std::make_unique<juce::AudioParameterFloat>(ratioID, ratioName, 1.0f, 20.0f, 1.0f);
auto pAttack = std::make_unique<juce::AudioParameterFloat>(attackID, attackName, attackRange, 50.0f);
auto pRelease = std::make_unique<juce::AudioParameterFloat>(releaseID, releaseName, releaseRange, 160.0f);
auto pLimThresh = std::make_unique<juce::AudioParameterFloat>(limThreshID, limThreshName, -60.0f, 0.0f, 160.0f);
auto pLimRelease = std::make_unique<juce::AudioParameterFloat>(limReleaseID, limReleaseName, limReleaseRange, 250.0f);
auto pOutput = std::make_unique<juce::AudioParameterFloat>(outputID, outputName, -60.0f, 24.0f, 0.0f);

//different type of parameters like floats or selection are pushed into the params vector
params.push_back(std::move(pInput));
params.push_back(std::move(pThresh));
params.push_back(std::move(pRatio));
params.push_back(std::move(pAttack));
params.push_back(std::move(pRelease));
params.push_back(std::move(pLimThresh));
params.push_back(std::move(pLimRelease));
params.push_back(std::move(pOutput));


Expand All @@ -95,6 +106,8 @@ void QuasoCompressorAudioProcessor::updateParameters()
compressorModule.setRatio(apvts.getRawParameterValue(ratioID)->load());
compressorModule.setAttack(apvts.getRawParameterValue(attackID)->load());
compressorModule.setRelease(apvts.getRawParameterValue(releaseID)->load());
limiterModule.setThreshold(apvts.getRawParameterValue(limThreshID)->load());
limiterModule.setRelease(apvts.getRawParameterValue(limReleaseID)->load());
outputModule.setGainDecibels(apvts.getRawParameterValue(outputID)->load());

}
Expand Down Expand Up @@ -180,6 +193,8 @@ void QuasoCompressorAudioProcessor::prepareToPlay (double sampleRate, int sample
outputModule.prepare(spec);

compressorModule.prepare(spec);

limiterModule.prepare(spec);

updateParameters();
}
Expand Down Expand Up @@ -222,11 +237,12 @@ void QuasoCompressorAudioProcessor::processBlock (juce::AudioBuffer<float>& buff
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

juce::dsp::AudioBlock<float> block{ buffer };
auto block = juce::dsp::AudioBlock<float>(buffer);

//process DSP modules
inputModule.process(juce::dsp::ProcessContextReplacing<float>(block));
compressorModule.process(juce::dsp::ProcessContextReplacing<float>(block));
limiterModule.process(juce::dsp::ProcessContextReplacing<float>(block));
outputModule.process(juce::dsp::ProcessContextReplacing<float>(block));


Expand Down
3 changes: 3 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class QuasoCompressorAudioProcessor : public juce::AudioProcessor, juce::AudioP
//the dsp module also implements a compressor module
juce::dsp::Compressor<float> compressorModule;

//limiter module
juce::dsp::Limiter<float> limiterModule;

//method to set the various parameters
void updateParameters();

Expand Down

0 comments on commit faec816

Please sign in to comment.