progress in saving/loading presets/banks
This commit is contained in:
parent
e8177d51cd
commit
7dc05c72c9
|
@ -39,7 +39,14 @@ void FluidSynthModel::initialise() {
|
|||
|
||||
synth = new_fluid_synth(settings);
|
||||
|
||||
loadFont(sharesParams.getSoundFontPath());
|
||||
if (sharesParams.getSoundFontPath().isNotEmpty()) {
|
||||
loadFont(sharesParams.getSoundFontPath());
|
||||
if (sharesParams.getPreset() == -1 || sharesParams.getBank() == -1) {
|
||||
changePreset(sharesParams.getBank(), sharesParams.getPreset());
|
||||
} else {
|
||||
selectFirstPreset();
|
||||
}
|
||||
}
|
||||
|
||||
fluid_synth_set_gain(synth, 2.0);
|
||||
|
||||
|
@ -59,6 +66,15 @@ int FluidSynthModel::getChannel() {
|
|||
}
|
||||
|
||||
void FluidSynthModel::changePreset(int bank, int preset) {
|
||||
if (bank == -1 || preset == -1) {
|
||||
return;
|
||||
}
|
||||
changePresetImpl(bank, preset);
|
||||
sharesParams.setPreset(preset);
|
||||
sharesParams.setBank(bank);
|
||||
}
|
||||
|
||||
void FluidSynthModel::changePresetImpl(int bank, int preset) {
|
||||
fluid_synth_program_select(synth, channel, sfont_id, static_cast<unsigned int>(bank), static_cast<unsigned int>(preset));
|
||||
}
|
||||
|
||||
|
@ -142,16 +158,13 @@ void FluidSynthModel::unloadAndLoadFont(const String &absPath) {
|
|||
fluid_synth_sfunload(synth, sfont_id, 1);
|
||||
}
|
||||
loadFont(absPath);
|
||||
selectFirstPreset();
|
||||
}
|
||||
|
||||
void FluidSynthModel::loadFont(const String &absPath) {
|
||||
if (!shouldLoadFont(absPath)) {
|
||||
return;
|
||||
}
|
||||
currentSoundFontAbsPath = absPath;
|
||||
sfont_id++;
|
||||
fluid_synth_sfload(synth, absPath.toStdString().c_str(), 1);
|
||||
selectFirstPreset();
|
||||
}
|
||||
|
||||
FluidSynthModel::Listener::~Listener() {
|
||||
|
|
|
@ -74,6 +74,8 @@ private:
|
|||
void loadFont(const String &absPath);
|
||||
bool shouldLoadFont(const String &absPath);
|
||||
|
||||
void changePresetImpl(int bank, int preset);
|
||||
|
||||
bool initialised;
|
||||
unsigned int sfont_id;
|
||||
unsigned int channel;
|
||||
|
|
|
@ -23,6 +23,8 @@ JuicySFAudioProcessor::JuicySFAudioProcessor()
|
|||
lastUIWidth(400),
|
||||
lastUIHeight(300),
|
||||
soundFontPath(String()),
|
||||
lastPreset(-1),
|
||||
lastBank(-1),
|
||||
fluidSynthModel(*this)/*,
|
||||
pluginEditor(nullptr)*/
|
||||
{
|
||||
|
@ -195,6 +197,8 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData)
|
|||
xml.setAttribute ("uiWidth", lastUIWidth);
|
||||
xml.setAttribute ("uiHeight", lastUIHeight);
|
||||
xml.setAttribute ("soundFontPath", soundFontPath);
|
||||
xml.setAttribute ("preset", lastPreset);
|
||||
xml.setAttribute ("bank", lastBank);
|
||||
|
||||
// list<StateChangeSubscriber*>::iterator p;
|
||||
// for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
||||
|
@ -231,6 +235,8 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
|||
lastUIWidth = jmax (xmlState->getIntAttribute ("uiWidth", lastUIWidth), 400);
|
||||
lastUIHeight = jmax (xmlState->getIntAttribute ("uiHeight", lastUIHeight), 300);
|
||||
soundFontPath = xmlState->getStringAttribute ("soundFontPath", soundFontPath);
|
||||
lastPreset = xmlState->getIntAttribute ("preset", lastPreset);
|
||||
lastBank = xmlState->getIntAttribute ("bank", lastBank);
|
||||
|
||||
// Now reload our parameters..
|
||||
for (auto* param : getParameters())
|
||||
|
@ -238,6 +244,7 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
|||
p->setValue ((float) xmlState->getDoubleAttribute (p->paramID, p->getValue()));
|
||||
|
||||
fluidSynthModel.onFileNameChanged(soundFontPath);
|
||||
fluidSynthModel.changePreset(lastBank, lastPreset);
|
||||
|
||||
AudioProcessorEditor* editor = getActiveEditor();
|
||||
if (editor != nullptr) {
|
||||
|
@ -280,6 +287,18 @@ void JuicySFAudioProcessor::setSoundFontPath(const String& value) {
|
|||
String& JuicySFAudioProcessor::getSoundFontPath() {
|
||||
return soundFontPath;
|
||||
}
|
||||
int JuicySFAudioProcessor::getPreset() {
|
||||
return lastPreset;
|
||||
}
|
||||
int JuicySFAudioProcessor::getBank() {
|
||||
return lastBank;
|
||||
}
|
||||
void JuicySFAudioProcessor::setPreset(int preset) {
|
||||
lastPreset = preset;
|
||||
}
|
||||
void JuicySFAudioProcessor::setBank(int bank) {
|
||||
lastBank = bank;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// This creates new instances of the plugin..
|
||||
|
|
|
@ -69,6 +69,10 @@ public:
|
|||
|
||||
virtual void setSoundFontPath(const String& value) override;
|
||||
virtual String& getSoundFontPath() override;
|
||||
virtual int getPreset() override;
|
||||
virtual void setPreset(int preset) override;
|
||||
virtual int getBank() override;
|
||||
virtual void setBank(int bank) override;
|
||||
|
||||
// void subscribeToStateChanges(StateChangeSubscriber* subscriber);
|
||||
// void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber);
|
||||
|
@ -79,6 +83,8 @@ private:
|
|||
void initialiseSynth();
|
||||
|
||||
String soundFontPath;
|
||||
int lastPreset;
|
||||
int lastBank;
|
||||
|
||||
FluidSynthModel fluidSynthModel;
|
||||
fluid_synth_t* fluidSynth;
|
||||
|
|
|
@ -13,6 +13,10 @@ public:
|
|||
|
||||
virtual void setSoundFontPath(const String& value) = 0;
|
||||
virtual String& getSoundFontPath() = 0;
|
||||
virtual int getPreset() = 0;
|
||||
virtual void setPreset(int preset) = 0;
|
||||
virtual int getBank() = 0;
|
||||
virtual void setBank(int bank) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user