change to construction-time reference
This commit is contained in:
parent
9427a029b9
commit
d7b87fe84f
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
FluidSynthModel::FluidSynthModel()
|
FluidSynthModel::FluidSynthModel(SharesParams& p)
|
||||||
: sharesParams(nullptr),
|
: sharesParams(p),
|
||||||
synth(nullptr),
|
synth(nullptr),
|
||||||
settings(nullptr),
|
settings(nullptr),
|
||||||
initialised(false),
|
initialised(false),
|
||||||
@ -27,8 +27,7 @@ FluidSynthModel::~FluidSynthModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluidSynthModel::initialise(SharesParams& p) {
|
void FluidSynthModel::initialise() {
|
||||||
sharesParams = &p;
|
|
||||||
// if (initialised) {
|
// if (initialised) {
|
||||||
// delete_fluid_synth(synth);
|
// delete_fluid_synth(synth);
|
||||||
// delete_fluid_settings(settings);
|
// delete_fluid_settings(settings);
|
||||||
@ -39,8 +38,8 @@ void FluidSynthModel::initialise(SharesParams& p) {
|
|||||||
|
|
||||||
synth = new_fluid_synth(settings);
|
synth = new_fluid_synth(settings);
|
||||||
|
|
||||||
if (sharesParams->getSoundFontPath().isNotEmpty()) {
|
if (sharesParams.getSoundFontPath().isNotEmpty()) {
|
||||||
loadFont(sharesParams->getSoundFontPath().toStdString());
|
loadFont(sharesParams.getSoundFontPath().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
fluid_synth_set_gain(synth, 2.0);
|
fluid_synth_set_gain(synth, 2.0);
|
||||||
@ -152,9 +151,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) {
|
model->sharesParams.setSoundFontPath(String(absPath));
|
||||||
model->sharesParams->setSoundFontPath(String(absPath));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -16,11 +16,11 @@ using std::shared_ptr;
|
|||||||
|
|
||||||
class FluidSynthModel {
|
class FluidSynthModel {
|
||||||
public:
|
public:
|
||||||
FluidSynthModel();
|
FluidSynthModel(SharesParams& p);
|
||||||
~FluidSynthModel();
|
~FluidSynthModel();
|
||||||
|
|
||||||
fluid_synth_t* getSynth();
|
fluid_synth_t* getSynth();
|
||||||
void initialise(SharesParams& p);
|
void initialise();
|
||||||
|
|
||||||
BanksToPresets getBanks();
|
BanksToPresets getBanks();
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
void removeListener (Listener* listener);
|
void removeListener (Listener* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharesParams* sharesParams;
|
SharesParams& sharesParams;
|
||||||
|
|
||||||
fluid_synth_t* synth;
|
fluid_synth_t* synth;
|
||||||
fluid_settings_t* settings;
|
fluid_settings_t* settings;
|
||||||
|
@ -22,7 +22,7 @@ JuicySFAudioProcessor::JuicySFAudioProcessor()
|
|||||||
lastUIWidth(400),
|
lastUIWidth(400),
|
||||||
lastUIHeight(300),
|
lastUIHeight(300),
|
||||||
soundFontPath(String()),
|
soundFontPath(String()),
|
||||||
fluidSynthModel()
|
fluidSynthModel(*this)
|
||||||
{
|
{
|
||||||
initialiseSynth();
|
initialiseSynth();
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ JuicySFAudioProcessor::~JuicySFAudioProcessor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JuicySFAudioProcessor::initialiseSynth() {
|
void JuicySFAudioProcessor::initialiseSynth() {
|
||||||
fluidSynthModel.initialise(*this);
|
fluidSynthModel.initialise();
|
||||||
|
|
||||||
fluidSynth = fluidSynthModel.getSynth();
|
fluidSynth = fluidSynthModel.getSynth();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user