Skip to content

Commit

Permalink
slider attachment and gui working
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmemelord committed Feb 2, 2023
1 parent 7d4b285 commit ce7f583
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 32 deletions.
4 changes: 4 additions & 0 deletions QuasoCompressor.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
companyName="sadmemelord">
<MAINGROUP id="AsMcn2" name="QuasoCompressor">
<GROUP id="{D7589DD5-C5DE-D5EC-0ABB-CC849D0320A2}" name="Source">
<GROUP id="{934AFFCF-E6D9-A510-94D9-DF6065430908}" name="Parameters">
<FILE id="ej4ums" name="Parameters.cpp" compile="1" resource="0" file="Source/Parameters/Parameters.cpp"/>
<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="{2F35E864-726F-E587-054A-5BD819F58A90}" name="LookAndFeel">
<FILE id="z0bHft" name="DialLAF.cpp" compile="1" resource="0" file="Source/GUI/LookAndFeel/DialLAF.cpp"/>
Expand Down
27 changes: 24 additions & 3 deletions Source/GUI/Sliders/SliderProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,41 @@ void QuasoCompressorAudioProcessorEditor::setCommonSliderProps(juce::Slider& sli
addAndMakeVisible(slider);
slider.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
slider.setTextBoxStyle(juce::Slider::TextBoxBelow, false, 72, 36);

//setting colours based on the custom look and feel
slider.setColour(juce::Slider::ColourIds::textBoxOutlineColourId, juce::Colours::transparentBlack);
slider.setColour(juce::Slider::ColourIds::trackColourId, juce::Colours::whitesmoke.darker(0.75));
slider.setColour(juce::Slider::ColourIds::rotarySliderOutlineColourId,
slider.setColour(juce::Slider::ColourIds::trackColourId,
slider.findColour(juce::Slider::ColourIds::rotarySliderOutlineColourId).brighter(0.2));
slider.setColour(juce::Slider::ColourIds::rotarySliderFillColourId, juce::Colours::whitesmoke.darker(1));
slider.setColour(juce::Slider::ColourIds::rotarySliderOutlineColourId,
slider.findColour(juce::Slider::ColourIds::rotarySliderOutlineColourId).brighter(0.15));
slider.setColour(juce::Slider::ColourIds::thumbColourId, juce::Colours::cornflowerblue.darker(0.3));

slider.setLookAndFeel(&customDialLAF);

//setting shadow properties based on the juce::shadowdrop
shadowProperties.radius = 25;
shadowProperties.offset = juce::Point<int>(0,0);
shadowProperties.colour = juce::Colours::black.brighter(0.1);
shadowProperties.colour = juce::Colours::black.brighter(0.05);
dialShadow.setShadowProperties(shadowProperties);
slider.setComponentEffect(&dialShadow);

}

void QuasoCompressorAudioProcessorEditor::attachSliders()
{
//method to attach dials to apvts
using SliderAttachment = juce::AudioProcessorValueTreeState::SliderAttachment;

inputAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, inputID, inputDial);
threshAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, threshID, threshDial);
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);
outputAttach = std::make_unique<SliderAttachment>(audioProcessor.apvts, outputID, outputDial);

}

