fixed circular reference
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include "SharesParams.h"
|
||||
#include <fluidsynth.h>
|
||||
#include <memory>
|
||||
#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;
|
||||
|
@ -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()
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "FluidSynthModel.h"
|
||||
#include "StateChangeSubscriber.h"
|
||||
#include "SharesParams.h"
|
||||
#include <list>
|
||||
|
||||
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;
|
||||
|
19
Source/SharesParams.h
Normal file
19
Source/SharesParams.h
Normal 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;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user