try to hook up soundfont path. perhaps encountering circular dependency on FSModel's inclusion of my plugin processor
This commit is contained in:
parent
9bbb27d780
commit
27b9dfb9df
|
@ -7,13 +7,15 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
FluidSynthModel::FluidSynthModel() {
|
||||
initialised = false;
|
||||
channel = 0;
|
||||
sfont_id = 0;
|
||||
settings = nullptr;
|
||||
synth = nullptr;
|
||||
}
|
||||
FluidSynthModel::FluidSynthModel()
|
||||
: processor(nullptr),
|
||||
synth(nullptr),
|
||||
settings(nullptr),
|
||||
initialised(false),
|
||||
sfont_id(0),
|
||||
channel(0)
|
||||
|
||||
{}
|
||||
|
||||
FluidSynthModel::~FluidSynthModel() {
|
||||
if (initialised) {
|
||||
|
@ -25,7 +27,8 @@ FluidSynthModel::~FluidSynthModel() {
|
|||
}
|
||||
}
|
||||
|
||||
void FluidSynthModel::initialise() {
|
||||
void FluidSynthModel::initialise(JuicySFAudioProcessor& p) {
|
||||
processor = &p;
|
||||
// if (initialised) {
|
||||
// delete_fluid_synth(synth);
|
||||
// delete_fluid_settings(settings);
|
||||
|
@ -36,8 +39,9 @@ void FluidSynthModel::initialise() {
|
|||
|
||||
synth = new_fluid_synth(settings);
|
||||
|
||||
// loadFont("/Users/birch/Documents/soundfont/EarthBound.sf2");
|
||||
|
||||
if (processor->soundFontPath.isNotEmpty()) {
|
||||
loadFont(processor->soundFontPath.toStdString());
|
||||
}
|
||||
|
||||
fluid_synth_set_gain(synth, 2.0);
|
||||
|
||||
|
@ -127,7 +131,7 @@ fluid_synth_t* FluidSynthModel::getSynth() {
|
|||
|
||||
void FluidSynthModel::onFileNameChanged(const string &absPath) {
|
||||
unloadAndLoadFont(absPath);
|
||||
eventListeners.call(&FluidSynthModel::Listener::fontChanged, this);
|
||||
eventListeners.call(&FluidSynthModel::Listener::fontChanged, this, absPath);
|
||||
}
|
||||
|
||||
void FluidSynthModel::unloadAndLoadFont(const string &absPath) {
|
||||
|
@ -147,7 +151,10 @@ void FluidSynthModel::loadFont(const string &absPath) {
|
|||
FluidSynthModel::Listener::~Listener() {
|
||||
}
|
||||
|
||||
void FluidSynthModel::Listener::fontChanged(FluidSynthModel *) {
|
||||
void FluidSynthModel::Listener::fontChanged(FluidSynthModel * model, const string &absPath) {
|
||||
if (model->initialised) {
|
||||
model->processor->soundFontPath = String(absPath);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include <fluidsynth.h>
|
||||
#include <memory>
|
||||
#include "PresetsToBanks.h"
|
||||
|
@ -19,7 +20,7 @@ public:
|
|||
~FluidSynthModel();
|
||||
|
||||
fluid_synth_t* getSynth();
|
||||
void initialise();
|
||||
void initialise(JuicySFAudioProcessor& p);
|
||||
|
||||
BanksToPresets getBanks();
|
||||
|
||||
|
@ -41,7 +42,7 @@ public:
|
|||
virtual ~Listener();
|
||||
|
||||
/** Called when the button is clicked. */
|
||||
virtual void fontChanged (FluidSynthModel*);
|
||||
virtual void fontChanged (FluidSynthModel*, const string &absPath);
|
||||
};
|
||||
|
||||
/** Registers a listener to receive events when this button's state changes.
|
||||
|
@ -56,6 +57,8 @@ public:
|
|||
void removeListener (Listener* listener);
|
||||
|
||||
private:
|
||||
JuicySFAudioProcessor* processor;
|
||||
|
||||
fluid_synth_t* synth;
|
||||
fluid_settings_t* settings;
|
||||
// fluid_audio_driver_t* driver;
|
||||
|
|
|
@ -21,8 +21,8 @@ JuicySFAudioProcessor::JuicySFAudioProcessor()
|
|||
: AudioProcessor (getBusesProperties()),
|
||||
lastUIWidth(400),
|
||||
lastUIHeight(300),
|
||||
fluidSynthModel(),
|
||||
soundFontPath(String())
|
||||
soundFontPath(String()),
|
||||
fluidSynthModel()
|
||||
{
|
||||
initialiseSynth();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ JuicySFAudioProcessor::~JuicySFAudioProcessor()
|
|||
}
|
||||
|
||||
void JuicySFAudioProcessor::initialiseSynth() {
|
||||
fluidSynthModel.initialise();
|
||||
fluidSynthModel.initialise(*this);
|
||||
|
||||
fluidSynth = fluidSynthModel.getSynth();
|
||||
|
||||
|
@ -191,6 +191,7 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData)
|
|||
// add some attributes to it..
|
||||
xml.setAttribute ("uiWidth", lastUIWidth);
|
||||
xml.setAttribute ("uiHeight", lastUIHeight);
|
||||
xml.setAttribute ("soundFontPath", soundFontPath);
|
||||
|
||||
// list<StateChangeSubscriber*>::iterator p;
|
||||
// for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
||||
|
@ -226,6 +227,7 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
|||
// ok, now pull out our last window size..
|
||||
lastUIWidth = jmax (xmlState->getIntAttribute ("uiWidth", lastUIWidth), 400);
|
||||
lastUIHeight = jmax (xmlState->getIntAttribute ("uiHeight", lastUIHeight), 300);
|
||||
soundFontPath = xmlState->getStringAttribute ("soundFontPath", soundFontPath);
|
||||
|
||||
// Now reload our parameters..
|
||||
for (auto* param : getParameters())
|
||||
|
|
|
@ -164,7 +164,7 @@ bool TablesComponent::keyPressed(const KeyPress &key) {
|
|||
return presetTable->keyPressed(key);
|
||||
}
|
||||
|
||||
void TablesComponent::fontChanged(FluidSynthModel *) {
|
||||
void TablesComponent::fontChanged(FluidSynthModel *, const string &) {
|
||||
banksToPresets = fluidSynthModel->getBanks();
|
||||
|
||||
fluid_preset_t* currentPreset = getCurrentPreset();
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
void resized() override;
|
||||
|
||||
bool keyPressed(const KeyPress &key) override;
|
||||
void fontChanged(FluidSynthModel *) override;
|
||||
void fontChanged(FluidSynthModel *, const string &) override;
|
||||
|
||||
private:
|
||||
FluidSynthModel* fluidSynthModel;
|
||||
|
|
Loading…
Reference in New Issue
Block a user