successfully save/load ui width/height

This commit is contained in:
Alex Birch 2019-07-08 23:36:27 +01:00
parent a990072f1f
commit 374394330f
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
8 changed files with 329 additions and 73 deletions

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "345302E3C02BBFCDACE98BE7"
BuildableName = "juicysfplugin.component"
BlueprintName = "juicysfplugin - AU"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Applications/JUCE/extras/AudioPluginHost/Builds/MacOSX/build/Debug/AudioPluginHost.app">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "345302E3C02BBFCDACE98BE7"
BuildableName = "juicysfplugin.component"
BlueprintName = "juicysfplugin - AU"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "345302E3C02BBFCDACE98BE7"
BuildableName = "juicysfplugin.component"
BlueprintName = "juicysfplugin - AU"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -33,7 +33,7 @@
</AdditionalOptions> </AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Release" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0" launchStyle = "0"

View File

@ -51,8 +51,11 @@
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<BuildableProductRunnable <PathRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0"
FilePath = "/Applications/JUCE/extras/AudioPluginHost/Builds/MacOSX/build/Debug/AudioPluginHost.app">
</PathRunnable>
<MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "24C399ED93EC47D5BEB26F76" BlueprintIdentifier = "24C399ED93EC47D5BEB26F76"
@ -60,7 +63,7 @@
BlueprintName = "juicysfplugin - Standalone Plugin" BlueprintName = "juicysfplugin - Standalone Plugin"
ReferencedContainer = "container:juicysfplugin.xcodeproj"> ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "48A570326AA09CE818BE1901"
BuildableName = "juicysfplugin.vst"
BlueprintName = "juicysfplugin - VST"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Applications/JUCE/extras/AudioPluginHost/Builds/MacOSX/build/Debug/AudioPluginHost.app">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "48A570326AA09CE818BE1901"
BuildableName = "juicysfplugin.vst"
BlueprintName = "juicysfplugin - VST"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "48A570326AA09CE818BE1901"
BuildableName = "juicysfplugin.vst"
BlueprintName = "juicysfplugin - VST"
ReferencedContainer = "container:juicysfplugin.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -42,6 +42,10 @@
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Applications/JUCE/extras/AudioPluginHost/Builds/MacOSX/build/Debug/AudioPluginHost.app">
</PathRunnable>
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"

View File

