try to correctly modify value tree and listen for changes
This commit is contained in:
parent
8c1be957fe
commit
11d7296813
|
@ -56,7 +56,8 @@ void FilePicker::filenameComponentChanged (FilenameComponent*) {
|
||||||
// currentPath = fileChooser.getCurrentFile().getFullPathName();
|
// currentPath = fileChooser.getCurrentFile().getFullPathName();
|
||||||
// fluidSynthModel.onFileNameChanged(fileChooser.getCurrentFile().getFullPathName(), -1, -1);
|
// fluidSynthModel.onFileNameChanged(fileChooser.getCurrentFile().getFullPathName(), -1, -1);
|
||||||
Value value{valueTreeState.state.getChildWithName("soundFont").getPropertyAsValue("path", nullptr)};
|
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,
|
void FilePicker::valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged,
|
||||||
|
|
|
@ -347,6 +347,7 @@ void FluidSynthModel::loadFont(const String &absPath) {
|
||||||
banks.appendChild({ "bank", {
|
banks.appendChild({ "bank", {
|
||||||
{ "num", initialBankOffset },
|
{ "num", initialBankOffset },
|
||||||
}, {} }, nullptr);
|
}, {} }, nullptr);
|
||||||
|
int greatestPersistedBank{initialBankOffset};
|
||||||
|
|
||||||
fluid_sfont_iteration_start(sfont);
|
fluid_sfont_iteration_start(sfont);
|
||||||
|
|
||||||
|
@ -362,10 +363,11 @@ void FluidSynthModel::loadFont(const String &absPath) {
|
||||||
// fluid_preset_get_name(preset)
|
// fluid_preset_get_name(preset)
|
||||||
// )
|
// )
|
||||||
// ));
|
// ));
|
||||||
if (bankOffset > initialBankOffset) {
|
if (bankOffset > greatestPersistedBank) {
|
||||||
banks.appendChild({ "bank", {
|
banks.appendChild({ "bank", {
|
||||||
{ "num", bankOffset },
|
{ "num", bankOffset },
|
||||||
}, {} }, nullptr);
|
}, {} }, nullptr);
|
||||||
|
greatestPersistedBank = bankOffset;
|
||||||
}
|
}
|
||||||
presets.appendChild({ "preset", {
|
presets.appendChild({ "preset", {
|
||||||
{ "num", fluid_preset_get_num(preset) },
|
{ "num", fluid_preset_get_num(preset) },
|
||||||
|
@ -373,8 +375,15 @@ void FluidSynthModel::loadFont(const String &absPath) {
|
||||||
}, {} }, nullptr);
|
}, {} }, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
valueTreeState.state.getChildWithName("banks") = banks;
|
// valueTreeState.state.getChildWithName("banks") = banks;
|
||||||
valueTreeState.state.getChildWithName("presets") = presets;
|
// valueTreeState.state.getChildWithName("presets") = presets;
|
||||||
|
valueTreeState.state.getChildWithName("banks").copyPropertiesAndChildrenFrom(banks, nullptr);
|
||||||
|
valueTreeState.state.getChildWithName("presets").copyPropertiesAndChildrenFrom(presets, nullptr);
|
||||||
|
|
||||||
|
#if JUCE_DEBUG
|
||||||
|
unique_ptr<XmlElement> xml{valueTreeState.state.createXml()};
|
||||||
|
Logger::outputDebugString(xml->createDocument("",false,false));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// FluidSynthModel::Listener::~Listener() {
|
// FluidSynthModel::Listener::~Listener() {
|
||||||
|
|
|
@ -388,7 +388,7 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||||
// XmlElement xml{"MYPLUGINSETTINGS"};
|
// XmlElement xml{"MYPLUGINSETTINGS"};
|
||||||
// sharedParams->setAttributesOnXml(xml);
|
// sharedParams->setAttributesOnXml(xml);
|
||||||
auto state{valueTreeState.copyState()};
|
auto state{valueTreeState.copyState()};
|
||||||
shared_ptr<XmlElement> xml{state.createXml()};
|
unique_ptr<XmlElement> xml{state.createXml()};
|
||||||
// sharedParams.setAttributesOnXml(xml);
|
// sharedParams.setAttributesOnXml(xml);
|
||||||
|
|
||||||
// list<StateChangeSubscriber*>::iterator p;
|
// list<StateChangeSubscriber*>::iterator p;
|
||||||
|
|
|
@ -120,11 +120,17 @@ void TableComponent::parameterChanged(const String& parameterID, float newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableComponent::valueTreePropertyChanged(
|
// void TableComponent::valueTreePropertyChanged(
|
||||||
ValueTree& treeWhosePropertyHasChanged,
|
// ValueTree& treeWhosePropertyHasChanged,
|
||||||
const Identifier& property) {
|
// const Identifier& property) {
|
||||||
if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) {
|
// if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) {
|
||||||
loadModelFrom(treeWhosePropertyHasChanged);
|
// loadModelFrom(treeWhosePropertyHasChanged);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) {
|
||||||
|
if (treeWhoseParentHasChanged.getType() == StringRef("presets")) {
|
||||||
|
loadModelFrom(treeWhoseParentHasChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,8 @@ public:
|
||||||
|
|
||||||
virtual void parameterChanged (const String& parameterID, float newValue) override;
|
virtual void parameterChanged (const String& parameterID, float newValue) override;
|
||||||
|
|
||||||
virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged,
|
inline virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged,
|
||||||
const Identifier& property) override;
|
const Identifier& property) override {};
|
||||||
inline virtual void valueTreeChildAdded (ValueTree& parentTree,
|
inline virtual void valueTreeChildAdded (ValueTree& parentTree,
|
||||||
ValueTree& childWhichHasBeenAdded) override {};
|
ValueTree& childWhichHasBeenAdded) override {};
|
||||||
inline virtual void valueTreeChildRemoved (ValueTree& parentTree,
|
inline virtual void valueTreeChildRemoved (ValueTree& parentTree,
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
int indexFromWhichChildWasRemoved) override {};
|
int indexFromWhichChildWasRemoved) override {};
|
||||||
inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved,
|
inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved,
|
||||||
int oldIndex, int newIndex) override {};
|
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 {};
|
inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {};
|
||||||
private:
|
private:
|
||||||
void loadModelFrom(ValueTree& presets);
|
void loadModelFrom(ValueTree& presets);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user