From 439d67ee85dc1675a01d557d712eaa7a0d43a2ef Mon Sep 17 00:00:00 2001 From: Takeshi Yokemura Date: Mon, 17 May 2021 09:33:28 +0900 Subject: [PATCH] Arpeggio parameters UI --- Source/MonophonicComponent.cpp | 66 +++++++++++++++++++++++++++++----- Source/MonophonicComponent.h | 8 ++++- Source/PluginEditor.cpp | 7 ++++ Source/PluginEditor.h | 2 ++ Source/PluginProcessor.cpp | 2 +- 5 files changed, 75 insertions(+), 10 deletions(-) diff --git a/Source/MonophonicComponent.cpp b/Source/MonophonicComponent.cpp index ed91e88..3f63dab 100644 --- a/Source/MonophonicComponent.cpp +++ b/Source/MonophonicComponent.cpp @@ -27,27 +27,62 @@ //[/MiscUserDefs] //============================================================================== -MonophonicComponent::MonophonicComponent () +MonophonicComponent::MonophonicComponent (Magical8bitPlug2AudioProcessor& p) { //[Constructor_pre] You can add your own custom stuff here.. //[/Constructor_pre] + label.reset (new juce::Label ("label", + TRANS("Monophonic Options"))); + addAndMakeVisible (label.get()); + label->setFont (juce::Font (17.00f, juce::Font::plain).withTypefaceStyle ("Regular")); + label->setJustificationType (juce::Justification::centredLeft); + label->setEditable (false, false, false); + label->setColour (juce::TextEditor::textColourId, juce::Colours::black); + label->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); + + label->setBounds (0, 4, 150, 22); + + behaviorChoice.reset (new ChoiceComponent (p, "monophonicBehavior", "Behavior")); + addAndMakeVisible (behaviorChoice.get()); + behaviorChoice->setName ("behavior selector"); + + behaviorChoice->setBounds (0, 28, 224, 26); + + intervalChoice.reset (new ChoiceComponent (p, "arpeggioIntervalType", "Interval")); + addAndMakeVisible (intervalChoice.get()); + intervalChoice->setName ("interval selector"); + + intervalChoice->setBounds (228, 28, 185, 28); + + intervalSlider.reset (new juce::Slider ("interval slider")); + addAndMakeVisible (intervalSlider.get()); + intervalSlider->setRange (0, 10, 0.01); + intervalSlider->setSliderStyle (juce::Slider::LinearHorizontal); + intervalSlider->setTextBoxStyle (juce::Slider::TextBoxRight, false, 50, 20); + //[UserPreSize] //[/UserPreSize] - setSize (640, 400); + setSize (640, 82); //[Constructor] You can add your own custom stuff here.. + attc.reset (new SliderAttachment (p.parameters, "arpeggioIntervalSliderValue", *intervalSlider)); //[/Constructor] } MonophonicComponent::~MonophonicComponent() { //[Destructor_pre]. You can add your own custom destruction code here.. + attc.reset(); //[/Destructor_pre] + label = nullptr; + behaviorChoice = nullptr; + intervalChoice = nullptr; + intervalSlider = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -60,8 +95,6 @@ void MonophonicComponent::paint (juce::Graphics& g) //[UserPrePaint] Add your own custom painting code here.. //[/UserPrePaint] - g.fillAll (juce::Colour (0xff323e44)); - //[UserPaint] Add your own custom painting code here.. //[/UserPaint] } @@ -71,6 +104,7 @@ void MonophonicComponent::resized() //[UserPreResize] Add your own custom resize code here.. //[/UserPreResize] + intervalSlider->setBounds (getWidth() - (getWidth() - 420), 28, getWidth() - 420, 24); //[UserResized] Add your own custom resize handling here.. //[/UserResized] } @@ -91,10 +125,26 @@ void MonophonicComponent::resized() BEGIN_JUCER_METADATA - + parentClasses="public juce::Component" constructorParams="Magical8bitPlug2AudioProcessor& p" + variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1" + overlayOpacity="0.330" fixedSize="1" initialWidth="640" initialHeight="82"> + + END_JUCER_METADATA diff --git a/Source/MonophonicComponent.h b/Source/MonophonicComponent.h index f6a8c96..228c8fe 100644 --- a/Source/MonophonicComponent.h +++ b/Source/MonophonicComponent.h @@ -21,6 +21,7 @@ //[Headers] -- You can add your own extra header files here -- #include +#include "ChoiceComponent.h" //[/Headers] @@ -37,7 +38,7 @@ class MonophonicComponent : public juce::Component { public: //============================================================================== - MonophonicComponent (); + MonophonicComponent (Magical8bitPlug2AudioProcessor& p); ~MonophonicComponent() override; //============================================================================== @@ -51,9 +52,14 @@ public: private: //[UserVariables] -- You can add your own custom variables in this section. + std::unique_ptr attc; //[/UserVariables] //============================================================================== + std::unique_ptr label; + std::unique_ptr behaviorChoice; + std::unique_ptr intervalChoice; + std::unique_ptr intervalSlider; //============================================================================== diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index d3c12c1..dfc759e 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -11,6 +11,7 @@ #include "PluginProcessor.h" #include "PluginEditor.h" #include "AdvancedParamsComponent.h" +#include "MonophonicComponent.h" #include "PulseParamsComponent.h" #include "BasicParamsComponent.h" #include "EnvelopeParamsComponent.h" @@ -31,6 +32,9 @@ Magical8bitPlug2AudioProcessorEditor::Magical8bitPlug2AudioProcessorEditor (Magi basicCompo.reset (new BasicParamsComponent (p, *this)); addAndMakeVisible (basicCompo.get()); + + monoCompo.reset (new MonophonicComponent (p)); + addAndMakeVisible(monoCompo.get()); envCompo.reset (new EnvelopeParamsComponent (p)); addAndMakeVisible (envCompo.get()); @@ -211,6 +215,7 @@ void Magical8bitPlug2AudioProcessorEditor::resized() // Monophonic // if (processor.settingRefs.isMonophonic()) { + monoCompo->setBounds(x, y, sizes.fullComponentWidth, sizes.monoCompoHeight); y += sizes.monoCompoHeight; } @@ -270,6 +275,8 @@ void Magical8bitPlug2AudioProcessorEditor::resized() noiCompo->setVisible (false); break; } + + monoCompo->setVisible(processor.settingRefs.isMonophonic()); // // Enable/Disable diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 6344145..1677ceb 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -13,6 +13,7 @@ #include "../JuceLibraryCode/JuceHeader.h" #include "PluginProcessor.h" class AdvancedParamsComponent; +class MonophonicComponent; class PulseParamsComponent; class BasicParamsComponent; class EnvelopeParamsComponent; @@ -44,6 +45,7 @@ private: Magical8bitPlug2AudioProcessor& processor; std::unique_ptr basicCompo; + std::unique_ptr monoCompo; std::unique_ptr envCompo; std::unique_ptr advCompo; std::unique_ptr pulCompo; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 9ebd447..904e29e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -68,7 +68,7 @@ Magical8bitPlug2AudioProcessor::Magical8bitPlug2AudioProcessor() // Monophonic // std::make_unique ("monophonicBehavior", "Behavior", StringArray ({"Legato", "Arpeggio Up", "Arpeggio Down", "Non-legato"}), 0), - std::make_unique ("arpeggioIntervalType", "Interval", StringArray ({"1frame", "2frames", "3frames", "96th", "64th", "48th", "32th", "24th", "Slider"}), 0), + std::make_unique ("arpeggioIntervalType", "Interval", StringArray ({"1 frame", "2 frames", "3 frames", "96th", "64th", "48th", "32th", "24th", "Slider"}), 0), std::make_unique ("arpeggioIntervalSliderValue", //ID "Interval", //name NormalisableRange (0.001f, //min