@ -34,26 +34,36 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(
// int width, height; // int width, height;
// { // {
// RangedAudioParameter *param {valueTreeState.getParameter("uiWidth")}; // RangedAudioParameter *param {valueTreeState.getParameter("uiWidthPersist")};
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr); // jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)}; // AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// width = castParam->get(); // width = castParam->get();
// } // }
// { // {
// RangedAudioParameter *param {valueTreeState.getParameter("uiHeight")}; // RangedAudioParameter *param {valueTreeState.getParameter("uiHeightPersist")};
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr); // jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)}; // AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// height = castParam->get(); // height = castParam->get();
// } // }
// valueTreeState.addParameterListener("uiWidthPersist", this); // valueTreeState.addParameterListener("uiWidthPersist", this);
// valueTreeState.addParameterListener("uiHeightPersist", this); // valueTreeState.addParameterListener("uiHeightPersist", this);
// valueTreeState.addParameterListener("uiWidth", this); // valueTreeState.addParameterListener("uiWidth", this);
// valueTreeState.addParameterListener("uiHeight", this); // valueTreeState.addParameterListener("uiHeight", this);
valueTreeState.state.addListener(this); // valueTreeState.state.addListener(this);
setSize(GuiConstants::minWidth, GuiConstants::minHeight); // setSize(GuiConstants::minWidth, GuiConstants::minHeight);
// setSize(width, height);
lastUIWidth.referTo(valueTreeState.state.getChildWithName("uiState").getPropertyAsValue("width", nullptr));
lastUIHeight.referTo(valueTreeState.state.getChildWithName("uiState").getPropertyAsValue("height", nullptr));
// set our component's initial size to be the last one that was stored in the filter's settings
setSize(lastUIWidth.getValue(), lastUIHeight.getValue());
lastUIWidth.addListener(this);
lastUIHeight.addListener(this);
// processor.subscribeToStateChanges(this); // processor.subscribeToStateChanges(this);
@ -71,52 +81,60 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(
} }
// called when the stored window size changes
void JuicySFAudioProcessorEditor::valueChanged(Value&) {
setSize(lastUIWidth.getValue(), lastUIHeight.getValue());
}
JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor() JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor()
{ {
// valueTreeState.removeParameterListener("uiWidthPersist", this); lastUIWidth.removeListener(this);
// valueTreeState.removeParameterListener("uiHeightPersist", this); lastUIHeight.removeListener(this);
// valueTreeState.removeParameterListener("uiWidthPersist", this);
// valueTreeState.removeParameterListener("uiHeightPersist", this);
// valueTreeState.removeParameterListener("uiWidth", this); // valueTreeState.removeParameterListener("uiWidth", this);
// valueTreeState.removeParameterListener("uiHeight", this); // valueTreeState.removeParameterListener("uiHeight", this);
valueTreeState.state.removeListener(this); // valueTreeState.state.removeListener(this);
// processor.unsubscribeFromStateChanges(this); // processor.unsubscribeFromStateChanges(this);
} }
void JuicySFAudioProcessorEditor::valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged, // void JuicySFAudioProcessorEditor::valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged,
const Identifier& property) { // const Identifier& property) {
if (&treeWhosePropertyHasChanged == &valueTreeState.state) { // // if (treeWhosePropertyHasChanged.getType() == Identifier("PARAM")) {
if (property == Identifier("uiWidth")) { // const String propertyString{property.toString()};
// String soundFontPath{treeWhosePropertyHasChanged.getProperty("soundFontPath", "")}; // if (propertyString == "uiWidth") {
// if (soundFontPath.isNotEmpty()) { // // String soundFontPath{treeWhosePropertyHasChanged.getProperty("soundFontPath", "")};
// loadFont(soundFontPath); // // if (soundFontPath.isNotEmpty()) {
// } // // loadFont(soundFontPath);
int value{treeWhosePropertyHasChanged.getProperty("uiWidth", GuiConstants::minWidth)}; // // }
setSize(value, getHeight()); // int value{treeWhosePropertyHasChanged.getProperty("uiWidth", GuiConstants::minWidth)};
} else if (property == Identifier("uiHeight")) { // setSize(value, getHeight());
int value{treeWhosePropertyHasChanged.getProperty("uiHeight", GuiConstants::minHeight)}; // } else if (propertyString == "uiHeight") {
setSize(getWidth(), value); // int value{treeWhosePropertyHasChanged.getProperty("uiHeight", GuiConstants::minHeight)};
} // setSize(getWidth(), value);
} // }
} // // }
// }
// void JuicySFAudioProcessorEditor::parameterChanged(const String& parameterID, float newValue) { // void JuicySFAudioProcessorEditor::parameterChanged(const String& parameterID, float newValue) {
// // if (parameterID == "uiWidthPersist" // // if (parameterID == "uiWidthPersist"
// // || parameterID == "uiHeightPersist") { // // || parameterID == "uiHeightPersist") {
// if (parameterID == "uiWidth" // if (parameterID == "uiWidth"
// || parameterID == "uiHeight") { // || parameterID == "uiHeight") {
// RangedAudioParameter *param {valueTreeState.getParameter(parameterID)}; // RangedAudioParameter *param {valueTreeState.getParameter(parameterID)};
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr); // jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)}; // AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// int value{castParam->get()}; // int value{castParam->get()};
// // if (parameterID == "uiWidthPersist") {
// // setSize(value, getHeight());
// // } else if (parameterID == "uiHeightPersist") {
// // setSize(getWidth(), value);
// // }
// if (parameterID == "uiWidth") { // if (parameterID == "uiWidth") {
// setSize(value, getHeight()); // setSize(value, getHeight());
// } else if (parameterID == "uiHeight") { // } else if (parameterID == "uiHeight") {
// setSize(getWidth(), value); // setSize(getWidth(), value);
// } // }
// // if (parameterID == "uiWidthPersist") {
// // setSize(value, getHeight());
// // } else if (parameterID == "uiHeightPersist") {
// // setSize(getWidth(), value);
// // }
// } // }
// } // }
@ -171,21 +189,30 @@ void JuicySFAudioProcessorEditor::resized()
tablesComponent.setBounds(rContent); tablesComponent.setBounds(rContent);
valueTreeState.state.setPropertyExcludingListener(this, "uiWidth", getWidth(), nullptr); lastUIWidth = getWidth();
valueTreeState.state.setPropertyExcludingListener(this, "uiHeight", getHeight(), nullptr); lastUIHeight = getHeight();
// { // valueTreeState.state.setPropertyExcludingListener(this, "uiWidth", getWidth(), nullptr);
// RangedAudioParameter *param {valueTreeState.getParameter("uiWidth2")}; // valueTreeState.state.setPropertyExcludingListener(this, "uiHeight", getHeight(), nullptr);
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)}; // {
// *castParam = getWidth(); // // RangedAudioParameter *param {valueTreeState.getParameter("uiWidthTemp")};
// } // RangedAudioParameter *param {valueTreeState.getParameter("uiWidth")};
// { // // param->setValueNotifyingHost(param->convertTo0to1(getWidth()));
// RangedAudioParameter *param {valueTreeState.getParameter("uiHeight2")}; // jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr); // AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)}; // *castParam = getWidth();
// *castParam = getHeight(); // // castParam->AudioProcessorParameter::setValue(castParam->convertTo0to1(static_cast<float>(getWidth())));
// } // }
// {
// // RangedAudioParameter *param {valueTreeState.getParameter("uiHeightTemp")};
// RangedAudioParameter *param {valueTreeState.getParameter("uiHeight")};
// // param->setValueNotifyingHost(param->convertTo0to1(getHeight()));
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// *castParam = getHeight();
// // castParam->AudioProcessorParameter::setValue(castParam->convertTo0to1(static_cast<float>(getHeight())));
// }
// sharedParams.setUiWidth(getWidth()); // sharedParams.setUiWidth(getWidth());
// sharedParams.setUiHeight(getHeight()); // sharedParams.setUiHeight(getHeight());

