commit d48a89891f8a5247c62c46143815b650a377870f
parent 53d71b6914525334560bf3d785bd90d422479f61
Author: keith <kbloemer89@gmail.com>
Date: Sun, 30 May 2021 21:45:31 -0500
WIP added osc messaging
Diffstat:
6 files changed, 539 insertions(+), 17 deletions(-)
diff --git a/NeuralPi.jucer b/NeuralPi.jucer
@@ -13,6 +13,8 @@
file="models/ts9_model_best.json"/>
</GROUP>
<GROUP id="{70CE292C-E9C5-C029-B95A-F7DF41E5F74C}" name="Source">
+ <FILE id="VgCJPH" name="AmpOSCReceiver.h" compile="0" resource="0"
+ file="Source/AmpOSCReceiver.h"/>
<FILE id="hNjQV9" name="PluginEditor.cpp" compile="1" resource="0"
file="Source/PluginEditor.cpp"/>
<FILE id="BweFTe" name="PluginEditor.h" compile="0" resource="0" file="Source/PluginEditor.h"/>
diff --git a/Source/AmpOSCReceiver.h b/Source/AmpOSCReceiver.h
@@ -0,0 +1,103 @@
+#include "../JuceLibraryCode/JuceHeader.h"
+
+#pragma once
+
+class AmpOSCReceiver :
+ private OSCReceiver,
+ private OSCReceiver::Listener <OSCReceiver::MessageLoopCallback>
+{
+public:
+ AmpOSCReceiver()
+ {
+ changePort (defaultPort);
+
+ addListener (this);
+ }
+
+ Value& getGainValue()
+ {
+ return gainValue;
+ }
+
+ Value& getMasterValue()
+ {
+ return masterValue;
+ }
+
+ Value& getModelValue()
+ {
+ return modelValue;
+ }
+
+ void changePort (int port)
+ {
+ if (! connect (port))
+ {
+ connected = false;
+ DBG ("Connection Failed");
+ }
+ else
+ {
+ connected = true;
+ DBG("Connection Succeeded");
+ }
+ }
+
+ void updateAmpName (String name)
+ {
+ ampName = name;
+ buildAddressPatterns();
+ }
+
+ bool isConnected()
+ {
+ return connected;
+ }
+
+private:
+ void buildAddressPatterns()
+ {
+ gainAddressPattern = "/parameter/" + ampName + "/Gain";
+ masterAddressPattern = "/parameter/" + ampName + "/Master";
+ modelAddressPattern = "/parameter/" + ampName + "/Model";
+ }
+
+ void oscMessageReceived (const OSCMessage& message) override
+ {
+ DBG ("Message Received: ");
+
+ if (message.size() == 1 && message[0].isFloat32())
+ {
+ DBG (" value " + String (message[0].getFloat32()) + " to AP " + message.getAddressPattern().toString());
+
+ if (message.getAddressPattern().matches(gainAddressPattern))
+ {
+ gainValue.setValue (jlimit (-12.0f, 12.0f, message[0].getFloat32()));
+ }
+ else if (message.getAddressPattern().matches (masterAddressPattern))
+ {
+ masterValue.setValue (jlimit (-48.0f, 0.0f, message[0].getFloat32()));
+ }
+ else if (message.getAddressPattern().matches (modelAddressPattern))
+ {
+ modelValue.setValue (jlimit (0.0f, 1.0f, message[0].getFloat32()));
+ }
+ }
+ }
+
+ int defaultPort {25024};
+
+ String ampName {"NeuralPi"};
+ String gainAddressPattern {"/parameter/elk_juce_example/Gain"};
+ String masterAddressPattern {"/parameter/elk_juce_example/Master"};
+ String modelAddressPattern {"/parameter/elk_juce_example/Model"};
+
+ Value gainValue {0.0f};
+ Value masterValue {0.0f};
+
+ Value modelValue {0.0f};
+
+ bool connected = false;
+
+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AmpOSCReceiver)
+};
diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp
@@ -10,6 +10,7 @@
#include "PluginProcessor.h"
#include "PluginEditor.h"
+#include "AmpOSCReceiver.h"
#include <stdio.h>
#include <fstream>
#include <iostream>
@@ -22,18 +23,45 @@ 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);
+ //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.setRange(0, processor.jsonFiles.size() - 1);
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);
+
+ auto modelValue = getParameterValue(modelName);
+ Slider& modelSlider = getModelSlider();
+ modelSlider.setValue(modelValue, NotificationType::dontSendNotification);
+
+ modelKnob.onValueChange = [this]
+ {
+ const float sliderValue = static_cast<float> (getModelSlider().getValue());
+ const float modelValue = getParameterValue(modelName);
+
+ if (!approximatelyEqual(modelValue, sliderValue))
+ {
+ setParameterValue(modelName, sliderValue);
+
+ // create and send an OSC message with an address and a float value:
+ float value = static_cast<float> (getModelSlider().getValue());
+
+ if (!oscSender.send(modelAddressPattern, value))
+ {
+ updateOutConnectedLabel(false);
+ }
+ else
+ {
+ DBG("Sent value " + String(value) + " to AP " + modelAddressPattern);
+ }
+ }
+ };
addAndMakeVisible(modelSelect);
@@ -52,7 +80,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);
+ //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);
@@ -65,7 +93,34 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
ampGainKnob.setNumDecimalPlacesToDisplay(1);
ampGainKnob.setDoubleClickReturnValue(true, 0.0);
- masterSliderAttach = std::make_unique<AudioProcessorValueTreeState::SliderAttachment>(processor.treeState, MASTER_ID, ampMasterKnob);
+ auto gainValue = getParameterValue(gainName);
+ Slider& gainSlider = getGainSlider();
+ gainSlider.setValue(gainValue, NotificationType::dontSendNotification);
+
+ ampGainKnob.onValueChange = [this]
+ {
+ const float sliderValue = static_cast<float> (getGainSlider().getValue());
+ const float gainValue = getParameterValue(gainName);
+
+ if (!approximatelyEqual(gainValue, sliderValue))
+ {
+ setParameterValue(gainName, sliderValue);
+
+ // create and send an OSC message with an address and a float value:
+ float value = static_cast<float> (getGainSlider().getValue());
+
+ if (!oscSender.send(gainAddressPattern, value))
+ {
+ updateOutConnectedLabel(false);
+ }
+ else
+ {
+ DBG("Sent value " + String(value) + " to AP " + gainAddressPattern);
+ }
+ }
+ };
+
+ //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);
@@ -78,6 +133,33 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
ampMasterKnob.setNumDecimalPlacesToDisplay(1);
ampMasterKnob.setDoubleClickReturnValue(true, -24.0);
+ auto masterValue = getParameterValue(masterName);
+ Slider& masterSlider = getMasterSlider();
+ masterSlider.setValue(masterValue, NotificationType::dontSendNotification);
+
+ ampMasterKnob.onValueChange = [this]
+ {
+ const float sliderValue = static_cast<float> (getMasterSlider().getValue());
+ const float masterValue = getParameterValue(masterName);
+
+ if (!approximatelyEqual(masterValue, sliderValue))
+ {
+ setParameterValue(masterName, sliderValue);
+
+ // create and send an OSC message with an address and a float value:
+ float value = static_cast<float> (getMasterSlider().getValue());
+
+ if (!oscSender.send(masterAddressPattern, value))
+ {
+ updateOutConnectedLabel(false);
+ }
+ else
+ {
+ DBG("Sent value " + String(value) + " to AP " + masterAddressPattern);
+ }
+ }
+ };
+
addAndMakeVisible(GainLabel);
GainLabel.setText("Gain", juce::NotificationType::dontSendNotification);
GainLabel.setJustificationType(juce::Justification::centred);
@@ -90,8 +172,48 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
GainLabel.setFont(font);
LevelLabel.setFont(font);
+
+ // Name controls:
+ addAndMakeVisible(ampNameLabel);
+ ampNameField.setEditable(true, true, true);
+ addAndMakeVisible(ampNameField);
+
+ // IP controls:
+ ipField.setEditable(true, true, true);
+ addAndMakeVisible(ipLabel);
+ addAndMakeVisible(ipField);
+
+ // Port controls:
+ addAndMakeVisible(outPortNumberLabel);
+ outPortNumberField.setEditable(true, true, true);
+ addAndMakeVisible(outPortNumberField);
+ addAndMakeVisible(outConnectedLabel);
+
+ addAndMakeVisible(inPortNumberLabel);
+ inPortNumberField.setEditable(true, true, true);
+ addAndMakeVisible(inPortNumberField);
+ addAndMakeVisible(inConnectedLabel);
+
+
+ // OSC messaging
+
+ getInPortNumberField().addListener(this);
+ getAmpNameField().addListener(this);
+ getOutPortNumberField().addListener(this);
+ getIPField().addListener(this);
+
+ oscReceiver.getGainValue().addListener(this);
+ oscReceiver.getMasterValue().addListener(this);
+
+ oscReceiver.getModelValue().addListener(this);
+
+ updateInConnectedLabel();
+
+ connectSender();
+
+
// Size of plugin GUI
- setSize(250, 200);
+ setSize(250, 350);
}
@@ -121,9 +243,23 @@ void NeuralPiAudioProcessorEditor::resized()
// Amp Widgets
ampGainKnob.setBounds(30, 85, 75, 95);
- ampMasterKnob.setBounds(140, 105, 75, 95);
+ ampMasterKnob.setBounds(140, 120, 75, 95);
GainLabel.setBounds(28, 163, 80, 10);
- LevelLabel.setBounds(138, 163, 80, 10);
+ LevelLabel.setBounds(138, 200, 80, 10);
+
+ addAndMakeVisible(ampNameLabel);
+ ampNameField.setEditable(true, true, true);
+ addAndMakeVisible(ampNameField);
+
+ // IP controls:
+ ipField.setBounds(130, 220, 100, 25);
+ ipLabel.setBounds(15, 220, 100, 25);
+
+ // Port controls:
+ outPortNumberLabel.setBounds(15, 260, 90, 25);
+ outPortNumberField.setBounds(130, 260, 100, 25);
+ inPortNumberLabel.setBounds(15, 300, 90, 25);
+ inPortNumberField.setBounds(130, 300, 100, 25);
}
void NeuralPiAudioProcessorEditor::modelSelectChanged()
@@ -188,6 +324,207 @@ void NeuralPiAudioProcessorEditor::sliderValueChanged(Slider* slider)
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);
+ }
+
+}
+
+// OSC Messages
+
+Slider& NeuralPiAudioProcessorEditor::getGainSlider()
+{
+ return ampGainKnob;
+}
+
+Slider& NeuralPiAudioProcessorEditor::getMasterSlider()
+{
+ return ampMasterKnob;
+}
+
+Slider& NeuralPiAudioProcessorEditor::getModelSlider()
+{
+ return modelKnob;
+}
+
+
+Label& NeuralPiAudioProcessorEditor::getOutPortNumberField()
+{
+ return outPortNumberField;
+}
+
+Label& NeuralPiAudioProcessorEditor::getInPortNumberField()
+{
+ return inPortNumberField;
+}
+
+Label& NeuralPiAudioProcessorEditor::getIPField()
+{
+ return ipField;
+}
+
+Label& NeuralPiAudioProcessorEditor::getAmpNameField()
+{
+ return ampNameField;
+}
+
+Label& NeuralPiAudioProcessorEditor::getOutConnectedLabel()
+{
+ return outConnectedLabel;
+}
+
+Label& NeuralPiAudioProcessorEditor::getInConnectedLabel()
+{
+ return inConnectedLabel;
+}
+
+void NeuralPiAudioProcessorEditor::buildAddressPatterns()
+{
+ gainAddressPattern = "/parameter/" + ampName + "/Gain";
+ masterAddressPattern = "/parameter/" + ampName + "/Master";
+ modelAddressPattern = "/parameter/" + ampName + "/Model";
+}
+
+void NeuralPiAudioProcessorEditor::connectSender()
+{
+ // specify here where to send OSC messages to: host URL and UDP port number
+ if (!oscSender.connect(outgoingIP, outgoingPort))
+ {
+ updateOutConnectedLabel(false);
+ }
+ else
+ {
+ updateOutConnectedLabel(true);
+ }
+}
+
+void NeuralPiAudioProcessorEditor::updateOutgoingIP(String ip)
+{
+ outgoingIP = ip;
+ connectSender();
+}
+
+void NeuralPiAudioProcessorEditor::updateOutgoingPort(int port)
+{
+ outgoingPort = port;
+ connectSender();
+}
+
+void NeuralPiAudioProcessorEditor::labelTextChanged(Label* labelThatHasChanged)
+{
+ if (labelThatHasChanged == &getInPortNumberField())
+ {
+ const int newPort = getInPortNumberField().getTextValue().toString().getIntValue();
+ oscReceiver.changePort(newPort);
+ updateInConnectedLabel();
+ }
+ else if (labelThatHasChanged == &getOutPortNumberField())
+ {
+ const int newPort = getOutPortNumberField().getTextValue().toString().getIntValue();
+ updateOutgoingPort(newPort);
+ }
+ else if (labelThatHasChanged == &getIPField())
+ {
+ const String newIP = getIPField().getTextValue().toString();
+ updateOutgoingIP(newIP);
+ }
+ //else if (labelThatHasChanged == getAmpNameField())
+ //{
+ // ampName = getAmpNameField().getTextValue().toString();
+ // buildAddressPatterns();
+ // oscReceiver.updateAmpName(getAmpNameField().getTextValue().toString());
+ //}
+}
+
+void NeuralPiAudioProcessorEditor::updateInConnectedLabel()
+{
+ const bool connected = oscReceiver.isConnected();
+ if (connected)
+ {
+ getInConnectedLabel().setText("(Connected)", dontSendNotification);
+ }
+ else
+ {
+ getInConnectedLabel().setText("(Disconnected!)", dontSendNotification);
+ }
+}
+
+void NeuralPiAudioProcessorEditor::updateOutConnectedLabel(bool connected)
+{
+ if (connected)
+ {
+ getOutConnectedLabel().setText("(Connected)", dontSendNotification);
+ }
+ else
+ {
+ getOutConnectedLabel().setText("(Disconnected!)", dontSendNotification);
+ }
+}
+
+// This callback is invoked if an OSC message has been received setting either value.
+void NeuralPiAudioProcessorEditor::valueChanged(Value& value)
+{
+ if (value.refersToSameSourceAs(oscReceiver.getGainValue()))
+ {
+ if (!approximatelyEqual(static_cast<double> (value.getValue()), getGainSlider().getValue()))
+ {
+ getGainSlider().setValue(static_cast<double> (value.getValue()),
+ NotificationType::sendNotification);
}
- modelSelect.setSelectedItemIndex(slider->getValue(), juce::NotificationType::dontSendNotification);
+ }
+ else if (value.refersToSameSourceAs(oscReceiver.getMasterValue()))
+ {
+ if (!approximatelyEqual(static_cast<double> (value.getValue()), getMasterSlider().getValue()))
+ {
+ getMasterSlider().setValue(static_cast<double> (value.getValue()),
+ NotificationType::sendNotification);
+ }
+ }
+ else if (value.refersToSameSourceAs(oscReceiver.getModelValue()))
+ {
+ if (!approximatelyEqual(static_cast<double> (value.getValue()), getModelSlider().getValue()))
+ {
+ getModelSlider().setValue(static_cast<double> (value.getValue()),
+ NotificationType::sendNotification);
+ }
+ }
+}
+
+void NeuralPiAudioProcessorEditor::timerCallback()
+{
+ getGainSlider().setValue(getParameterValue(gainName), NotificationType::dontSendNotification);
+ getMasterSlider().setValue(getParameterValue(masterName), NotificationType::dontSendNotification);
+ getModelSlider().setValue(getParameterValue(modelName), NotificationType::dontSendNotification);
+}
+
+AudioProcessorParameter* NeuralPiAudioProcessorEditor::getParameter(const String& paramId)
+{
+ if (auto* proc = getAudioProcessor())
+ {
+ auto& params = proc->getParameters();
+
+ for (auto p : params)
+ {
+ if (auto* param = dynamic_cast<AudioProcessorParameterWithID*> (p))
+ {
+ if (param->paramID == paramId)
+ return param;
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+float NeuralPiAudioProcessorEditor::getParameterValue(const String& paramId)
+{
+ if (auto* param = getParameter(paramId))
+ return param->getValue();
+
+ return 0.0f;
+}
+
+void NeuralPiAudioProcessorEditor::setParameterValue(const String& paramId, float value)
+{
+ if (auto* param = getParameter(paramId))
+ param->setValueNotifyingHost(value);
}
\ No newline at end of file
diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h
@@ -12,6 +12,7 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "PluginProcessor.h"
+#include "AmpOSCReceiver.h"
//#include "myLookAndFeel.h"
#include <stdlib.h>
@@ -19,8 +20,11 @@
/**
*/
class NeuralPiAudioProcessorEditor : public AudioProcessorEditor,
- private Button::Listener,
- private Slider::Listener
+ private Button::Listener,
+ private Slider::Listener,
+ private Value::Listener,
+ private Label::Listener,
+ private Timer
{
public:
@@ -31,6 +35,23 @@ public:
void paint (Graphics&) override;
void resized() override;
+ AmpOSCReceiver oscReceiver;
+ OSCSender oscSender;
+
+ String outgoingIP{ "127.0.0.1" };
+ int outgoingPort{ 24024 };
+ int incomingPort{ 25024 };
+
+ String ampName{ "NeuralPi" };
+ String gainAddressPattern{ "/parameter/NeuralPi/Gain" };
+ String masterAddressPattern{ "/parameter/NeuralPi/Master" };
+ String modelAddressPattern{ "/parameter/NeuralPi/Model" };
+
+ const String gainName{ "gain" };
+ const String masterName{ "master" };
+
+ const String modelName{ "model" };
+
private:
// This reference is provided as a quick way for your editor to
@@ -57,10 +78,58 @@ private:
void loadButtonClicked();
virtual void sliderValueChanged(Slider* slider) override;
+
+ Label ampNameLabel{ {}, "Amp Name (no spaces): " };
+ Label ampNameField{ {}, "NeuralPi" };
+
+ Label ipLabel{ {}, "Target IP Address: " };
+ Label ipField{ {}, "127.0.0.1" };
+
+ Label outPortNumberLabel{ {}, "Outgoing OSC Port: " };
+ Label outPortNumberField{ {}, "24024" };
+
+ Label inPortNumberLabel{ {}, "Incoming OSC Port: " };
+ Label inPortNumberField{ {}, "25024" };
+
+ Label gainLabel{ {}, "Gain" };
+ Label masterLabel{ {}, "Master" };
+
+ Label modelLabel{ {}, "Model" };
+
+ Label inConnectedLabel{ "(connected)" };
+ Label outConnectedLabel{ "(connected)" };
+
+ // OSC Messages
+
+ Slider& getGainSlider();
+ Slider& getMasterSlider();
+ Slider& getModelSlider();
+ Label& getOutPortNumberField();
+ Label& getInPortNumberField();
+ Label& getIPField();
+ Label& getAmpNameField();
+ Label& getOutConnectedLabel();
+ Label& getInConnectedLabel();
+ void buildAddressPatterns();
+ void connectSender();
+ void updateOutgoingIP(String ip);
+ void updateOutgoingPort(int port);
+ void labelTextChanged(Label* labelThatHasChanged) override;
+ void updateInConnectedLabel();
+ void updateOutConnectedLabel(bool connected);
+ // This callback is invoked if an OSC message has been received setting either value.
+ void valueChanged(Value& value) override;
+ void timerCallback() override;
+
+ AudioProcessorParameter* getParameter(const String& paramId);
+
+ float getParameterValue(const String& paramId);
+ void setParameterValue(const String& paramId, float value);
+/*
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,10 +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) })
+ )//,
+ //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
{
@@ -36,7 +36,12 @@ 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));
+ // initialize parameters:
+ addParameter(gainParam = new AudioParameterFloat(GAIN_ID, GAIN_NAME, NormalisableRange<float>(-12.0f, 12.0f, 0.01f), 0.0f));
+ addParameter(masterParam = new AudioParameterFloat(MASTER_ID, MASTER_NAME, NormalisableRange<float>(-48.0f, 0.0f, 0.01f), 0.0f));
+ addParameter(modelParam = new AudioParameterFloat(MODEL_ID, MODEL_NAME, NormalisableRange<float>(0, jsonFiles.size()-1, 1), 0));
+
+ //treeState.createAndAddParameter(std::make_unique<AudioParameterFloat>(MODEL_ID, MODEL_NAME, NormalisableRange<float>(0, jsonFiles.size() - 1, 1), 0));
}
diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h
@@ -10,6 +10,7 @@
#include <nlohmann/json.hpp>
#include "RTNeuralLSTM.h"
+#include "AmpOSCReceiver.h"
#pragma once
@@ -101,7 +102,7 @@ public:
RT_LSTM LSTM;
- AudioProcessorValueTreeState treeState;
+ //AudioProcessorValueTreeState treeState;
private:
@@ -111,6 +112,11 @@ private:
var dummyVar;
+ AudioParameterFloat* gainParam;
+ AudioParameterFloat* masterParam;
+
+ AudioParameterFloat* modelParam;
+
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralPiAudioProcessor)
};