/* ============================================================================== This file contains the basic framework code for a JUCE plugin editor. ============================================================================== */ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== GainSliderAudioProcessorEditor::GainSliderAudioProcessorEditor (GainSliderAudioProcessor& p) : AudioProcessorEditor (&p), audioProcessor (p) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. setSize (600, 200); audioProcessor.reverb.setParameters({ 0.5f, 0.5f, 0.5f }); roomSizeSlider.setSliderStyle(juce::Slider::Rotary); roomSizeSlider.setTextBoxStyle(juce::Slider::NoTextBox, false, 0, 0); roomSizeSlider.setRange(0.0, 1.0, 0.01); roomSizeSlider.setValue(audioProcessor.reverb.getParameters().roomSize); roomSizeSlider.addListener(this); addAndMakeVisible(roomSizeSlider); addAndMakeVisible(roomSizeSlider); roomSizeLabel.setText("Roomsize", juce::dontSendNotification); roomSizeLabel.setJustificationType(juce::Justification::centred); addAndMakeVisible(roomSizeLabel); dampingSlider.setSliderStyle(juce::Slider::Rotary); dampingSlider.setTextBoxStyle(juce::Slider::NoTextBox, false, 0, 0); dampingSlider.setRange(0.0, 1.0, 0.01); dampingSlider.setValue(audioProcessor.reverb.getParameters().damping); dampingSlider.addListener(this); addAndMakeVisible(dampingSlider); addAndMakeVisible(dampingSlider); dampingLabel.setText("Damping", juce::dontSendNotification); dampingLabel.setJustificationType(juce::Justification::centred); addAndMakeVisible(dampingLabel); gainSlider.setSliderStyle(juce::Slider::RotaryVerticalDrag); gainSlider.setTextBoxStyle(juce::Slider::TextBoxBelow, false, 0, 0); gainSlider.setRange(-48.0, 10.0); gainSlider.setValue(-1.0); gainSlider.addListener(this); addAndMakeVisible(gainSlider); gainLabel.setText("Gain", juce::dontSendNotification); gainLabel.setJustificationType(juce::Justification::centred); addAndMakeVisible(gainLabel); } GainSliderAudioProcessorEditor::~GainSliderAudioProcessorEditor() { } //============================================================================== void GainSliderAudioProcessorEditor::paint (juce::Graphics& g) { // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll(juce::Colours::darkgrey); getLookAndFeel().setColour(juce::Slider::thumbColourId, juce::Colours::yellow); getLookAndFeel().setColour(juce::Slider::rotarySliderFillColourId, juce::Colours::orange); getLookAndFeel().setColour(juce::Slider::rotarySliderOutlineColourId, juce::Colours::green); } void GainSliderAudioProcessorEditor::resized() { // This is generally where you'll want to lay out the positions of any // subcomponents in your editor.. const int knobSize = 200; const int labelHeight = 20; const int textBoxHeight = 20; // Set the bounds of the knob within the component roomSizeSlider.setBounds((getWidth() - knobSize) / 2 -200, 0, knobSize, getHeight() - labelHeight - textBoxHeight); // Set the bounds of the label underneath the knob roomSizeLabel.setBounds(-200, getHeight() - labelHeight - textBoxHeight, getWidth(), labelHeight); // Set the bounds of the knob within the component dampingSlider.setBounds((getWidth() - knobSize) / 2, 0, knobSize, getHeight() - labelHeight - textBoxHeight); // Set the bounds of the label underneath the knob dampingLabel.setBounds(0, getHeight() - labelHeight - textBoxHeight, getWidth(), labelHeight); // Set the bounds of the knob within the component gainSlider.setBounds((getWidth() - knobSize) / 2 + 200, 0, knobSize, getHeight() - labelHeight - textBoxHeight); // Set the bounds of the label underneath the knob gainLabel.setBounds(200, getHeight() - labelHeight - textBoxHeight, getWidth(), labelHeight); } void GainSliderAudioProcessorEditor::sliderValueChanged(juce::Slider* slider) { if (slider == &gainSlider) { audioProcessor.rawVolume = pow(10, gainSlider.getValue() / 20); } else if (slider == &roomSizeSlider) { audioProcessor.reverb.setParameters({ (float)slider->getValue(), audioProcessor.reverb.getParameters().damping }); } else if (slider == &dampingSlider) { audioProcessor.reverb.setParameters({ audioProcessor.reverb.getParameters().roomSize, (float)slider->getValue() }); } }