fixed circular reference

This commit is contained in:
Alex Birch 2018-04-10 01:17:50 +01:00
parent 27b9dfb9df
commit 9427a029b9
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
6 changed files with 46 additions and 11 deletions

View File

@ -235,6 +235,7 @@
560D40E30164CA9D05C6AC3B /* MyColours.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MyColours.h; path = ../../Source/MyColours.h; sourceTree = SOURCE_ROOT; }; 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; }; 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 = "<group>"; }; 596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StateChangeSubscriber.h; path = ../../Source/StateChangeSubscriber.h; sourceTree = "<group>"; };
59672C6315E5D06A21B4A2F2 /* SharesParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharesParams.h; path = ../../Source/SharesParams.h; sourceTree = "<group>"; };
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; }; 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; }; 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; }; 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 */, 457D4946B07CC4A74EB0FAE1 /* PluginEditor.cpp */,
B3E8D1BE528BBA1B6004672E /* PluginEditor.h */, B3E8D1BE528BBA1B6004672E /* PluginEditor.h */,
596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */, 596723D094319DA06FDDCDC6 /* StateChangeSubscriber.h */,
59672C6315E5D06A21B4A2F2 /* SharesParams.h */,
); );
name = Source; name = Source;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@ -8,7 +8,7 @@
using namespace std; using namespace std;
FluidSynthModel::FluidSynthModel() FluidSynthModel::FluidSynthModel()
: processor(nullptr), : sharesParams(nullptr),
synth(nullptr), synth(nullptr),
settings(nullptr), settings(nullptr),
initialised(false), initialised(false),
@ -27,8 +27,8 @@ FluidSynthModel::~FluidSynthModel() {
} }
} }
void FluidSynthModel::initialise(JuicySFAudioProcessor& p) { void FluidSynthModel::initialise(SharesParams& p) {
processor = &p; sharesParams = &p;
// if (initialised) { // if (initialised) {
// delete_fluid_synth(synth); // delete_fluid_synth(synth);
// delete_fluid_settings(settings); // delete_fluid_settings(settings);
@ -39,8 +39,8 @@ void FluidSynthModel::initialise(JuicySFAudioProcessor& p) {
synth = new_fluid_synth(settings); synth = new_fluid_synth(settings);
if (processor->soundFontPath.isNotEmpty()) { if (sharesParams->getSoundFontPath().isNotEmpty()) {
loadFont(processor->soundFontPath.toStdString()); loadFont(sharesParams->getSoundFontPath().toStdString());
} }
fluid_synth_set_gain(synth, 2.0); fluid_synth_set_gain(synth, 2.0);
@ -153,7 +153,7 @@ FluidSynthModel::Listener::~Listener() {
void FluidSynthModel::Listener::fontChanged(FluidSynthModel * model, const string &absPath) { void FluidSynthModel::Listener::fontChanged(FluidSynthModel * model, const string &absPath) {
if (model->initialised) { if (model->initialised) {
model->processor->soundFontPath = String(absPath); model->sharesParams->setSoundFontPath(String(absPath));
} }
} }

View File

@ -5,7 +5,7 @@
#pragma once #pragma once
#include "../JuceLibraryCode/JuceHeader.h" #include "../JuceLibraryCode/JuceHeader.h"
#include "PluginProcessor.h" #include "SharesParams.h"
#include <fluidsynth.h> #include <fluidsynth.h>
#include <memory> #include <memory>
#include "PresetsToBanks.h" #include "PresetsToBanks.h"
@ -20,7 +20,7 @@ public:
~FluidSynthModel(); ~FluidSynthModel();
fluid_synth_t* getSynth(); fluid_synth_t* getSynth();
void initialise(JuicySFAudioProcessor& p); void initialise(SharesParams& p);
BanksToPresets getBanks(); BanksToPresets getBanks();
@ -57,7 +57,7 @@ public:
void removeListener (Listener* listener); void removeListener (Listener* listener);
private: private:
JuicySFAudioProcessor* processor; SharesParams* sharesParams;
fluid_synth_t* synth; fluid_synth_t* synth;
fluid_settings_t* settings; fluid_settings_t* settings;

View File

@ -254,6 +254,14 @@ FluidSynthModel* JuicySFAudioProcessor::getFluidSynthModel() {
return &fluidSynthModel; return &fluidSynthModel;
} }
void JuicySFAudioProcessor::setSoundFontPath(const String& value) {
soundFontPath = value;
}
String& JuicySFAudioProcessor::getSoundFontPath() {
return soundFontPath;
}
//============================================================================== //==============================================================================
// This creates new instances of the plugin.. // This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter() AudioProcessor* JUCE_CALLTYPE createPluginFilter()

View File

@ -13,6 +13,7 @@
#include "../JuceLibraryCode/JuceHeader.h" #include "../JuceLibraryCode/JuceHeader.h"
#include "FluidSynthModel.h" #include "FluidSynthModel.h"
#include "StateChangeSubscriber.h" #include "StateChangeSubscriber.h"
#include "SharesParams.h"
#include <list> #include <list>
using namespace std; using namespace std;
@ -20,7 +21,8 @@ using namespace std;
//============================================================================== //==============================================================================
/** /**
*/ */
class JuicySFAudioProcessor : public AudioProcessor class JuicySFAudioProcessor : public AudioProcessor,
public SharesParams
{ {
public: public:
//============================================================================== //==============================================================================
@ -65,15 +67,19 @@ public:
MidiKeyboardState keyboardState; MidiKeyboardState keyboardState;
virtual void setSoundFontPath(const String& value) override;
virtual String& getSoundFontPath() override;
// void subscribeToStateChanges(StateChangeSubscriber* subscriber); // void subscribeToStateChanges(StateChangeSubscriber* subscriber);
// void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber); // void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber);
int lastUIWidth, lastUIHeight; int lastUIWidth, lastUIHeight;
String soundFontPath;
private: private:
void initialiseSynth(); void initialiseSynth();
String soundFontPath;
FluidSynthModel fluidSynthModel; FluidSynthModel fluidSynthModel;
fluid_synth_t* fluidSynth; fluid_synth_t* fluidSynth;
Synthesiser synth; Synthesiser synth;

19
Source/SharesParams.h Normal file
View File

@ -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;
};