commit 53d71b6914525334560bf3d785bd90d422479f61
parent e1fa5a03f304265ae7ee2b65b90b29a33fa671b4
Author: keith <[email protected]>
Date: Sun, 30 May 2021 07:06:36 -0500
WIP Added automation parameters
Diffstat:
5 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/NeuralPi.jucer b/NeuralPi.jucer
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<JUCERPROJECT name="NeuralPi" companyName="GuitarML" version="1.0.0" companyWebsite="http://juce.com"
+<JUCERPROJECT name="NeuralPi" companyName="GuitarML" version="1.0.0" companyWebsite="https://guitarml.com"
defines="PIP_JUCE_EXAMPLES_DIRECTORY=L2hvbWUvaWxpYXMvd29ya3NwYWNlcy9KVUNFL2V4YW1wbGVz"
- projectType="audioplug" pluginManufacturer="JUCE" pluginAUIsSandboxSafe="1"
+ projectType="audioplug" pluginManufacturer="GuitarML" pluginAUIsSandboxSafe="1"
pluginFormats="buildStandalone,buildVST3" id="vXK47v" jucerFormatVersion="1"
displaySplashScreen="1">
<MAINGROUP id="zI9r2C" name="NeuralPi">
diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp
@@ -22,6 +22,20 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to
+ modelSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, MODEL_ID, modelKnob);
+ addAndMakeVisible(modelKnob);
+ //ampGainKnob.setLookAndFeel(&SilverKnobLAF);
+ modelKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::TextBoxBelow, false, 50, 20);
+ modelKnob.setNumDecimalPlacesToDisplay(1);
+ modelKnob.addListener(this);
+ //modelKnob.setRange(-12.0, 12.0);
+ modelKnob.setValue(processor.current_model_index);
+ modelKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
+ modelKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
+ modelKnob.setNumDecimalPlacesToDisplay(1);
+ modelKnob.setDoubleClickReturnValue(true, 0.0);
+
+
addAndMakeVisible(modelSelect);
modelSelect.setColour(juce::Label::textColourId, juce::Colours::black);
int c = 1;
@@ -38,6 +52,7 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
loadButton.setColour(juce::Label::textColourId, juce::Colours::black);
loadButton.addListener(this);
+ gainSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, GAIN_ID, ampGainKnob);
addAndMakeVisible(ampGainKnob);
//ampGainKnob.setLookAndFeel(&SilverKnobLAF);
ampGainKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::TextBoxBelow, false, 50, 20);
@@ -50,6 +65,7 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
ampGainKnob.setNumDecimalPlacesToDisplay(1);
ampGainKnob.setDoubleClickReturnValue(true, 0.0);
+ masterSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, MASTER_ID, ampMasterKnob);
addAndMakeVisible(ampMasterKnob);
//ampMasterKnob.setLookAndFeel(&SilverKnobLAF);
ampMasterKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::TextBoxBelow, false, 50, 20);
@@ -101,10 +117,11 @@ void NeuralPiAudioProcessorEditor::resized()
// subcomponents in your editor..
modelSelect.setBounds(15, 10, 210, 25);
loadButton.setBounds(15, 42, 100, 25);
+ modelKnob.setBounds(140, 40, 75, 95);
// Amp Widgets
ampGainKnob.setBounds(30, 85, 75, 95);
- ampMasterKnob.setBounds(140, 85, 75, 95);
+ ampMasterKnob.setBounds(140, 105, 75, 95);
GainLabel.setBounds(28, 163, 80, 10);
LevelLabel.setBounds(138, 163, 80, 10);
}
@@ -116,6 +133,7 @@ void NeuralPiAudioProcessorEditor::modelSelectChanged()
processor.loadConfig(processor.jsonFiles[selectedFileIndex]);
processor.current_model_index = modelSelect.getSelectedItemIndex();
}
+ modelKnob.setValue(processor.current_model_index);
}
void NeuralPiAudioProcessorEditor::loadButtonClicked()
@@ -166,4 +184,10 @@ void NeuralPiAudioProcessorEditor::sliderValueChanged(Slider* slider)
processor.set_ampDrive(slider->getValue());
else if (slider == &MasterKnob)
processor.set_ampMaster(slider->getValue());
+ else if (slider == &modelKnob)
+ if (slider->getValue() >= 0 && slider->getValue() < processor.jsonFiles.size()) {
+ processor.loadConfig(processor.jsonFiles[slider->getValue()]);
+ processor.current_model_index = modelSelect.getSelectedItemIndex();
+ }
+ modelSelect.setSelectedItemIndex(slider->getValue(), juce::NotificationType::dontSendNotification);
}
\ No newline at end of file
diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h
@@ -40,6 +40,7 @@ private:
// Amp Widgets
Slider ampGainKnob;
Slider ampMasterKnob;
+ Slider modelKnob;
//ImageButton ampOnButton;
//ImageButton ampLED;
ComboBox modelSelect;
@@ -56,5 +57,10 @@ private:
void loadButtonClicked();
virtual void sliderValueChanged(Slider* slider) override;
+public:
+ std::unique_ptr <AudioProcessorValueTreeState::SliderAttachment> gainSliderAttach;
+ std::unique_ptr <AudioProcessorValueTreeState::SliderAttachment> modelSliderAttach;
+ std::unique_ptr <AudioProcessorValueTreeState::SliderAttachment> masterSliderAttach;
+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralPiAudioProcessorEditor)
};
diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp
@@ -23,7 +23,10 @@ NeuralPiAudioProcessor::NeuralPiAudioProcessor()
#endif
.withOutput("Output", AudioChannelSet::stereo(), true)
#endif
- )
+ ),
+ treeState(*this, nullptr, "PARAMETER", { std::make_unique<AudioParameterFloat>(GAIN_ID, GAIN_NAME, NormalisableRange<float>(-10.0f, 10.0f, 0.01f), 0.0f),
+ //std::make_unique<AudioParameterFloat>(MODEL_ID, MODEL_NAME, NormalisableRange<float>(0, 1, 1), 0),
+ std::make_unique<AudioParameterFloat>(MASTER_ID, MASTER_NAME, NormalisableRange<float>(-36.0f, 0.0f, 0.01f), 0.0f) })
#endif
{
@@ -33,8 +36,11 @@ NeuralPiAudioProcessor::NeuralPiAudioProcessor()
if (jsonFiles.size() > 0) {
loadConfig(jsonFiles[current_model_index]);
}
+ treeState.createAndAddParameter(std::make_unique<AudioParameterFloat>(MODEL_ID, MODEL_NAME, NormalisableRange<float>(0, jsonFiles.size() - 1, 1), 0));
+
}
+
NeuralPiAudioProcessor::~NeuralPiAudioProcessor()
{
}
@@ -317,7 +323,6 @@ void NeuralPiAudioProcessor::set_ampMaster(float db_ampMaster)
}
}
-
float NeuralPiAudioProcessor::decibelToLinear(float dbValue)
{
return powf(10.0, dbValue/20.0);
diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h
@@ -14,7 +14,13 @@
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
-// USE_RTNEURAL 1
+
+#define GAIN_ID "gain"
+#define GAIN_NAME "Gain"
+#define MODEL_ID "model"
+#define MODEL_NAME "Model"
+#define MASTER_ID "master"
+#define MASTER_NAME "Master"
//==============================================================================
/**
@@ -95,6 +101,9 @@ public:
RT_LSTM LSTM;
+ AudioProcessorValueTreeState treeState;
+
+
private:
// Amp
float ampDrive = 1.0;