-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginProcessor.h
More file actions
140 lines (107 loc) · 5.21 KB
/
PluginProcessor.h
File metadata and controls
140 lines (107 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin processor.
==============================================================================
*/
#pragma once
#include <JuceHeader.h>
#include <juce_dsp/juce_dsp.h>
#include "Service/Parameters.h"
#include "Service/ProtectYourEars.h"
#include "Service/PresetManager.h"
#include "DSP/CompressorUnit.h"
#include "DSP/OptoCompressorUnit.h"
#include "Service/Measurement.h"
#include "Service/RmsMeasurement.h"
//==============================================================================
/**
*/
class GuideLinesCompAudioProcessor : public juce::AudioProcessor
{
public:
//==============================================================================
GuideLinesCompAudioProcessor();
~GuideLinesCompAudioProcessor() override;
//==============================================================================
void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported(const BusesLayout& layouts) const override;
#endif
void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
//==============================================================================
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;
//==============================================================================
const juce::String getName() const override;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool isMidiEffect() const override;
double getTailLengthSeconds() const override;
//==============================================================================
int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram(int index) override;
const juce::String getProgramName(int index) override;
void changeProgramName(int index, const juce::String& newName) override;
//==============================================================================
void getStateInformation(juce::MemoryBlock& destData) override;
void setStateInformation(const void* data, int sizeInBytes) override;
juce::AudioProcessorParameter* getBypassParameter() const override;
juce::AudioProcessorValueTreeState apvts{
*this, nullptr, "Parameters", Parameters::createParameterLayout()
};
Parameters params;
CompressorUnit compA;
OptoCompressorUnit compB;
RmsMeasurement rmsInputLevelLeft;
RmsMeasurement rmsInputLevelRight;
Measurement peakInputLevelRight;
Measurement peakInputLevelLeft;
RmsMeasurement rmsOutputLevelLeft;
RmsMeasurement rmsOutputLevelRight;
Measurement peakOutputLevelRight;
Measurement peakOutputLevelLeft;
RmsMeasurement rmsTotalGainReductionLeft;
RmsMeasurement rmsTotalGainReductionRight;
float getPeakInputLevelForKnob() const noexcept { return peakInputLevelForKnob.load(); }
float getCompressionAmountForKnob() const noexcept { return compressionAmountForKnob.load(); }
float getPeakOutputLevelForKnob() const noexcept { return peakOutputLevelForKnob.load(); }
Service::PresetManager& getPresetManager() { return *presetManager; }
private:
std::unique_ptr<Service::PresetManager> presetManager;
juce::dsp::StateVariableTPTFilter<float> lowCutFilter;
float lastLowCut = -1.f;
juce::dsp::Gain<float> outputGainProcessor;
float bypassFade = 1.0f;
float bypassFadeInc = 0.0f;
bool isBypassing = false;
float controlAttackA = 50.0f;
float compressThresholdA = -12.f;
float controlReleaseA = 55.0f;
float compressRatioA = 2.0f;
std::atomic<float> compAGainReductionDbLeft{ 0.0f };
std::atomic<float> compAGainReductionDbRight{ 0.0f };
RmsMeasurement rmsCompAOutputLeft;
RmsMeasurement rmsCompAOutputRight;
RmsMeasurement rmsCompBOutputLeft;
RmsMeasurement rmsCompBOutputRight;
std::atomic<float> compBGainReductionDbLeft{ 0.0f };
std::atomic<float> compBGainReductionDbRight{ 0.0f };
juce::LinearSmoothedValue<float> compressInputGainSmoother = 1.0f;
juce::LinearSmoothedValue<float> controlAttackASmoother = 50.0f;
juce::LinearSmoothedValue<float> controlThresholdASmoother = -12.f;
juce::LinearSmoothedValue<float> compressRatioASmoother = 2.0f;
juce::LinearSmoothedValue<float> controlReleaseASmoother = 55.0f;
std::atomic<float> peakInputLevelForKnob{ 0.0f };
std::atomic<float> compressionAmountForKnob{ 0.0f };
std::atomic<float> peakOutputLevelForKnob{ 0.0f };
void initializeProcessing(juce::AudioBuffer<float>& buffer);
void updateBypassState();
void updateLowCutFilter();
void updateMappedCompressorParameters();
void updateRMSLevels(const juce::AudioBuffer<float>& buffer, RmsMeasurement& rmsLevelLeft, RmsMeasurement& rmsLevelRight);
void updatePeakLevels(const juce::AudioBuffer<float>& buffer, Measurement& peakLevelLeft, Measurement& peakLevelRight);
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(GuideLinesCompAudioProcessor)
};