rewrite source to compile against new public APIs of FluidSynth 2

This commit is contained in:
Alex Birch 2018-06-17 17:53:32 +01:00
parent fcdc743b3b
commit f220cbb6e2
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
3 changed files with 21 additions and 25 deletions

View File

@ -83,33 +83,29 @@ 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)); fluid_synth_program_select(synth, channel, sfont_id, static_cast<unsigned int>(bank), static_cast<unsigned int>(preset));
} }
const fluid_preset_t FluidSynthModel::getFirstPreset() { fluid_preset_t* FluidSynthModel::getFirstPreset() {
fluid_sfont_t* sfont = fluid_synth_get_sfont_by_id(synth, sfont_id); fluid_sfont_t* sfont = fluid_synth_get_sfont_by_id(synth, sfont_id);
jassert(sfont != nullptr); jassert(sfont != nullptr);
sfont->iteration_start(sfont); fluid_sfont_iteration_start(sfont);
fluid_preset_t preset; return fluid_sfont_iteration_next(sfont);
sfont->iteration_next(sfont, &preset);
return preset;
} }
unique_ptr<BankAndPreset> FluidSynthModel::getFirstBankAndPreset() { unique_ptr<BankAndPreset> FluidSynthModel::getFirstBankAndPreset() {
fluid_preset_t preset = getFirstPreset(); fluid_preset_t* preset = getFirstPreset();
int offset = fluid_synth_get_bank_offset(synth, sfont_id); int offset = fluid_synth_get_bank_offset(synth, sfont_id);
return make_unique<BankAndPreset>(preset.get_banknum(&preset) + offset, preset.get_num(&preset)); return make_unique<BankAndPreset>(fluid_preset_get_banknum(preset) + offset, fluid_preset_get_num(preset));
}; };
void FluidSynthModel::selectFirstPreset() { void FluidSynthModel::selectFirstPreset() {
fluid_preset_t preset = getFirstPreset(); fluid_preset_t* preset = getFirstPreset();
int offset = fluid_synth_get_bank_offset(synth, sfont_id); int offset = fluid_synth_get_bank_offset(synth, sfont_id);
changePreset(preset.get_banknum(&preset) + offset, preset.get_num(&preset)); changePreset(fluid_preset_get_banknum(preset) + offset, fluid_preset_get_num(preset));
} }
BanksToPresets FluidSynthModel::getBanks() { BanksToPresets FluidSynthModel::getBanks() {
@ -132,16 +128,16 @@ BanksToPresets FluidSynthModel::getBanks() {
int offset = fluid_synth_get_bank_offset(synth, sfont_id); int offset = fluid_synth_get_bank_offset(synth, sfont_id);
sfont->iteration_start(sfont); fluid_sfont_iteration_start(sfont);
fluid_preset_t preset; for(fluid_preset_t* preset = fluid_sfont_iteration_next(sfont);
preset != nullptr;
while(sfont->iteration_next(sfont, &preset)) { preset = fluid_sfont_iteration_next(sfont)) {
banksToPresets.insert(BanksToPresets::value_type( banksToPresets.insert(BanksToPresets::value_type(
preset.get_banknum(&preset) + offset, fluid_preset_get_banknum(preset) + offset,
*new Preset( *new Preset(
preset.get_num(&preset), fluid_preset_get_num(preset),
preset.get_name(&preset) fluid_preset_get_name(preset)
) )
)); ));
} }

View File

@ -74,7 +74,7 @@ private:
float currentSampleRate; float currentSampleRate;
const fluid_preset_t getFirstPreset(); fluid_preset_t* getFirstPreset();
void selectFirstPreset(); void selectFirstPreset();
unique_ptr<BankAndPreset> getFirstBankAndPreset(); unique_ptr<BankAndPreset> getFirstBankAndPreset();

View File

@ -18,8 +18,8 @@ TablesComponent::TablesComponent(
int selectedPreset = -1; int selectedPreset = -1;
if (currentPreset != nullptr) { if (currentPreset != nullptr) {
selectedBank = currentPreset->get_banknum(currentPreset); selectedBank = fluid_preset_get_banknum(currentPreset);
selectedPreset = currentPreset->get_num(currentPreset); selectedPreset = fluid_preset_get_num(currentPreset);
} }
auto rowToPresetMapper = [this](const vector<string> &row) { auto rowToPresetMapper = [this](const vector<string> &row) {
@ -169,8 +169,8 @@ void TablesComponent::fontChanged(FluidSynthModel *, const String &) {
fluid_preset_t* currentPreset = getCurrentPreset(); fluid_preset_t* currentPreset = getCurrentPreset();
selectedBank = currentPreset->get_banknum(currentPreset); selectedBank = fluid_preset_get_banknum(currentPreset);
int selectedPreset = currentPreset->get_num(currentPreset); int selectedPreset = fluid_preset_get_num(currentPreset);
presetTable->setRows( presetTable->setRows(
mapPresets( mapPresets(