Skip to content

Commit

Permalink
kg - added some gui objects, still in progress; wave selection is sti…
Browse files Browse the repository at this point in the history
…ll buggy
  • Loading branch information
kgusdorf committed Feb 12, 2020
1 parent 7c74c07 commit e222834
Show file tree
Hide file tree
Showing 31 changed files with 644 additions and 554 deletions.
64 changes: 0 additions & 64 deletions fmSynth/Source/Main.cpp

This file was deleted.

101 changes: 71 additions & 30 deletions fmSynth/Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,96 @@
#include "PluginEditor.h"

//==============================================================================
BasicPluginAudioProcessorEditor::BasicPluginAudioProcessorEditor (BasicPluginAudioProcessor& p)
FmSynthAudioProcessorEditor::FmSynthAudioProcessorEditor (FmSynthAudioProcessor& p)
: AudioProcessorEditor (&p), processor (p)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (200, 200);

// these define the parameters of our slider object
midiVolume.setSliderStyle(Slider::LinearBarVertical);
midiVolume.setRange(0.0, 127.0, 1.0);
midiVolume.setTextBoxStyle(Slider::NoTextBox, false, 90, 0);
midiVolume.setPopupDisplayEnabled(true, false, this);
midiVolume.setTextValueSuffix(" Volume");
midiVolume.setValue(1.0);
setSize (700, 400);

// this function adds the slider to the editor
addAndMakeVisible(&midiVolume);
cutoffSlider.setSliderStyle(Slider::LinearBarVertical);
cutoffSlider.setRange(0.1, 1000.0, 1.0);
cutoffSlider.setTextBoxStyle(Slider::NoTextBox, false, 90, 0);
cutoffSlider.setPopupDisplayEnabled(true, false, this);
cutoffSlider.setValue(1.0);

addAndMakeVisible(cutoffSlider);
cutoffSlider.addListener(this);

volumeSlider.setSliderStyle(Slider::LinearBarVertical);
volumeSlider.setRange(0.1, 1000.0, 1.0);
volumeSlider.setTextBoxStyle(Slider::NoTextBox, false, 90, 0);
volumeSlider.setPopupDisplayEnabled(true, false, this);
volumeSlider.setValue(1.0);

addAndMakeVisible(volumeSlider);
volumeSlider.addListener(this);

dial1.setSliderStyle(Slider::Rotary);
dial1.setTextBoxStyle(Slider::TextBoxBelow, true, 90, 25);

addAndMakeVisible(dial1);
dial1.addListener(this);

addAndMakeVisible(carWaveSelect);

carWaveSelect.addItem("Sine", 1);
carWaveSelect.addItem("Square", 2);
carWaveSelect.addItem("Saw", 3);

carWaveSelect.onChange = [this] { WaveSelectChanged(); };
//waveSelect.setSelectedId(1);

addAndMakeVisible(modWaveSelect);

modWaveSelect.addItem("Sine", 1);
modWaveSelect.addItem("Square", 2);
modWaveSelect.addItem("Saw", 3);

midiVolume.addListener(this);
}

BasicPluginAudioProcessorEditor::~BasicPluginAudioProcessorEditor()
FmSynthAudioProcessorEditor::~FmSynthAudioProcessorEditor()
{
}

//==============================================================================
void BasicPluginAudioProcessorEditor::paint (Graphics& g)
void FmSynthAudioProcessorEditor::sliderValueChanged(Slider* slider)
{
// fill the whole window white
g.fillAll(Colours::white);
}

// set the current drawing colour to black
g.setColour(Colours::black);
void FmSynthAudioProcessorEditor::WaveSelectChanged() {
switch (carWaveSelect.getSelectedId()) {
case 1: processor.synth.addVoice<SineVoice, SineSound>(12); break;
case 2: processor.synth.addVoice<SquareVoice, SquareSound>(12); break;
}
}

// set the font size and draw text to the screen
g.setFont(15.0f);
//==============================================================================
void FmSynthAudioProcessorEditor::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.drawFittedText("Midi Volume", 0, 0, getWidth(), 30, Justification::centred, 1);
g.setColour (Colours::white);
g.setFont (18.0f);

g.drawFittedText("Filter Cutoff", 480, 20, getWidth(), 30, Justification::left, 1);
g.drawFittedText("Volume", 600, 20, getWidth(), 30, Justification::left, 1);
g.drawFittedText("Modulator", 50, 20, getWidth(), 30, Justification::left, 1);
g.drawFittedText("Carrier", 300, 20, getWidth(), 30, Justification::left, 1);
}

void BasicPluginAudioProcessorEditor::resized()
void FmSynthAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..

midiVolume.setBounds(40, 30, 20, getHeight() - 60);
const int border = 20;
const int dialWidth = getWidth() / 1.7 - border;
const int dialHeight = getHeight() / 1.7 - border - 100;

cutoffSlider.setBounds(520, 50, 20, 300);
volumeSlider.setBounds(620, 50, 20, 300);
dial1.setBounds(border, 250, dialWidth, dialHeight);
modWaveSelect.setBounds(50, 70, 100, 20);
carWaveSelect.setBounds(200, 70, 100, 20);
}

void BasicPluginAudioProcessorEditor::sliderValueChanged(Slider* slider)
{
processor.noteOnVel = midiVolume.getValue();
}
25 changes: 17 additions & 8 deletions fmSynth/Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,33 @@
//==============================================================================
/**
*/
class BasicPluginAudioProcessorEditor : public AudioProcessorEditor, private Slider::Listener
class FmSynthAudioProcessorEditor : public AudioProcessorEditor,
private Slider::Listener
{
public:
BasicPluginAudioProcessorEditor (BasicPluginAudioProcessor&);
~BasicPluginAudioProcessorEditor();
FmSynthAudioProcessorEditor (FmSynthAudioProcessor&);
~FmSynthAudioProcessorEditor();

//==============================================================================
void paint (Graphics&) override;
void resized() override;

private:

void sliderValueChanged(Slider* slider) override;

void WaveSelectChanged();

// This reference is provided as a quick way for your editor to
// access the processor object that created it.
BasicPluginAudioProcessor& processor;

Slider midiVolume;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BasicPluginAudioProcessorEditor)
FmSynthAudioProcessor& processor;
Slider cutoffSlider;
Slider volumeSlider;
Slider dial1;
Slider dial2;

Label textLabel;
ComboBox modWaveSelect;
ComboBox carWaveSelect;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FmSynthAudioProcessorEditor)
};
Loading

0 comments on commit e222834

Please sign in to comment.