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: PVOC Passthrough: phase vocoder structure which passes input andrewm@0: to output without performing any processing andrewm@0: 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: PVOCPassthroughAudioProcessorEditor::PVOCPassthroughAudioProcessorEditor (PVOCPassthroughAudioProcessor* 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(&hopSizeComboBox_); andrewm@0: hopSizeComboBox_.setEditableText(false); andrewm@0: hopSizeComboBox_.setJustificationType(Justification::left); andrewm@0: hopSizeComboBox_.addItem("1 Window", PVOCPassthroughAudioProcessor::kHopSize1Window); andrewm@0: hopSizeComboBox_.addItem("1/2 Window", PVOCPassthroughAudioProcessor::kHopSize1_2Window); andrewm@0: hopSizeComboBox_.addItem("1/4 Window", PVOCPassthroughAudioProcessor::kHopSize1_4Window); andrewm@0: hopSizeComboBox_.addItem("1/8 Window", PVOCPassthroughAudioProcessor::kHopSize1_8Window); andrewm@0: hopSizeComboBox_.addListener(this); andrewm@0: andrewm@0: addAndMakeVisible(&windowTypeComboBox_); andrewm@0: windowTypeComboBox_.setEditableText(false); andrewm@0: windowTypeComboBox_.setJustificationType(Justification::left); andrewm@0: windowTypeComboBox_.addItem("Rectangular", PVOCPassthroughAudioProcessor::kWindowRectangular); andrewm@0: windowTypeComboBox_.addItem("Bartlett", PVOCPassthroughAudioProcessor::kWindowBartlett); andrewm@0: windowTypeComboBox_.addItem("Hann", PVOCPassthroughAudioProcessor::kWindowHann); andrewm@0: windowTypeComboBox_.addItem("Hamming", PVOCPassthroughAudioProcessor::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(&hopSizeComboBox_, 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: PVOCPassthroughAudioProcessorEditor::~PVOCPassthroughAudioProcessorEditor() andrewm@0: { andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: void PVOCPassthroughAudioProcessorEditor::paint (Graphics& g) andrewm@0: { andrewm@0: g.fillAll (Colours::grey); andrewm@0: } andrewm@0: andrewm@0: void PVOCPassthroughAudioProcessorEditor::resized() andrewm@0: { andrewm@0: fftSizeComboBox_.setBounds(20, 20, 150, 30); andrewm@0: hopSizeComboBox_.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 PVOCPassthroughAudioProcessorEditor::timerCallback() andrewm@0: { andrewm@0: PVOCPassthroughAudioProcessor* ourProcessor = getProcessor(); andrewm@0: b@1: fftSizeComboBox_.setSelectedId(ourProcessor->fftSelectedSize_, dontSendNotification); b@1: hopSizeComboBox_.setSelectedId(ourProcessor->hopSelectedSize_, dontSendNotification); b@1: 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 PVOCPassthroughAudioProcessorEditor::sliderValueChanged (Slider* slider) andrewm@0: { andrewm@0: } andrewm@0: andrewm@0: // Similar callback to sliderValueChanged for ComboBox updates andrewm@0: void PVOCPassthroughAudioProcessorEditor::comboBoxChanged (ComboBox *comboBox) andrewm@0: { andrewm@0: if(comboBox == &fftSizeComboBox_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (PVOCPassthroughAudioProcessor::kFFTSizeParam, andrewm@0: (float)fftSizeComboBox_.getSelectedId()); andrewm@0: } andrewm@0: else if(comboBox == &hopSizeComboBox_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (PVOCPassthroughAudioProcessor::kHopSizeParam, andrewm@0: (float)hopSizeComboBox_.getSelectedId()); andrewm@0: } andrewm@0: else if(comboBox == &windowTypeComboBox_) andrewm@0: { andrewm@0: getProcessor()->setParameterNotifyingHost (PVOCPassthroughAudioProcessor::kWindowTypeParam, andrewm@0: (float)windowTypeComboBox_.getSelectedId()); andrewm@0: } andrewm@0: }