commit f4e01fbc061c7f9403e42bb3f2c92bdd24662cb5
parent fe1ff78de571dec7deb20b85eccd354f3fbd7b57
Author: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Date: Sat, 9 Feb 2019 18:29:41 -0800
Basic GUI
Diffstat:
4 files changed, 100 insertions(+), 50 deletions(-)
diff --git a/Plugin/Source/PluginEditor.cpp b/Plugin/Source/PluginEditor.cpp
@@ -1,15 +1,24 @@
-/*
- ==============================================================================
+#include "PluginProcessor.h"
+#include "PluginEditor.h"
- This file was auto-generated!
+enum
+{
+ width = 375,
+ height = 150,
- It contains the basic framework code for a JUCE plugin editor.
+ nameHeight = 20,
- ==============================================================================
-*/
+ xOffset = 2,
+ yOffset = 5,
-#include "PluginProcessor.h"
-#include "PluginEditor.h"
+ sliderWidth = 110,
+ sliderY = 20,
+
+ overWidth = 65,
+ tapeWidth = 90,
+ boxHeight = 25,
+ boxY = 75,
+};
//==============================================================================
ChowtapeModelAudioProcessorEditor::ChowtapeModelAudioProcessorEditor (ChowtapeModelAudioProcessor& p)
@@ -17,26 +26,69 @@ ChowtapeModelAudioProcessorEditor::ChowtapeModelAudioProcessorEditor (ChowtapeMo
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
- setSize (400, 300);
+ setSize (width, height);
+
+ createSlider (gainInKnob, processor.inGain);
+ createSlider (gainOutKnob, processor.outGain);
+
+ createComboBox (oversampling, processor.overSampling);
+ createComboBox (tapeSpeed, processor.tapeSpeed);
}
ChowtapeModelAudioProcessorEditor::~ChowtapeModelAudioProcessorEditor()
{
}
+void ChowtapeModelAudioProcessorEditor::createSlider(Slider& slide, AudioParameterFloat* param, float step){
+ slide.setName(param->name);
+ slide.setRange(param->range.start, param->range.end, step);
+ slide.setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
+ slide.setColour(Slider::rotarySliderFillColourId, Colours::darkred);
+ slide.setColour(Slider::rotarySliderOutlineColourId, Colours::black);
+ slide.setColour(Slider::thumbColourId, Colours::navajowhite);
+ slide.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
+ slide.setColour(Slider::textBoxTextColourId, Colours::antiquewhite);
+ slide.setColour(Slider::textBoxOutlineColourId, Colours::antiquewhite);
+ slide.setValue(*param);
+ slide.addListener(this);
+
+ addAndMakeVisible (slide);
+}
+
+void ChowtapeModelAudioProcessorEditor::createComboBox (ComboBox& box, AudioParameterChoice* choice)
+{
+ box.setName (choice->name);
+ box.addItemList (choice->getAllValueStrings(), 1);
+ box.setSelectedItemIndex (*choice);
+
+ box.setColour (ComboBox::backgroundColourId, Colours::black);
+ box.setColour (ComboBox::outlineColourId, Colours::saddlebrown);
+ box.setColour (ComboBox::textColourId, Colours::antiquewhite);
+ box.setColour (ComboBox::arrowColourId, Colours::antiquewhite);
+ getLookAndFeel().setColour (PopupMenu::backgroundColourId, Colours::black);
+ getLookAndFeel().setColour (PopupMenu::textColourId, Colours::antiquewhite);
+ getLookAndFeel().setColour (PopupMenu::highlightedBackgroundColourId, Colours::darkgrey);
+
+ box.addListener (this);
+ addAndMakeVisible (box);
+}
+
//==============================================================================
void ChowtapeModelAudioProcessorEditor::paint (Graphics& g)
{
- // (Our component is opaque, so we must completely fill the background with a solid colour)
- g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
+ g.fillAll (Colours::saddlebrown);
- g.setColour (Colours::white);
- g.setFont (15.0f);
- g.drawFittedText ("Hello World!", getLocalBounds(), Justification::centred, 1);
+ g.setColour (Colours::antiquewhite);
+ g.setFont (Font ((float) nameHeight).boldened());
+ g.drawFittedText ("CHOW Tape Model", getLocalBounds().removeFromTop (nameHeight), Justification::centred, 1);
}
void ChowtapeModelAudioProcessorEditor::resized()
{
- // This is generally where you'll want to lay out the positions of any
- // subcomponents in your editor..
+ gainInKnob.setBounds (0, sliderY, sliderWidth, sliderWidth);
+
+ oversampling.setBounds (gainInKnob.getRight(), boxY, overWidth, boxHeight);
+ tapeSpeed.setBounds (oversampling.getRight() + 2 * xOffset, boxY, tapeWidth, boxHeight);
+
+ gainOutKnob.setBounds (tapeSpeed.getRight(), sliderY, sliderWidth, sliderWidth);
}
diff --git a/Plugin/Source/PluginEditor.h b/Plugin/Source/PluginEditor.h
@@ -1,13 +1,3 @@
-/*
- ==============================================================================
-
- This file was auto-generated!
-
- It contains the basic framework code for a JUCE plugin editor.
-
- ==============================================================================
-*/
-
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
@@ -16,7 +6,9 @@
//==============================================================================
/**
*/
-class ChowtapeModelAudioProcessorEditor : public AudioProcessorEditor
+class ChowtapeModelAudioProcessorEditor : public AudioProcessorEditor,
+ public Slider::Listener,
+ public ComboBox::Listener
{
public:
ChowtapeModelAudioProcessorEditor (ChowtapeModelAudioProcessor&);
@@ -26,10 +18,22 @@ public:
void paint (Graphics&) override;
void resized() override;
+ void sliderValueChanged (Slider* slider) override {}
+ void comboBoxChanged (ComboBox* box) override {}
+
private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
ChowtapeModelAudioProcessor& processor;
+ Slider gainInKnob;
+ Slider gainOutKnob;
+
+ ComboBox oversampling;
+ ComboBox tapeSpeed;
+
+ void createSlider(Slider& slide, AudioParameterFloat* param, float step = 0.1f);
+ void createComboBox (ComboBox& box, AudioParameterChoice* choice);
+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChowtapeModelAudioProcessorEditor)
};
diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp
@@ -1,13 +1,3 @@
-/*
- ==============================================================================
-
- This file was auto-generated!
-
- It contains the basic framework code for a JUCE plugin processor.
-
- ==============================================================================
-*/
-
#include "PluginProcessor.h"
#include "PluginEditor.h"
@@ -24,7 +14,17 @@ ChowtapeModelAudioProcessor::ChowtapeModelAudioProcessor()
)
#endif
{
- overSample = new dsp::Oversampling<float> (2, 1, dsp::Oversampling<float>::FilterType::filterHalfBandFIREquiripple);
+ addParameter (inGain = new AudioParameterFloat (String ("inGain"), String ("Input Gain"), -30.0f, 30.0f, 0.0f));
+ addParameter (outGain = new AudioParameterFloat (String ("outGain"), String ("Output Gain"), -30.0f, 30.0f, 0.0f));
+
+ addParameter (overSampling = new AudioParameterChoice (String ("overSampling"), String ("Oversampling"),
+ StringArray ({ "2x", "4x", "8x" }), 0));
+
+ addParameter (tapeSpeed = new AudioParameterChoice (String ("tapeSpeed"), String ("Tape Speed"),
+ StringArray ({ "3.75 ips", "7.5 ips", "15 ips" }), 1));
+
+
+ overSample.reset (new dsp::Oversampling<float> (2, 1, dsp::Oversampling<float>::FilterType::filterHalfBandFIREquiripple));
}
ChowtapeModelAudioProcessor::~ChowtapeModelAudioProcessor()
@@ -157,7 +157,6 @@ void ChowtapeModelAudioProcessor::processBlock (AudioBuffer<float>& buffer, Midi
}
overSample->processSamplesDown(block);
- //osBlock.clear();
}
//==============================================================================
diff --git a/Plugin/Source/PluginProcessor.h b/Plugin/Source/PluginProcessor.h
@@ -1,13 +1,3 @@
-/*
- ==============================================================================
-
- This file was auto-generated!
-
- It contains the basic framework code for a JUCE plugin processor.
-
- ==============================================================================
-*/
-
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
@@ -56,9 +46,14 @@ public:
void getStateInformation (MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
+ AudioParameterFloat* inGain;
+ AudioParameterFloat* outGain;
+ AudioParameterChoice* overSampling;
+ AudioParameterChoice* tapeSpeed;
+
private:
HysteresisProcessor hProcs[2];
- dsp::Oversampling<float>* overSample;
+ std::unique_ptr<dsp::Oversampling<float>> overSample;
int overSamplingFactor = 8;