void QuasoCompressorAudioProcessorEditor::setCommonLabelProps(juce::Label& label)
{
//setting properties common to every slider
Expand Down
29 changes: 29 additions & 0 deletions Source/Parameters/Parameters.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
==============================================================================
Parameters.cpp
Created: 2 Feb 2023 4:48:43pm
Author: Utente
==============================================================================
*/

#include "Parameters.h"

const juce::String inputID = "input";
const juce::String inputName = "Input";

const juce::String threshID = "thresh";
const juce::String threshName = "Thresh";

const juce::String ratioID = "ratio";
const juce::String ratioName = "Ratio";

const juce::String attackID = "attack";
const juce::String attackName = "Attack";

const juce::String releaseID = "release";
const juce::String releaseName = "Release";

const juce::String outputID = "output";
const juce::String outputName = "Output";
30 changes: 30 additions & 0 deletions Source/Parameters/Parameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
==============================================================================
Parameters.h
Created: 2 Feb 2023 4:48:43pm
Author: Utente
==============================================================================
*/

#pragma once
#include <JuceHeader.h>

extern const juce::String inputID;
extern const juce::String inputName;

extern const juce::String threshID;
extern const juce::String threshName;

extern const juce::String ratioID;
extern const juce::String ratioName;

extern const juce::String attackID;
extern const juce::String attackName;

extern const juce::String releaseID;
extern const juce::String releaseName;

extern const juce::String outputID;
extern const juce::String outputName;
2 changes: 1 addition & 1 deletion Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QuasoCompressorAudioProcessorEditor::QuasoCompressorAudioProcessorEditor (QuasoC
dialLabels[i]->attachToComponent(dials[i], false);
}


attachSliders();

setSize(1000, 500);

Expand Down
14 changes: 14 additions & 0 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ class QuasoCompressorAudioProcessorEditor : public juce::AudioProcessorEditor
void setCommonSliderProps(juce::Slider& slider);
void setCommonLabelProps(juce::Label& label);

//setting up attachment
using Attachment = std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>;

Attachment inputAttach;
Attachment threshAttach;
Attachment ratioAttach;
Attachment attackAttach;
Attachment releaseAttach;
Attachment outputAttach;

//method to attach sliders to the apvts
void attachSliders();





Expand Down
56 changes: 28 additions & 28 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ QuasoCompressorAudioProcessor::QuasoCompressorAudioProcessor()
{
//every paramaters needs a listener inside the constructor of the main AudioProcessor class
//everything the listener receives a changes from its parameter ID the parameterChanged method is called
apvts.addParameterListener("input", this);
apvts.addParameterListener("thresh", this);
apvts.addParameterListener("ratio", this);
apvts.addParameterListener("attack", this);
apvts.addParameterListener("release", this);
apvts.addParameterListener("output", this);
apvts.addParameterListener(inputID, this);
apvts.addParameterListener(threshID, this);
apvts.addParameterListener(ratioID, this);
apvts.addParameterListener(attackID, this);
apvts.addParameterListener(releaseID, this);
apvts.addParameterListener(outputID, this);
}

QuasoCompressorAudioProcessor::~QuasoCompressorAudioProcessor()
{
//the listener for each parameter has to be removed in the destructor
apvts.removeParameterListener("input", this);
apvts.removeParameterListener("thresh", this);
apvts.removeParameterListener("ratio", this);
apvts.removeParameterListener("attack", this);
apvts.removeParameterListener("release", this);
apvts.removeParameterListener("output", this);
apvts.removeParameterListener(inputID, this);
apvts.removeParameterListener(threshID, this);
apvts.removeParameterListener(ratioID, this);
apvts.removeParameterListener(attackID, this);
apvts.removeParameterListener(releaseID, this);
apvts.removeParameterListener(outputID, this);

}

Expand All @@ -57,22 +57,22 @@ juce::AudioProcessorValueTreeState::ParameterLayout QuasoCompressorAudioProcesso
juce::NormalisableRange<float> attackRange = juce::NormalisableRange<float>(0.0f, 200.0f, 1.0f);
attackRange.setSkewForCentre(50.0f);

juce::NormalisableRange<float> releaseRange = juce::NormalisableRange<float>(0.0f, 5000.0f, 1.0f);
juce::NormalisableRange<float> releaseRange = juce::NormalisableRange<float>( 5.0f, 5000.0f, 1.0f);
releaseRange.setSkewForCentre(160.0f);

//parameters are created
auto pInput = std::make_unique<juce::AudioParameterFloat>("input", "Input", -60.0f, 24.0f, 0.0f);
auto pThresh = std::make_unique<juce::AudioParameterFloat>("thresh", "Threshold", -60.0f, 10.0f, 0.0f);
auto pRatio = std::make_unique<juce::AudioParameterFloat>("ratio", "Ratio", 1.0f, 20.0f, 1.0f);
auto pAttack = std::make_unique<juce::AudioParameterFloat>("attack", "Attack", attackRange, 50.0f);
auto pRelease = std::make_unique<juce::AudioParameterFloat>("release", "Release", releaseRange, 160.0f);
auto pOutput = std::make_unique<juce::AudioParameterFloat>("output", "Output", -60.0f, 24.0f, 0.0f);
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 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 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(pAttack));
params.push_back(std::move(pRelease));
params.push_back(std::move(pOutput));

Expand All @@ -90,12 +90,12 @@ void QuasoCompressorAudioProcessor::parameterChanged(const juce::String& paramet
void QuasoCompressorAudioProcessor::updateParameters()
{
//the load method is needed because the raw parameters are atomic
inputModule.setGainDecibels(apvts.getRawParameterValue("input")->load());
compressorModule.setThreshold(apvts.getRawParameterValue("thresh")->load());
compressorModule.setRatio(apvts.getRawParameterValue("ratio")->load());
compressorModule.setAttack(apvts.getRawParameterValue("attack")->load());
compressorModule.setRelease(apvts.getRawParameterValue("release")->load());
outputModule.setGainDecibels(apvts.getRawParameterValue("output")->load());
inputModule.setGainDecibels(apvts.getRawParameterValue(inputID)->load());
compressorModule.setThreshold(apvts.getRawParameterValue(threshID)->load());
compressorModule.setRatio(apvts.getRawParameterValue(ratioID)->load());
compressorModule.setAttack(apvts.getRawParameterValue(attackID)->load());
compressorModule.setRelease(apvts.getRawParameterValue(releaseID)->load());
outputModule.setGainDecibels(apvts.getRawParameterValue(outputID)->load());

}

Expand Down Expand Up @@ -175,8 +175,8 @@ void QuasoCompressorAudioProcessor::prepareToPlay (double sampleRate, int sample
//prepare dsp modules for processing
inputModule.prepare(spec);
inputModule.setRampDurationSeconds(0.02);
outputModule.setRampDurationSeconds(0.02);
outputModule.prepare(spec);
outputModule.setRampDurationSeconds(0.02);
compressorModule.prepare(spec);

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

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

//process DSP modules
inputModule.process(juce::dsp::ProcessContextReplacing<float>(block));
Expand Down
1 change: 1 addition & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <JuceHeader.h>
#include "./Parameters/Parameters.h"

//==============================================================================
/**
Expand Down

0 comments on commit ce7f583

Please sign in to comment.