Proteus

Guitar amp and pedal capture plugin using neural networks
Log | Files | Refs | Submodules | README

commit 458fbb70d53de80922249268abcf2114e4516ba5
parent ded4f8698994d0015319a3c8ed834867b48b2631
Author: Keith <smartguitarml@gmail.com>
Date:   Thu, 13 Oct 2022 17:22:04 -0500

Updated model loading

Diffstat:
Minstallers/linux/build_deb.sh | 2+-
Msrc/PluginEditor.cpp | 10+++++++---
Msrc/PluginProcessor.cpp | 48+++++++++++++++++++++++++++++++++++++++++++++---
Msrc/PluginProcessor.h | 1+
4 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/installers/linux/build_deb.sh b/installers/linux/build_deb.sh @@ -3,7 +3,7 @@ # Set the app name and version here app_name=Proteus -version=1.0 +version=1.1 # 1. Create the package directory structure and control file diff --git a/src/PluginEditor.cpp b/src/PluginEditor.cpp @@ -176,7 +176,7 @@ bool ProteusAudioProcessorEditor::isValidFormat(File configFile) } void ProteusAudioProcessorEditor::loadButtonClicked() -{ +{ myChooser = std::make_unique<FileChooser> ("Select a folder to load models from", processor.folder, "*.json"); @@ -253,8 +253,11 @@ void ProteusAudioProcessorEditor::loadFromFolder() } } if (!processor.jsonFiles.empty()) { - processor.loadConfig(processor.jsonFiles[processor.current_model_index]); - modelSelect.setText(processor.jsonFiles[processor.current_model_index].getFileNameWithoutExtension(), juce::NotificationType::dontSendNotification); + processor.loadConfig(processor.saved_model); + modelSelect.setText(processor.saved_model.getFileNameWithoutExtension(), juce::NotificationType::dontSendNotification); + + //processor.loadConfig(processor.jsonFiles[processor.current_model_index]); + //modelSelect.setText(processor.jsonFiles[processor.current_model_index].getFileNameWithoutExtension(), juce::NotificationType::dontSendNotification); } } } @@ -288,6 +291,7 @@ void ProteusAudioProcessorEditor::modelSelectChanged() if (selectedFileIndex >= 0 && selectedFileIndex < processor.jsonFiles.size() && processor.jsonFiles.empty() == false) { //check if correct processor.loadConfig(processor.jsonFiles[selectedFileIndex]); processor.current_model_index = selectedFileIndex; + processor.saved_model = processor.jsonFiles[selectedFileIndex]; } repaint(); } diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp @@ -285,19 +285,59 @@ void ProteusAudioProcessor::setStateInformation (const void* data, int sizeInByt { treeState.replaceState (juce::ValueTree::fromXml (*xmlState)); fw_state = xmlState->getBoolAttribute ("fw_state"); - saved_model = xmlState->getStringAttribute("saved_model"); + File temp_saved_model = xmlState->getStringAttribute("saved_model"); + saved_model = temp_saved_model; + //saved_model = xmlState->getStringAttribute("saved_model"); + current_model_index = xmlState->getIntAttribute("current_model_index"); File temp = xmlState->getStringAttribute("folder"); folder = temp; if (auto* editor = dynamic_cast<ProteusAudioProcessorEditor*> (getActiveEditor())) editor->resetImages(); - if (auto* editor = dynamic_cast<ProteusAudioProcessorEditor*> (getActiveEditor())) - editor->loadFromFolder(); + //if (auto* editor = dynamic_cast<ProteusAudioProcessorEditor*> (getActiveEditor())) + // editor->loadFromFolder(); + + if (isValidFormat(saved_model)) { + loadConfig(saved_model); + } } } } +bool ProteusAudioProcessor::isValidFormat(File configFile) +{ + // Read in the JSON file + String path = configFile.getFullPathName(); + const char* char_filename = path.toUTF8(); + + std::ifstream i2(char_filename); + nlohmann::json weights_json; + i2 >> weights_json; + + int hidden_size_temp = 0; + std::string network = ""; + + // Check that the hidden_size and unit_type fields exist and are correct + if (weights_json.contains("/model_data/unit_type"_json_pointer) == true && weights_json.contains("/model_data/hidden_size"_json_pointer) == true) { + // Get the input size of the JSON file + int input_size_json = weights_json["/model_data/hidden_size"_json_pointer]; + std::string network_temp = weights_json["/model_data/unit_type"_json_pointer]; + + network = network_temp; + hidden_size_temp = input_size_json; + } + else { + return false; + } + + if (hidden_size_temp == 40 && network == "LSTM") { + return true; + } + else { + return false; + } +} void ProteusAudioProcessor::loadConfig(File configFile) { @@ -318,6 +358,8 @@ void ProteusAudioProcessor::loadConfig(File configFile) conditioned = true; } + //saved_model = configFile; + this->suspendProcessing(false); } diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h @@ -65,6 +65,7 @@ public: void setStateInformation (const void* data, int sizeInBytes) override; // Files and configuration + bool isValidFormat(File configFile); void loadConfig(File configFile); // Pedal/amp states