annotate AddressPlugin/PluginEditor.cpp @ 2:13ec2fa02a26 tip

(none)
author Yannick JACOB <y.jacob@se12.qmul.ac.uk>
date Tue, 03 Sep 2013 15:33:42 +0100
parents 2cd427e000b0
children
rev   line source
y@0 1 /*
y@0 2 ==============================================================================
y@0 3
y@0 4 This file was auto-generated by the Introjucer!
y@0 5
y@0 6 It contains the basic startup code for a Juce application.
y@0 7
y@0 8 ==============================================================================
y@0 9 */
y@0 10
y@0 11 #include "PluginProcessor.h"
y@0 12 #include "PluginEditor.h"
y@0 13
y@0 14
y@0 15 //==============================================================================
y@0 16 ADRessAudioProcessorEditor::ADRessAudioProcessorEditor (ADRessAudioProcessor* ownerFilter)
y@0 17 : AudioProcessorEditor (ownerFilter),
y@0 18 fftSizeLabel_("", "FFT Size:"),
y@0 19 hopSizeLabel_("", "Hop Size:"),
y@0 20 windowTypeLabel_("", "Window Type:"),
y@0 21 widthLabel_("", "Width:"),
y@0 22 widthSlider_("width"),
y@0 23 azimuthLabel_("", "Azimuth:"),
y@0 24 azimuthSlider_("azimuth")
y@0 25 {
y@0 26 // This is where our plugin's editor size is set.
y@0 27 // setSize(170, 80);
y@0 28
y@0 29 betaE_ = 5;
y@0 30 // Set up the selection boxes
y@0 31
y@0 32 addAndMakeVisible(&fftSizeComboBox_);
y@0 33 fftSizeComboBox_.setEditableText(false);
y@0 34 fftSizeComboBox_.setJustificationType(Justification::left);
y@0 35 fftSizeComboBox_.addItem("1024", 1024);
y@0 36 fftSizeComboBox_.addItem("2048", 2048);
y@0 37 fftSizeComboBox_.addItem("4096", 4096);
y@0 38 fftSizeComboBox_.addListener(this);
y@0 39
y@0 40 addAndMakeVisible(&hopSizeComboBox_);
y@0 41 hopSizeComboBox_.setEditableText(false);
y@0 42 hopSizeComboBox_.setJustificationType(Justification::left);
y@0 43 hopSizeComboBox_.addItem("1/4 Window", ADRessAudioProcessor::kHopSize1_4Window);
y@0 44 hopSizeComboBox_.addItem("1/8 Window", ADRessAudioProcessor::kHopSize1_8Window);
y@0 45 hopSizeComboBox_.addListener(this);
y@0 46
y@0 47 addAndMakeVisible(&windowTypeComboBox_);
y@0 48 windowTypeComboBox_.setEditableText(false);
y@0 49 windowTypeComboBox_.setJustificationType(Justification::left);
y@0 50 windowTypeComboBox_.addItem("Rectangular", ADRessAudioProcessor::kWindowRectangular);
y@0 51 windowTypeComboBox_.addItem("Bartlett", ADRessAudioProcessor::kWindowBartlett);
y@0 52 windowTypeComboBox_.addItem("Hann", ADRessAudioProcessor::kWindowHann);
y@0 53 windowTypeComboBox_.addItem("Hamming", ADRessAudioProcessor::kWindowHamming);
y@0 54 windowTypeComboBox_.addListener(this);
y@0 55
y@0 56
y@0 57 // Set up the sliders
y@0 58 addAndMakeVisible(&widthSlider_);
y@0 59 widthSlider_.setSliderStyle(Slider::Rotary);
y@0 60 widthSlider_.addListener(this);
y@0 61 widthSlider_.setRange(0, betaE_, 1);
y@0 62
y@0 63 widthLabel_.attachToComponent(&widthSlider_, false);
y@0 64 widthLabel_.setFont(Font (11.0f));
y@0 65
y@0 66
y@0 67 // Set up the sliders
y@0 68 addAndMakeVisible(&azimuthSlider_);
y@0 69 azimuthSlider_.setSliderStyle(Slider::Rotary);
y@0 70 azimuthSlider_.addListener(this);
y@0 71 azimuthSlider_.setRange(0, 2*betaE_, 1);
y@0 72
y@0 73
y@0 74
y@0 75 azimuthLabel_.attachToComponent(&azimuthSlider_, false);
y@0 76 azimuthLabel_.setFont(Font (11.0f));
y@0 77
y@0 78 fftSizeLabel_.attachToComponent(&fftSizeComboBox_, false);
y@0 79 fftSizeLabel_.setFont(Font (11.0f));
y@0 80
y@0 81 hopSizeLabel_.attachToComponent(&hopSizeComboBox_, false);
y@0 82 hopSizeLabel_.setFont(Font (11.0f));
y@0 83
y@0 84 windowTypeLabel_.attachToComponent(&windowTypeComboBox_, false);
y@0 85 windowTypeLabel_.setFont(Font (11.0f));
y@0 86
y@0 87 // add the triangular resizer component for the bottom-right of the UI
y@0 88 addAndMakeVisible(resizer_ = new ResizableCornerComponent (this, &resizeLimits_));
y@0 89 resizeLimits_.setSizeLimits(360, 400, 360, 400);
y@0 90
y@0 91 // set our component's initial size to be the last one that was stored in the filter's settings
y@0 92 setSize(ownerFilter->lastUIWidth_,
y@0 93 ownerFilter->lastUIHeight_);
y@0 94
y@0 95 startTimer(50);
y@0 96 }
y@0 97
y@0 98 ADRessAudioProcessorEditor::~ADRessAudioProcessorEditor()
y@0 99 {
y@0 100 }
y@0 101
y@0 102 //==============================================================================
y@0 103 void ADRessAudioProcessorEditor::paint (Graphics& g)
y@0 104 {
y@0 105 g.fillAll (Colours::grey);
y@0 106 }
y@0 107
y@0 108 void ADRessAudioProcessorEditor::resized()
y@0 109 {
y@0 110 fftSizeComboBox_.setBounds(20, 20, 150, 30);
y@0 111 hopSizeComboBox_.setBounds(200, 20, 150, 30);
y@0 112 windowTypeComboBox_.setBounds(20, 75, 150, 30);
y@0 113 widthSlider_.setBounds(200, 70, 150, 40);
y@0 114
y@0 115 azimuthSlider_.setBounds(20, 150, 150, 40);
y@0 116 resizer_->setBounds(getWidth() - 16, getHeight() - 16, 16, 16);
y@0 117
y@0 118 getProcessor()->lastUIWidth_ = getWidth();
y@0 119 getProcessor()->lastUIHeight_ = getHeight();
y@0 120 }
y@0 121
y@0 122 //==============================================================================
y@0 123 // This timer periodically checks whether any of the filter's parameters have changed...
y@0 124 void ADRessAudioProcessorEditor::timerCallback()
y@0 125 {
y@0 126 ADRessAudioProcessor* ourProcessor = getProcessor();
y@0 127
y@0 128 fftSizeComboBox_.setSelectedId(ourProcessor->fftSelectedSize_, false);
y@0 129 hopSizeComboBox_.setSelectedId(ourProcessor->hopSelectedSize_, false);
y@0 130 windowTypeComboBox_.setSelectedId(ourProcessor->windowType_, false);
y@0 131
y@0 132 widthSlider_.setValue(ourProcessor->width_, dontSendNotification);
y@0 133 azimuthSlider_.setValue(ourProcessor->azimuth_, dontSendNotification);
y@0 134 }
y@0 135
y@0 136 // This is our Slider::Listener callback, when the user drags a slider.
y@0 137 void ADRessAudioProcessorEditor::sliderValueChanged (Slider* slider)
y@0 138 {
y@0 139 if (slider == &widthSlider_)
y@0 140 {
y@0 141 // It's vital to use setParameterNotifyingHost to change any parameters that are automatable
y@0 142 // by the host, rather than just modifying them directly, otherwise the host won't know
y@0 143 // that they've changed.
y@0 144 getProcessor()->setParameterNotifyingHost (ADRessAudioProcessor::kWidthParam,
y@0 145 (float)widthSlider_.getValue());
y@0 146 }
y@0 147
y@0 148 if (slider == &azimuthSlider_)
y@0 149 {
y@0 150 getProcessor()->setParameterNotifyingHost (ADRessAudioProcessor::kAzimuthParam,
y@0 151 (float)azimuthSlider_.getValue());
y@0 152 }
y@0 153 }
y@0 154
y@0 155 // Similar callback to sliderValueChanged for ComboBox updates
y@0 156 void ADRessAudioProcessorEditor::comboBoxChanged (ComboBox *comboBox)
y@0 157 {
y@0 158 if(comboBox == &fftSizeComboBox_)
y@0 159 {
y@0 160 getProcessor()->setParameterNotifyingHost (ADRessAudioProcessor::kFFTSizeParam,
y@0 161 (float)fftSizeComboBox_.getSelectedId());
y@0 162 }
y@0 163 else if(comboBox == &hopSizeComboBox_)
y@0 164 {
y@0 165 getProcessor()->setParameterNotifyingHost (ADRessAudioProcessor::kHopSizeParam,
y@0 166 (float)hopSizeComboBox_.getSelectedId());
y@0 167 }
y@0 168 else if(comboBox == &windowTypeComboBox_)
y@0 169 {
y@0 170 getProcessor()->setParameterNotifyingHost (ADRessAudioProcessor::kWindowTypeParam,
y@0 171 (float)windowTypeComboBox_.getSelectedId());
y@0 172 }
y@0 173 }
y@0 174
y@0 175 int ADRessAudioProcessorEditor::getBeta()
y@0 176 {
y@0 177 return betaE_;
y@0 178 }