diff --git a/Builds/MacOSX/juicysfplugin.xcodeproj/project.pbxproj b/Builds/MacOSX/juicysfplugin.xcodeproj/project.pbxproj index 5e37ab9..1d0e430 100644 --- a/Builds/MacOSX/juicysfplugin.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/juicysfplugin.xcodeproj/project.pbxproj @@ -235,6 +235,7 @@ 560D40E30164CA9D05C6AC3B /* MyColours.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MyColours.h; path = ../../Source/MyColours.h; sourceTree = SOURCE_ROOT; }; 571BC08FE42BABE3BAF364C8 /* Info-AUv3_AppExtension.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-AUv3_AppExtension.plist"; sourceTree = SOURCE_ROOT; }; 596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StateChangeSubscriber.h; path = ../../Source/StateChangeSubscriber.h; sourceTree = ""; }; + 59672C6315E5D06A21B4A2F2 /* SharesParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharesParams.h; path = ../../Source/SharesParams.h; sourceTree = ""; }; 5B3CBC48DAB08EDF53CEE609 /* include_juce_audio_plugin_client_VST3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = include_juce_audio_plugin_client_VST3.cpp; path = ../../JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp; sourceTree = SOURCE_ROOT; }; 5BC90F629770BCF4193FABDD /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 63942F8053F1E4E72C1BE98C /* FilePicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = FilePicker.cpp; path = ../../Source/FilePicker.cpp; sourceTree = SOURCE_ROOT; }; @@ -555,6 +556,7 @@ 457D4946B07CC4A74EB0FAE1 /* PluginEditor.cpp */, B3E8D1BE528BBA1B6004672E /* PluginEditor.h */, 596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */, + 59672C6315E5D06A21B4A2F2 /* SharesParams.h */, ); name = Source; sourceTree = ""; diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index d9cb337..9a6d7f7 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -8,7 +8,7 @@ using namespace std; FluidSynthModel::FluidSynthModel() - : processor(nullptr), + : sharesParams(nullptr), synth(nullptr), settings(nullptr), initialised(false), @@ -27,8 +27,8 @@ FluidSynthModel::~FluidSynthModel() { } } -void FluidSynthModel::initialise(JuicySFAudioProcessor& p) { - processor = &p; +void FluidSynthModel::initialise(SharesParams& p) { + sharesParams = &p; // if (initialised) { // delete_fluid_synth(synth); // delete_fluid_settings(settings); @@ -39,8 +39,8 @@ void FluidSynthModel::initialise(JuicySFAudioProcessor& p) { synth = new_fluid_synth(settings); - if (processor->soundFontPath.isNotEmpty()) { - loadFont(processor->soundFontPath.toStdString()); + if (sharesParams->getSoundFontPath().isNotEmpty()) { + loadFont(sharesParams->getSoundFontPath().toStdString()); } fluid_synth_set_gain(synth, 2.0); @@ -153,7 +153,7 @@ FluidSynthModel::Listener::~Listener() { void FluidSynthModel::Listener::fontChanged(FluidSynthModel * model, const string &absPath) { if (model->initialised) { - model->processor->soundFontPath = String(absPath); + model->sharesParams->setSoundFontPath(String(absPath)); } } diff --git a/Source/FluidSynthModel.h b/Source/FluidSynthModel.h index 7ce41a8..89cebda 100644 --- a/Source/FluidSynthModel.h +++ b/Source/FluidSynthModel.h @@ -5,7 +5,7 @@ #pragma once #include "../JuceLibraryCode/JuceHeader.h" -#include "PluginProcessor.h" +#include "SharesParams.h" #include #include #include "PresetsToBanks.h" @@ -20,7 +20,7 @@ public: ~FluidSynthModel(); fluid_synth_t* getSynth(); - void initialise(JuicySFAudioProcessor& p); + void initialise(SharesParams& p); BanksToPresets getBanks(); @@ -57,7 +57,7 @@ public: void removeListener (Listener* listener); private: - JuicySFAudioProcessor* processor; + SharesParams* sharesParams; fluid_synth_t* synth; fluid_settings_t* settings; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 346fa1e..299a9a8 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -254,6 +254,14 @@ FluidSynthModel* JuicySFAudioProcessor::getFluidSynthModel() { return &fluidSynthModel; } +void JuicySFAudioProcessor::setSoundFontPath(const String& value) { + soundFontPath = value; +} + +String& JuicySFAudioProcessor::getSoundFontPath() { + return soundFontPath; +} + //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index ccef604..b350e6e 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -13,6 +13,7 @@ #include "../JuceLibraryCode/JuceHeader.h" #include "FluidSynthModel.h" #include "StateChangeSubscriber.h" +#include "SharesParams.h" #include using namespace std; @@ -20,7 +21,8 @@ using namespace std; //============================================================================== /** */ -class JuicySFAudioProcessor : public AudioProcessor +class JuicySFAudioProcessor : public AudioProcessor, + public SharesParams { public: //============================================================================== @@ -65,15 +67,19 @@ public: MidiKeyboardState keyboardState; + virtual void setSoundFontPath(const String& value) override; + virtual String& getSoundFontPath() override; + // void subscribeToStateChanges(StateChangeSubscriber* subscriber); // void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber); int lastUIWidth, lastUIHeight; - String soundFontPath; private: void initialiseSynth(); + String soundFontPath; + FluidSynthModel fluidSynthModel; fluid_synth_t* fluidSynth; Synthesiser synth; diff --git a/Source/SharesParams.h b/Source/SharesParams.h new file mode 100644 index 0000000..8d0ad03 --- /dev/null +++ b/Source/SharesParams.h @@ -0,0 +1,19 @@ +// +// Created by Alex Birch on 10/04/2018. +// Copyright (c) 2018 Birchlabs. All rights reserved. +// + +#pragma once + +#include "../JuceLibraryCode/JuceHeader.h" + +class SharesParams { +public: + virtual ~SharesParams() {} + + virtual void setSoundFontPath(const String& value) = 0; + virtual String& getSoundFontPath() = 0; +}; + + +