-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginEditor.cpp
More file actions
88 lines (68 loc) · 2.78 KB
/
PluginEditor.cpp
File metadata and controls
88 lines (68 loc) · 2.78 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
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin editor.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
UrcompressorAudioProcessorEditor::UrcompressorAudioProcessorEditor (UrcompressorAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
addAndMakeVisible(&attackSlider);
addAndMakeVisible(&releaseSlider);
addAndMakeVisible(&ratioSlider);
addAndMakeVisible(&thresholdSlider);
//Set ranges
attackSlider.setRange(0.1f, 100.f);
releaseSlider.setRange(10.f, 1000.f);
ratioSlider.setRange(1.f, 10.f, 1.0f);
thresholdSlider.setRange(-64.f, 0.f);
//Set starting values
attackSlider.setValue(10.f);
releaseSlider.setValue(100.f);
ratioSlider.setValue(4.f);
thresholdSlider.setValue(-3.f);
//Set textboxes
attackSlider.setTextBoxStyle(juce::Slider::TextBoxAbove, false, 70, 70);
releaseSlider.setTextBoxStyle(juce::Slider::TextBoxAbove, false, 70, 70);
ratioSlider.setTextBoxStyle(juce::Slider::TextBoxAbove, false, 70, 70);
thresholdSlider.setTextBoxStyle(juce::Slider::TextBoxAbove, false, 70, 70);
//Attach sliders to values
attackSlider.onValueChange = [this]() {
audioProcessor.compressor.setAttack(attackSlider.getValue());
};
releaseSlider.onValueChange = [this]() {
audioProcessor.compressor.setRelease(releaseSlider.getValue());
};
ratioSlider.onValueChange = [this]() {
audioProcessor.compressor.setRatio(ratioSlider.getValue());
};
thresholdSlider.onValueChange = [this]() {
audioProcessor.compressor.setTreshold(thresholdSlider.getValue());
};
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 300);
}
UrcompressorAudioProcessorEditor::~UrcompressorAudioProcessorEditor()
{
}
//==============================================================================
void UrcompressorAudioProcessorEditor::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
g.setColour (juce::Colours::white);
g.setFont (15.0f);
//g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1);
}
void UrcompressorAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
attackSlider.setBounds(5, 75, 70, 70);
releaseSlider.setBounds(100, 75, 70, 70);
ratioSlider.setBounds(200, 75, 70, 70);
thresholdSlider.setBounds(300, 75, 70, 70);
}