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: Robotisation: robot effect using phase vocoder andrewm@0: See textbook Chapter 8: The Phase Vocoder andrewm@0: andrewm@0: Code by Andrew McPherson, Brecht De Man and Joshua Reiss andrewm@0: andrewm@0: This code requires the fftw library version 3 to compile: andrewm@0: http://fftw.org 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: RobotisationAudioProcessorEditor::RobotisationAudioProcessorEditor (RobotisationAudioProcessor* ownerFilter) andrewm@0: : AudioProcessorEditor (ownerFilter), andrewm@0: fftSizeLabel_("", "FFT Size:"), andrewm@0: hopSizeLabel_("", "Hop Size:"), andrewm@0: windowTypeLabel_("", "Window Type:") 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 selection boxes andrewm@0: andrewm@0: addAndMakeVisible(&fftSizeComboBox_); andrewm@0: fftSizeComboBox_.setEditableText(false); andrewm@0: fftSizeComboBox_.setJustificationType(Justification::left); andrewm@0: fftSizeComboBox_.addItem("64", 64); andrewm@0: fftSizeComboBox_.addItem("128", 128); andrewm@0: fftSizeComboBox_.addItem("256", 256); andrewm@0: fftSizeComboBox_.addItem("512", 512); andrewm@0: fftSizeComboBox_.addItem("1024", 1024); andrewm@0: fftSizeComboBox_.addItem("2048", 2048); andrewm@0: fftSizeComboBox_.addListener(this); andrewm@0: andrewm@0: addAndMakeVisible (&hopSizeSlider_); andrewm@0: hopSizeSlider_.setSliderStyle (Slider::Rotary); andrewm@0: hopSizeSlider_.addListener (this); andrewm@0: hopSizeSlider_.setRange (32, 2048, 1.0); andrewm@0: andrewm@0: addAndMakeVisible(&windowTypeComboBox_); andrewm@0: windowTypeComboBox_.setEditableText(false); andrewm@0: windowTypeComboBox_.setJustificationType(Justification::left); andrewm@0: windowTypeComboBox_.addItem("Rectangular", RobotisationAudioProcessor::kWindowRectangular); andrewm@0: windowTypeComboBox_.addItem("Bartlett", RobotisationAudioProcessor::kWindowBartlett); andrewm@0: windowTypeComboBox_.addItem("Hann", RobotisationAudioProcessor::kWindowHann); andrewm@0: windowTypeComboBox_.addItem("Hamming", RobotisationAudioProcessor::kWindowHamming); andrewm@0: windowTypeComboBox_.addListener(this); andrewm@0: andrewm@0: fftSizeLabel_.attachToComponent(&fftSizeComboBox_, false); andrewm@0: fftSizeLabel_.setFont(Font (11.0f)); andrewm@0: andrewm@0: hopSizeLabel_.attachToComponent(&hopSizeSlider_, false); andrewm@0: hopSizeLabel_.setFont(Font (11.0f)); andrewm@0: andrewm@0: windowTypeLabel_.attachToComponent(&windowTypeComboBox_, false); andrewm@0: windowTypeLabel_.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(370, 120, 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: RobotisationAudioProcessorEditor::~RobotisationAudioProcessorEditor() andrewm@0: { andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: void RobotisationAudioProcessorEditor::paint (Graphics& g) andrewm@0: { andrewm@0: g.fillAll (Colours::grey); andrewm@0: } andrewm@0: andrewm@0: void RobotisationAudioProcessorEditor::resized() andrewm@0: { andrewm@0: fftSizeComboBox_.setBounds(20, 20, 150, 30); andrewm@0: hopSizeSlider_.setBounds(200, 20, 150, 30); andrewm@0: windowTypeComboBox_.setBounds(20, 70, 150, 30); 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 RobotisationAudioProcessorEditor::timerCallback() andrewm@0: { andrewm@0: RobotisationAudioProcessor* ourProcessor = getProcessor(); andrewm@0: andrewm@0: fftSizeComboBox_.setSelectedId(ourProcessor->fftSelectedSize_, dontSendNotification); andrewm@0: hopSizeSlider_.setValue(ourProcessor->hopSelectedSize_, dontSendNotification); andrewm@0: windowTypeComboBox_.setSelectedId(ourProcessor->windowType_, dontSendNotification); andrewm@0: } andrewm@0: andrewm@0: // This is our Slider::Listener callback, when the user drags a slider. andrewm@0: void RobotisationAudioProcessorEditor::sliderValueChanged (Slider* slider) 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: andrewm@0: if (slider == &hopSizeSlider_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (RobotisationAudioProcessor::kHopSizeParam, andrewm@0: (float)hopSizeSlider_.getValue()); andrewm@0: } andrewm@0: } andrewm@0: andrewm@0: // Similar callback to sliderValueChanged for ComboBox updates andrewm@0: void RobotisationAudioProcessorEditor::comboBoxChanged (ComboBox *comboBox) andrewm@0: { andrewm@0: if(comboBox == &fftSizeComboBox_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (RobotisationAudioProcessor::kFFTSizeParam, andrewm@0: (float)fftSizeComboBox_.getSelectedId()); andrewm@0: } andrewm@0: else if(comboBox == &windowTypeComboBox_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (RobotisationAudioProcessor::kWindowTypeParam, andrewm@0: (float)windowTypeComboBox_.getSelectedId()); andrewm@0: } andrewm@0: }