diff --git a/Source/FilePicker.cpp b/Source/FilePicker.cpp index 7a74eef..4787f49 100644 --- a/Source/FilePicker.cpp +++ b/Source/FilePicker.cpp @@ -56,7 +56,8 @@ void FilePicker::filenameComponentChanged (FilenameComponent*) { // currentPath = fileChooser.getCurrentFile().getFullPathName(); // fluidSynthModel.onFileNameChanged(fileChooser.getCurrentFile().getFullPathName(), -1, -1); Value value{valueTreeState.state.getChildWithName("soundFont").getPropertyAsValue("path", nullptr)}; - value = fileChooser.getCurrentFile().getFullPathName(); + value.setValue(fileChooser.getCurrentFile().getFullPathName()); +// value = fileChooser.getCurrentFile().getFullPathName(); } void FilePicker::valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged, diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index c11ba06..5b8cef1 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -347,6 +347,7 @@ void FluidSynthModel::loadFont(const String &absPath) { banks.appendChild({ "bank", { { "num", initialBankOffset }, }, {} }, nullptr); + int greatestPersistedBank{initialBankOffset}; fluid_sfont_iteration_start(sfont); @@ -362,10 +363,11 @@ void FluidSynthModel::loadFont(const String &absPath) { // fluid_preset_get_name(preset) // ) // )); - if (bankOffset > initialBankOffset) { + if (bankOffset > greatestPersistedBank) { banks.appendChild({ "bank", { { "num", bankOffset }, }, {} }, nullptr); + greatestPersistedBank = bankOffset; } presets.appendChild({ "preset", { { "num", fluid_preset_get_num(preset) }, @@ -373,8 +375,15 @@ void FluidSynthModel::loadFont(const String &absPath) { }, {} }, nullptr); } } - valueTreeState.state.getChildWithName("banks") = banks; - valueTreeState.state.getChildWithName("presets") = presets; +// valueTreeState.state.getChildWithName("banks") = banks; +// valueTreeState.state.getChildWithName("presets") = presets; + valueTreeState.state.getChildWithName("banks").copyPropertiesAndChildrenFrom(banks, nullptr); + valueTreeState.state.getChildWithName("presets").copyPropertiesAndChildrenFrom(presets, nullptr); + +#if JUCE_DEBUG + unique_ptr xml{valueTreeState.state.createXml()}; + Logger::outputDebugString(xml->createDocument("",false,false)); +#endif } // FluidSynthModel::Listener::~Listener() { diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index e94fc05..40e6515 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -388,7 +388,7 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData) // XmlElement xml{"MYPLUGINSETTINGS"}; // sharedParams->setAttributesOnXml(xml); auto state{valueTreeState.copyState()}; - shared_ptr xml{state.createXml()}; + unique_ptr xml{state.createXml()}; // sharedParams.setAttributesOnXml(xml); // list::iterator p; diff --git a/Source/TableComponent.cpp b/Source/TableComponent.cpp index 3bedb14..021c1af 100644 --- a/Source/TableComponent.cpp +++ b/Source/TableComponent.cpp @@ -120,11 +120,17 @@ void TableComponent::parameterChanged(const String& parameterID, float newValue) } } -void TableComponent::valueTreePropertyChanged( - ValueTree& treeWhosePropertyHasChanged, - const Identifier& property) { - if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) { - loadModelFrom(treeWhosePropertyHasChanged); +// void TableComponent::valueTreePropertyChanged( +// ValueTree& treeWhosePropertyHasChanged, +// const Identifier& property) { +// if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) { +// loadModelFrom(treeWhosePropertyHasChanged); +// } +// } + +void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) { + if (treeWhoseParentHasChanged.getType() == StringRef("presets")) { + loadModelFrom(treeWhoseParentHasChanged); } } diff --git a/Source/TableComponent.h b/Source/TableComponent.h index 41feaa3..6944ccc 100644 --- a/Source/TableComponent.h +++ b/Source/TableComponent.h @@ -79,8 +79,8 @@ public: virtual void parameterChanged (const String& parameterID, float newValue) override; - virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, - const Identifier& property) override; + inline virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, + const Identifier& property) override {}; inline virtual void valueTreeChildAdded (ValueTree& parentTree, ValueTree& childWhichHasBeenAdded) override {}; inline virtual void valueTreeChildRemoved (ValueTree& parentTree, @@ -88,7 +88,7 @@ public: int indexFromWhichChildWasRemoved) override {}; inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved, int oldIndex, int newIndex) override {}; - inline virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override {}; + virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override; inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {}; private: void loadModelFrom(ValueTree& presets);