View File

@ -26,7 +26,8 @@
class JuicySFAudioProcessorEditor class JuicySFAudioProcessorEditor
: public AudioProcessorEditor : public AudioProcessorEditor
// , public AudioProcessorValueTreeState::Listener // , public AudioProcessorValueTreeState::Listener
, public ValueTree::Listener , private Value::Listener
// , public ValueTree::Listener
/*, /*,
, public ExposesComponents , public ExposesComponents
public StateChangeSubscriber*/ public StateChangeSubscriber*/
@ -55,19 +56,20 @@ public:
// int getWidth(); // int getWidth();
// int getHeight(); // int getHeight();
virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, // 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,
ValueTree& childWhichHasBeenRemoved, // ValueTree& childWhichHasBeenRemoved,
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 {}; // inline virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override {};
inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {}; // inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {};
private: private:
void valueChanged (Value&) override;
// This reference is provided as a quick way for your editor to // This reference is provided as a quick way for your editor to
// access the processor object that created it. // access the processor object that created it.
@ -76,6 +78,11 @@ private:
AudioProcessorValueTreeState& valueTreeState; AudioProcessorValueTreeState& valueTreeState;
// SharesParams& sharedParams; // SharesParams& sharedParams;
// these are used to persist the UI's size - the values are stored along with the
// filter's other parameters, and the UI component will update them when it gets
// resized.
Value lastUIWidth, lastUIHeight;
SurjectiveMidiKeyboardComponent midiKeyboard; SurjectiveMidiKeyboardComponent midiKeyboard;
TablesComponent tablesComponent; TablesComponent tablesComponent;
FilePicker filePicker; FilePicker filePicker;

View File

