commit 575a04b5984f9808089903174b8c6235cde63471
parent a4f39c3de0d491f403258cbba0bafaeb502978ba
Author: keith <kbloemer89@gmail.com>
Date: Mon, 14 Jun 2021 17:15:12 -0500
Updated model select
Diffstat:
5 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/NeuralPi.jucer b/NeuralPi.jucer
@@ -70,7 +70,8 @@
</LINUX_MAKE>
<VS2019 targetFolder="Builds/VisualStudio2019">
<CONFIGURATIONS>
- <CONFIGURATION isDebug="1" name="Debug" targetName="NeuralPi"/>
+ <CONFIGURATION isDebug="1" name="Debug" targetName="NeuralPi" headerPath="C:\Users\rache\Desktop\dev\json-develop\include C:\Users\rache\Desktop\dev\NeuralPi\modules\RTNeural C:\Users\rache\Desktop\dev\NeuralPi\modules\RTNeural\modules\xsimd\include"
+ defines="USE_XSIMD=1"/>
<CONFIGURATION isDebug="0" name="Release" targetName="NeuralPi" headerPath="C:\Users\rache\Desktop\dev\json-develop\include C:\Users\rache\Desktop\dev\NeuralPi\modules\RTNeural C:\Users\rache\Desktop\dev\NeuralPi\modules\RTNeural\modules\xsimd\include"
defines="USE_XSIMD=1"/>
</CONFIGURATIONS>
diff --git a/Source/AmpOSCReceiver.h b/Source/AmpOSCReceiver.h
@@ -78,17 +78,11 @@ private:
{
masterValue.setValue(jlimit(0.0f, 1.0f, message[0].getFloat32()));
}
-
- }
- else if (message.size() == 1 && message[0].isInt32())
- {
- DBG(" value " + String(message[0].getInt32()) + " to AP " + message.getAddressPattern().toString());
-
- if (message.getAddressPattern().matches(modelAddressPattern))
+ else if (message.getAddressPattern().matches(modelAddressPattern))
{
- //modelValue.setValue(jlimit(0.0f, 1.0f, message[0].getFloat32()));
- modelValue.setValue(message[0].getInt32());
+ modelValue.setValue(jlimit(0.0f, 1.0f, message[0].getFloat32()));
}
+
}
}
diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp
@@ -23,17 +23,18 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to
- addAndMakeVisible(modelKnob);
+ //addAndMakeVisible(modelKnob);
//ampGainKnob.setLookAndFeel(&SilverKnobLAF);
modelKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::TextBoxBelow, false, 50, 20);
modelKnob.setNumDecimalPlacesToDisplay(1);
modelKnob.addListener(this);
- modelKnob.setRange(0, processor.jsonFiles.size() - 1);
- modelKnob.setValue(processor.current_model_index);
+ //modelKnob.setRange(0, processor.jsonFiles.size() - 1);
+ modelKnob.setRange(0.0, 1.0);
+ modelKnob.setValue(0.0);
modelKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
modelKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20);
modelKnob.setNumDecimalPlacesToDisplay(1);
- modelKnob.setDoubleClickReturnValue(true, 0);
+ modelKnob.setDoubleClickReturnValue(true, 0.0);
auto modelValue = getParameterValue(modelName);
Slider& modelSlider = getModelSlider();
@@ -41,15 +42,15 @@ NeuralPiAudioProcessorEditor::NeuralPiAudioProcessorEditor (NeuralPiAudioProcess
modelKnob.onValueChange = [this]
{
- const int sliderValue = static_cast<int> (getModelSlider().getValue());
- const int modelValue = getParameterValue(modelName);
+ 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:
- int value = static_cast<int> (getModelSlider().getValue());
+ float value = static_cast<float> (getModelSlider().getValue());
if (!oscSender.send(modelAddressPattern, value))
{
@@ -235,23 +236,23 @@ void NeuralPiAudioProcessorEditor::resized()
// Amp Widgets
ampGainKnob.setBounds(30, 85, 75, 95);
- ampMasterKnob.setBounds(140, 120, 75, 95);
+ ampMasterKnob.setBounds(140, 85, 75, 95);
GainLabel.setBounds(28, 163, 80, 10);
- LevelLabel.setBounds(138, 200, 80, 10);
+ LevelLabel.setBounds(138, 163, 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);
+ ipField.setBounds(150, 220, 100, 25);
+ ipLabel.setBounds(15, 220, 150, 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);
+ outPortNumberLabel.setBounds(15, 260, 150, 25);
+ outPortNumberField.setBounds(160, 260, 75, 25);
+ inPortNumberLabel.setBounds(15, 300, 150, 25);
+ inPortNumberField.setBounds(160, 300, 75, 25);
}
void NeuralPiAudioProcessorEditor::modelSelectChanged()
@@ -261,7 +262,9 @@ void NeuralPiAudioProcessorEditor::modelSelectChanged()
processor.loadConfig(processor.jsonFiles[selectedFileIndex]);
processor.current_model_index = modelSelect.getSelectedItemIndex();
}
- modelKnob.setValue(processor.current_model_index);
+ auto newValue = static_cast<float>(processor.current_model_index / (processor.num_models - 1.0));
+ modelKnob.setValue(newValue);
+ //modelKnob.setValue(processor.current_model_index);
}
void NeuralPiAudioProcessorEditor::loadButtonClicked()
@@ -290,7 +293,10 @@ void NeuralPiAudioProcessorEditor::loadButtonClicked()
modelSelect.addItem(file.getFileNameWithoutExtension(), processor.jsonFiles.size() + 1);
modelSelect.setSelectedItemIndex(processor.jsonFiles.size(), juce::NotificationType::dontSendNotification);
processor.jsonFiles.push_back(file);
+ //processor.num_models += 1;
}
+ // Sort jsonFiles alphabetically
+ std::sort(processor.jsonFiles.begin(), processor.jsonFiles.end());
}
}
}
@@ -309,9 +315,7 @@ void NeuralPiAudioProcessorEditor::sliderValueChanged(Slider* slider)
{
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);
+ modelSelect.setSelectedItemIndex(processor.getModelIndex(slider->getValue()), juce::NotificationType::dontSendNotification);
}
}
diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp
@@ -33,10 +33,14 @@ NeuralPiAudioProcessor::NeuralPiAudioProcessor()
if (jsonFiles.size() > 0) {
loadConfig(jsonFiles[current_model_index]);
}
+
+ // Sort jsonFiles alphabetically
+ std::sort(jsonFiles.begin(), jsonFiles.end());
+
// initialize parameters:
- addParameter(gainParam = new AudioParameterFloat(GAIN_ID, GAIN_NAME, NormalisableRange<float>(-0.0f, 1.0f, 0.01f), 0.5f));
+ addParameter(gainParam = new AudioParameterFloat(GAIN_ID, GAIN_NAME, NormalisableRange<float>(0.0f, 1.0f, 0.01f), 0.5f));
addParameter(masterParam = new AudioParameterFloat(MASTER_ID, MASTER_NAME, NormalisableRange<float>(0.0f, 1.0f, 0.01f), 0.5f));
- addParameter(modelParam = new AudioParameterInt(MODEL_ID, MODEL_NAME, 0, jsonFiles.size()-1, 0));
+ addParameter(modelParam = new AudioParameterFloat(MODEL_ID, MODEL_NAME, NormalisableRange<float>(0.0f, 1.0f, 0.001f), 0.0f));
}
@@ -157,7 +161,8 @@ void NeuralPiAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffe
if (amp_state == 1) {
auto gain = static_cast<float> (gainParam->get());
auto master = static_cast<float> (masterParam->get());
- auto model_index = static_cast<int> (modelParam->get());
+ auto model = static_cast<float> (modelParam->get());
+ model_index = getModelIndex(model);
buffer.applyGain(gain);
@@ -196,7 +201,7 @@ void NeuralPiAudioProcessor::getStateInformation(MemoryBlock& destData)
stream.writeFloat(*gainParam);
stream.writeFloat(*masterParam);
- stream.writeInt(*modelParam);
+ stream.writeFloat(*modelParam);
}
void NeuralPiAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
@@ -205,7 +210,13 @@ void NeuralPiAudioProcessor::setStateInformation(const void* data, int sizeInByt
gainParam->setValueNotifyingHost(stream.readFloat());
masterParam->setValueNotifyingHost(stream.readFloat());
- modelParam->setValueNotifyingHost(stream.readInt());
+ modelParam->setValueNotifyingHost(stream.readFloat());
+}
+
+int NeuralPiAudioProcessor::getModelIndex(float model_param)
+{
+ //return static_cast<int>(model_param * (jsonFiles.size() - 1.0));
+ return static_cast<int>(model_param * (num_models - 1.0));
}
void NeuralPiAudioProcessor::loadConfig(File configFile)
@@ -239,7 +250,10 @@ void NeuralPiAudioProcessor::addDirectory(const File& file)
juce::Array<juce::File> results;
file.findChildFiles(results, juce::File::findFiles, false, "*.json");
for (int i = results.size(); --i >= 0;)
+ {
jsonFiles.push_back(File(results.getReference(i).getFullPathName()));
+ num_models = num_models + 1.0;
+ }
}
}
diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h
@@ -66,6 +66,8 @@ public:
void getStateInformation (MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
+ bool compareFunction(juce::File a, juce::File b);
+ int getModelIndex(float model_param);
void loadConfig(File configFile);
void setupDataDirectories();
void installTones();
@@ -95,6 +97,8 @@ public:
const char* char_filename = "";
int model_loaded = 0;
int current_model_index = 0;
+ float num_models = 0.0;
+ int model_index = 0; // Used in processBlock when converting slider param to model index
RT_LSTM LSTM;
@@ -103,8 +107,7 @@ private:
AudioParameterFloat* gainParam;
AudioParameterFloat* masterParam;
-
- AudioParameterInt* modelParam;
+ AudioParameterFloat* modelParam;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralPiAudioProcessor)