successfully setting banks and presets
This commit is contained in:
parent
fc1d45d77c
commit
d8ce91e666
|
@ -208,11 +208,32 @@ void FluidSynthModel::initialise() {
|
||||||
|
|
||||||
void FluidSynthModel::parameterChanged(const String& parameterID, float newValue) {
|
void FluidSynthModel::parameterChanged(const String& parameterID, float newValue) {
|
||||||
if (parameterID == "bank") {
|
if (parameterID == "bank") {
|
||||||
|
// RangedAudioParameter *param {valueTreeState.getParameter("bank")};
|
||||||
|
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
|
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
|
// int value{castParam->get()};
|
||||||
|
|
||||||
|
int bank, preset;
|
||||||
|
{
|
||||||
RangedAudioParameter *param {valueTreeState.getParameter("bank")};
|
RangedAudioParameter *param {valueTreeState.getParameter("bank")};
|
||||||
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
int value{castParam->get()};
|
bank = castParam->get();
|
||||||
fluid_synth_bank_select(synth.get(), channel, value);
|
}
|
||||||
|
{
|
||||||
|
RangedAudioParameter *param {valueTreeState.getParameter("preset")};
|
||||||
|
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
|
preset = castParam->get();
|
||||||
|
}
|
||||||
|
fluid_synth_program_select(
|
||||||
|
synth.get(),
|
||||||
|
channel,
|
||||||
|
sfont_id,
|
||||||
|
static_cast<unsigned int>(bank),
|
||||||
|
static_cast<unsigned int>(preset));
|
||||||
|
|
||||||
|
// fluid_synth_bank_select(synth.get(), channel, value);
|
||||||
refreshPresets();
|
refreshPresets();
|
||||||
// fluid_sfont_t* sfont{fluid_synth_get_sfont_by_id(synth.get(), sfont_id)};
|
// fluid_sfont_t* sfont{fluid_synth_get_sfont_by_id(synth.get(), sfont_id)};
|
||||||
// fluid_sfont_iteration_start(sfont);
|
// fluid_sfont_iteration_start(sfont);
|
||||||
|
@ -221,10 +242,26 @@ void FluidSynthModel::parameterChanged(const String& parameterID, float newValue
|
||||||
// int bank{fluid_preset_get_banknum(presetObj) + offset};
|
// int bank{fluid_preset_get_banknum(presetObj) + offset};
|
||||||
// int preset{fluid_preset_get_num(presetObj)};
|
// int preset{fluid_preset_get_num(presetObj)};
|
||||||
} else if (parameterID == "preset") {
|
} else if (parameterID == "preset") {
|
||||||
|
int bank, preset;
|
||||||
|
{
|
||||||
|
RangedAudioParameter *param {valueTreeState.getParameter("bank")};
|
||||||
|
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
|
bank = castParam->get();
|
||||||
|
}
|
||||||
|
{
|
||||||
RangedAudioParameter *param {valueTreeState.getParameter("preset")};
|
RangedAudioParameter *param {valueTreeState.getParameter("preset")};
|
||||||
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
int value{castParam->get()};
|
preset = castParam->get();
|
||||||
|
}
|
||||||
|
// int bank{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
||||||
|
fluid_synth_program_select(
|
||||||
|
synth.get(),
|
||||||
|
channel,
|
||||||
|
sfont_id,
|
||||||
|
static_cast<unsigned int>(bank),
|
||||||
|
static_cast<unsigned int>(preset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,18 +409,19 @@ void FluidSynthModel::refreshBanks() {
|
||||||
fluid_sfont_t* sfont {fluid_synth_get_sfont_by_id(synth.get(), sfont_id)};
|
fluid_sfont_t* sfont {fluid_synth_get_sfont_by_id(synth.get(), sfont_id)};
|
||||||
ValueTree banks{"banks"};
|
ValueTree banks{"banks"};
|
||||||
if (sfont != nullptr) {
|
if (sfont != nullptr) {
|
||||||
int initialBank{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
// int initialBankOffset{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
||||||
banks.appendChild({ "bank", {
|
banks.appendChild({ "bank", {
|
||||||
{ "num", initialBank },
|
{ "num", /* initialBankOffset */ 0 },
|
||||||
}, {} }, nullptr);
|
}, {} }, nullptr);
|
||||||
int greatestPersistedBank{initialBank};
|
// int greatestPersistedBank{initialBankOffset};
|
||||||
|
int greatestPersistedBank{0};
|
||||||
|
|
||||||
fluid_sfont_iteration_start(sfont);
|
fluid_sfont_iteration_start(sfont);
|
||||||
|
|
||||||
for(fluid_preset_t* preset {fluid_sfont_iteration_next(sfont)};
|
for(fluid_preset_t* preset {fluid_sfont_iteration_next(sfont)};
|
||||||
preset != nullptr;
|
preset != nullptr;
|
||||||
preset = fluid_sfont_iteration_next(sfont)) {
|
preset = fluid_sfont_iteration_next(sfont)) {
|
||||||
int bank{fluid_preset_get_banknum(preset) + initialBank};
|
int bank{fluid_preset_get_banknum(preset) /* + initialBankOffset */};
|
||||||
if (bank > greatestPersistedBank) {
|
if (bank > greatestPersistedBank) {
|
||||||
banks.appendChild({ "bank", {
|
banks.appendChild({ "bank", {
|
||||||
{ "num", bank },
|
{ "num", bank },
|
||||||
|
@ -406,14 +444,14 @@ void FluidSynthModel::refreshPresets() {
|
||||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
int value{castParam->get()};
|
int value{castParam->get()};
|
||||||
|
|
||||||
int initialBank{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
// int initialBank{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
||||||
|
|
||||||
fluid_sfont_iteration_start(sfont);
|
fluid_sfont_iteration_start(sfont);
|
||||||
|
|
||||||
for(fluid_preset_t* preset {fluid_sfont_iteration_next(sfont)};
|
for(fluid_preset_t* preset {fluid_sfont_iteration_next(sfont)};
|
||||||
preset != nullptr;
|
preset != nullptr;
|
||||||
preset = fluid_sfont_iteration_next(sfont)) {
|
preset = fluid_sfont_iteration_next(sfont)) {
|
||||||
int bank{fluid_preset_get_banknum(preset) + initialBank};
|
int bank{fluid_preset_get_banknum(preset) /* + initialBank */};
|
||||||
if (bank == value) {
|
if (bank == value) {
|
||||||
presets.appendChild({ "preset", {
|
presets.appendChild({ "preset", {
|
||||||
{ "num", fluid_preset_get_num(preset) },
|
{ "num", fluid_preset_get_num(preset) },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user