andrewm@0: /* andrewm@0: This code accompanies the textbook: andrewm@0: andrewm@0: Digital Audio Effects: Theory, Implementation and Application andrewm@0: Joshua D. Reiss and Andrew P. McPherson andrewm@0: andrewm@0: --- andrewm@0: andrewm@0: Empty: template for an effect; passes input to output unmodified andrewm@0: See textbook Chapter 13: Building Audio Effect Plug-Ins andrewm@0: andrewm@0: Code by Andrew McPherson, Brecht De Man and Joshua Reiss andrewm@0: andrewm@0: --- andrewm@0: andrewm@0: This program is free software: you can redistribute it and/or modify andrewm@0: it under the terms of the GNU General Public License as published by andrewm@0: the Free Software Foundation, either version 3 of the License, or andrewm@0: (at your option) any later version. andrewm@0: andrewm@0: This program is distributed in the hope that it will be useful, andrewm@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrewm@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrewm@0: GNU General Public License for more details. andrewm@0: andrewm@0: You should have received a copy of the GNU General Public License andrewm@0: along with this program. If not, see . andrewm@0: */ andrewm@0: andrewm@0: #include "PluginProcessor.h" andrewm@0: #include "PluginEditor.h" andrewm@0: andrewm@0: andrewm@0: //============================================================================== andrewm@0: EmptyAudioProcessorEditor::EmptyAudioProcessorEditor (EmptyAudioProcessor* ownerFilter) andrewm@0: : AudioProcessorEditor (ownerFilter), andrewm@0: volumeLabel_("", "Volume:"), andrewm@0: volumeSlider_("volume") andrewm@0: { andrewm@0: // This is where our plugin's editor size is set. andrewm@0: // setSize(170, 80); andrewm@0: andrewm@0: // Set up the sliders andrewm@0: addAndMakeVisible(&volumeSlider_); andrewm@0: volumeSlider_.setSliderStyle(Slider::Rotary); andrewm@0: volumeSlider_.addListener(this); andrewm@0: volumeSlider_.setRange(0.0, 2.0, 0.01); andrewm@0: andrewm@0: volumeLabel_.attachToComponent(&volumeSlider_, false); andrewm@0: volumeLabel_.setFont(Font (11.0f)); andrewm@0: andrewm@0: // add the triangular resizer component for the bottom-right of the UI andrewm@0: addAndMakeVisible(resizer_ = new ResizableCornerComponent (this, &resizeLimits_)); andrewm@0: resizeLimits_.setSizeLimits(170, 100, 400, 160); andrewm@0: andrewm@0: // set our component's initial size to be the last one that was stored in the filter's settings andrewm@0: setSize(ownerFilter->lastUIWidth_, andrewm@0: ownerFilter->lastUIHeight_); andrewm@0: andrewm@0: startTimer(50); andrewm@0: } andrewm@0: andrewm@0: EmptyAudioProcessorEditor::~EmptyAudioProcessorEditor() andrewm@0: { andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: void EmptyAudioProcessorEditor::paint (Graphics& g) andrewm@0: { andrewm@0: g.fillAll (Colours::grey); andrewm@0: } andrewm@0: andrewm@0: void EmptyAudioProcessorEditor::resized() andrewm@0: { andrewm@0: volumeSlider_.setBounds(20, 20, 150, 40); andrewm@0: andrewm@0: resizer_->setBounds(getWidth() - 16, getHeight() - 16, 16, 16); andrewm@0: andrewm@0: getProcessor()->lastUIWidth_ = getWidth(); andrewm@0: getProcessor()->lastUIHeight_ = getHeight(); andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: // This timer periodically checks whether any of the filter's parameters have changed... andrewm@0: void EmptyAudioProcessorEditor::timerCallback() andrewm@0: { andrewm@0: EmptyAudioProcessor* ourProcessor = getProcessor(); andrewm@0: andrewm@0: volumeSlider_.setValue(ourProcessor->volume_, dontSendNotification); andrewm@0: } andrewm@0: andrewm@0: // This is our Slider::Listener callback, when the user drags a slider. andrewm@0: void EmptyAudioProcessorEditor::sliderValueChanged (Slider* slider) andrewm@0: { andrewm@0: if (slider == &volumeSlider_) andrewm@0: { andrewm@0: // It's vital to use setParameterNotifyingHost to change any parameters that are automatable andrewm@0: // by the host, rather than just modifying them directly, otherwise the host won't know andrewm@0: // that they've changed. andrewm@0: getProcessor()->setParameterNotifyingHost (EmptyAudioProcessor::kVolumeParam, andrewm@0: (float)volumeSlider_.getValue()); andrewm@0: } andrewm@0: }