@ -33,12 +33,19 @@ JuicySFAudioProcessor::JuicySFAudioProcessor()
, valueTreeState{ , valueTreeState{
*this, *this,
nullptr, nullptr,
{ "MYPLUGINSETTINGS" }, "MYPLUGINSETTINGS",
createParameterLayout()} createParameterLayout()}
, fluidSynthModel{valueTreeState, valueTree} , fluidSynthModel{valueTreeState, valueTree}
//, fluidSynthModel{*this} //, fluidSynthModel{*this}
//, pluginEditor(nullptr) //, pluginEditor(nullptr)
{ {
valueTreeState.state.appendChild({ "uiState", {
{ "width", GuiConstants::minWidth },
{ "height", GuiConstants::minHeight }
}, {} }, nullptr);
valueTreeState.state.setProperty("soundFontPath", "", nullptr);
// valueTreeState.state.appendChild({ "soundFontPath", {} }, nullptr);
initialiseSynth(); initialiseSynth();
} }
@ -57,8 +64,8 @@ AudioProcessorValueTreeState::ParameterLayout JuicySFAudioProcessor::createParam
// make_unique<AudioParameterInt>("uiHeightPersist", "height of this plugin's GUI. Editor listens for changes (e.g. on load)", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Persist" ), // make_unique<AudioParameterInt>("uiHeightPersist", "height of this plugin's GUI. Editor listens for changes (e.g. on load)", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Persist" ),
// make_unique<AudioParameterInt>("uiWidthTemp", "width of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width Temp" ), // make_unique<AudioParameterInt>("uiWidthTemp", "width of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width Temp" ),
// make_unique<AudioParameterInt>("uiHeightTemp", "height of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Temp" ), // make_unique<AudioParameterInt>("uiHeightTemp", "height of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Temp" ),
make_unique<AudioParameterInt>("uiWidth", "width of this plugin's GUI", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width" ), // make_unique<AudioParameterInt>("uiWidth", "width of this plugin's GUI", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width" ),
make_unique<AudioParameterInt>("uiHeight", "height of this plugin's GUI", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height" ), // make_unique<AudioParameterInt>("uiHeight", "height of this plugin's GUI", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height" ),
// todo: check whether bank really is 0-127 // todo: check whether bank really is 0-127
make_unique<AudioParameterInt>("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Bank" ), make_unique<AudioParameterInt>("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Bank" ),
// note: banks may be sparse, and lack a 0th preset. so defend against this. // note: banks may be sparse, and lack a 0th preset. so defend against this.
@ -227,7 +234,11 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
switch(static_cast<fluid_midi_control_change>(m.getControllerNumber())) { switch(static_cast<fluid_midi_control_change>(m.getControllerNumber())) {
case SOUND_CTRL2: { // MIDI CC 71 Timbre/Harmonic Intensity (filter resonance) case SOUND_CTRL2: { // MIDI CC 71 Timbre/Harmonic Intensity (filter resonance)
valueTreeState.state.setProperty({"filterResonance"}, m.getControllerValue(), nullptr); // valueTreeState.state.setProperty({"filterResonance"}, m.getControllerValue(), nullptr);
RangedAudioParameter *param {valueTreeState.getParameter("filterResonance")};
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
*castParam = m.getControllerValue();
break; break;
} }
case SOUND_CTRL3: { // MIDI CC 72 Release time case SOUND_CTRL3: { // MIDI CC 72 Release time
@ -384,7 +395,9 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData)
// xml->setAttribute (p->paramID, p->getValue()); // xml->setAttribute (p->paramID, p->getValue());
// then use this helper function to stuff it into the binary blob and return it.. // then use this helper function to stuff it into the binary blob and return it..
copyXmlToBinary (*xml, destData); if (xml.get() != nullptr) {
copyXmlToBinary(*xml, destData);
}
} }
void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInBytes) void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
@ -399,7 +412,41 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
// make sure that it's actually our type of XML object.. // make sure that it's actually our type of XML object..
// if (xmlState->hasTagName ("MYPLUGINSETTINGS")) { // if (xmlState->hasTagName ("MYPLUGINSETTINGS")) {
if (xmlState->hasTagName(valueTreeState.state.getType())) { if (xmlState->hasTagName(valueTreeState.state.getType())) {
valueTreeState.replaceState(ValueTree::fromXml(*xmlState)); // valueTreeState.replaceState(ValueTree::fromXml(*xmlState));
for (auto* param : getParameters())
if (auto* p = dynamic_cast<AudioProcessorParameterWithID*>(param))
p->setValue(static_cast<float>(xmlState->getDoubleAttribute(p->paramID, p->getValue())));
{
Value value{valueTreeState.state.getPropertyAsValue("soundFontPath", nullptr)};
value = xmlState->getStringAttribute("soundFontPath", value.getValue());
// valueTreeState.getParameter("soundFontPath")->getValue()
// valueTreeState.getParameter("soundFontPath")->getValue();
// RangedAudioParameter *param {valueTreeState.getParameter("release")};
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
// *castParam = m.getControllerValue();
}
{
ValueTree tree{valueTreeState.state.getChildWithName("uiState")};
XmlElement* uiState{xmlState->getChildByName("uiState")};
if (uiState) {
{
Value value{tree.getPropertyAsValue("width", nullptr)};
value = uiState->getIntAttribute("width", value.getValue());
}
{
Value value{tree.getPropertyAsValue("height", nullptr)};
value = uiState->getIntAttribute("height", value.getValue());
}
}
// tree.getPropertyAsValue("width", nullptr)
// tree.
// valueTreeState.replaceState(ValueTree::fromXml(*xmlState))
// value = xmlState->getStringAttribute("soundFontPath", value.getValue());
}
// list<StateChangeSubscriber*>::iterator p; // list<StateChangeSubscriber*>::iterator p;
// for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) { // for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
// (*p)->setStateInformation(xmlState); // (*p)->setStateInformation(xmlState);