-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom DSP, button GUI, audio tracks
-Custom compressor DSP module following Eric Tarr Hack Audio -started working on button with .cpp file and a method to make visibile new look and feel needed -standalone .cpp file for labels -new audio track
- Loading branch information
1 parent
faec816
commit 3a85864
Showing
13 changed files
with
271 additions
and
26 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
============================================================================== | ||
CustomCompressor.cpp | ||
Created: 7 Feb 2023 4:07:01pm | ||
Author: Utente | ||
============================================================================== | ||
*/ | ||
|
||
#include "CustomCompressor.h" | ||
|
||
CustomCompressor::CustomCompressor() | ||
{ | ||
|
||
} | ||
|
||
|
||
void CustomCompressor::prepare(juce::dsp::ProcessSpec& spec) noexcept | ||
{ | ||
_sampleRate = spec.sampleRate; | ||
} | ||
|
||
|
||
void CustomCompressor::setThreshold(float newThresh) | ||
{ | ||
_thresh = newThresh; | ||
} | ||
|
||
|
||
void CustomCompressor::setRatio(float newRatio) | ||
{ | ||
_ratio = newRatio; | ||
} | ||
|
||
|
||
void CustomCompressor::setAttack(float newAttack) | ||
{ | ||
_attack = newAttack / 1000.0f; | ||
} | ||
|
||
void CustomCompressor::setRelease(float newRelease) | ||
{ | ||
_release = newRelease / 1000.0f; | ||
} | ||
|
||
void CustomCompressor::setBypass(bool newBypass) | ||
{ | ||
_isBypassed = newBypass; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
============================================================================== | ||
CustomCompressor.h | ||
Created: 7 Feb 2023 4:07:01pm | ||
Author: Utente | ||
============================================================================== | ||
*/ | ||
|
||
#pragma once | ||
#include <JuceHeader.h> | ||
|
||
class CustomCompressor | ||
{ | ||
|
||
public: | ||
CustomCompressor(); | ||
|
||
void prepare(juce::dsp::ProcessSpec& spec) noexcept; | ||
|
||
void process(juce::AudioBuffer<float>& buffer) noexcept | ||
{ | ||
//the process method is defined in the header file | ||
//because it is passed through the translation unit | ||
//and has a better chance of being optimized | ||
//bypassing the dsp | ||
|
||
if (_isBypassed == true) | ||
return; | ||
|
||
auto data = buffer.getArrayOfWritePointers(); | ||
|
||
//sample/channel loop | ||
for(int sample = 0; sample < buffer.getNumSamples(); ++sample) | ||
{ | ||
|
||
for (int ch = 0; ch < buffer.getNumChannels(); ++ch) | ||
{ | ||
data[ch][sample] = processSample(data[ch][sample]); | ||
} | ||
} | ||
} | ||
|
||
float processSample(float inputValue) | ||
{ | ||
//attack and release variable from Eric Tarr Hack Audio | ||
auto alphaAttack = std::exp((std::log(9) * -1.0) / (_sampleRate * _attack)); | ||
auto alphaRelease = std::exp((std::log(9) * -1.0) / (_sampleRate * _release)); | ||
|
||
const auto input = inputValue; | ||
|
||
//input dividedin unipolar (absolute value) and dB values | ||
auto input_uni = std::abs(input); //maybe remove std | ||
auto input_dB = juce::Decibels::gainToDecibels(input_uni / 1.0); | ||
|
||
//checking that no value in dB are negative infinity | ||
if (input_dB < -96) | ||
{ | ||
input_dB = -96; | ||
} | ||
|
||
if (input_dB > _thresh) | ||
{ | ||
_gainSC = _thresh + (input_dB - _thresh) / _ratio; | ||
} | ||
|
||
else | ||
{ | ||
_gainSC = input_dB; | ||
} | ||
|
||
_gainChange_dB = _gainSC - input_dB; | ||
|
||
if (_gainChange_dB < _gainSmoothPrevious) | ||
{ | ||
_gainSmooth = ((1.0 - alphaAttack) * _gainChange_dB) + (alphaAttack * _gainSmoothPrevious); | ||
_currentSignal = _gainSmooth; | ||
} | ||
|
||
else | ||
{ | ||
_gainSmooth = ((1.0 - alphaRelease) * _gainChange_dB) + (alphaRelease * _gainSmoothPrevious); | ||
_currentSignal = _gainSmooth; | ||
|
||
} | ||
|
||
auto output = input * juce::Decibels::decibelsToGain(_gainSmooth); | ||
_gainSmoothPrevious = _gainSmooth; | ||
|
||
//output signal | ||
return output; | ||
|
||
} | ||
|
||
void setThreshold(float newThresh); | ||
void setRatio(float newRatio); | ||
void setAttack(float newAttack); | ||
void setRelease(float newRelease); | ||
void setBypass(bool newBypass); | ||
|
||
|
||
private: | ||
|
||
//compressor parameters | ||
float _thresh = 0.0f; | ||
float _ratio = 1.0f; | ||
float _attack = 50.0f / 1000.0f ; | ||
float _release = 160.0f / 1000.0f; | ||
bool _isBypassed = false; | ||
|
||
//sample rate | ||
float _sampleRate = 44100.0f; | ||
|
||
//gain sidechain | ||
float _gainSC = 0.0f; | ||
|
||
//gain smooth | ||
float _gainSmooth = 0.0f; | ||
|
||
//gain smooth previous | ||
float _gainSmoothPrevious = 0.0f; | ||
|
||
//current signal | ||
float _currentSignal = 0.0f; | ||
|
||
//gain change in decibels | ||
float _gainChange_dB = 0.0f; | ||
|
||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
============================================================================== | ||
Buttons.cpp | ||
Created: 7 Feb 2023 8:21:22pm | ||
Author: Utente | ||
============================================================================== | ||
*/ | ||
|
||
#include "../../PluginEditor.h" | ||
|
||
void QuasoCompressorAudioProcessorEditor::setButtonProps(juce::ToggleButton& button) | ||
{ | ||
addAndMakeVisible(button); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
============================================================================== | ||
Labels.cpp | ||
Created: 7 Feb 2023 8:23:29pm | ||
Author: Utente | ||
============================================================================== | ||
*/ | ||
|
||
#include "../../PluginEditor.h" | ||
|
||
void QuasoCompressorAudioProcessorEditor::setCommonLabelProps(juce::Label& label) | ||
{ | ||
//setting properties common to every slider | ||
addAndMakeVisible(label); | ||
label.setFont(juce::Font("Helvetica", 16.0f, juce::Font::FontStyleFlags::bold)); | ||
label.setJustificationType(juce::Justification::centred); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.