diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index 89db518..958ef9c 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -83,33 +83,29 @@ void FluidSynthModel::changePresetImpl(int bank, int preset) { fluid_synth_program_select(synth, channel, sfont_id, static_cast(bank), static_cast(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); jassert(sfont != nullptr); - sfont->iteration_start(sfont); + fluid_sfont_iteration_start(sfont); - fluid_preset_t preset; - - sfont->iteration_next(sfont, &preset); - - return preset; + return fluid_sfont_iteration_next(sfont); } unique_ptr FluidSynthModel::getFirstBankAndPreset() { - fluid_preset_t preset = getFirstPreset(); + fluid_preset_t* preset = getFirstPreset(); int offset = fluid_synth_get_bank_offset(synth, sfont_id); - return make_unique(preset.get_banknum(&preset) + offset, preset.get_num(&preset)); + return make_unique(fluid_preset_get_banknum(preset) + offset, fluid_preset_get_num(preset)); }; void FluidSynthModel::selectFirstPreset() { - fluid_preset_t preset = getFirstPreset(); + fluid_preset_t* preset = getFirstPreset(); 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() { @@ -132,16 +128,16 @@ BanksToPresets FluidSynthModel::getBanks() { int offset = fluid_synth_get_bank_offset(synth, sfont_id); - sfont->iteration_start(sfont); + fluid_sfont_iteration_start(sfont); - fluid_preset_t preset; - - while(sfont->iteration_next(sfont, &preset)) { + for(fluid_preset_t* preset = fluid_sfont_iteration_next(sfont); + preset != nullptr; + preset = fluid_sfont_iteration_next(sfont)) { banksToPresets.insert(BanksToPresets::value_type( - preset.get_banknum(&preset) + offset, + fluid_preset_get_banknum(preset) + offset, *new Preset( - preset.get_num(&preset), - preset.get_name(&preset) + fluid_preset_get_num(preset), + fluid_preset_get_name(preset) ) )); } @@ -218,4 +214,4 @@ void FluidSynthModel::setSampleRate(float sampleRate) { return; } fluid_synth_set_sample_rate(synth, sampleRate); -} \ No newline at end of file +} diff --git a/Source/FluidSynthModel.h b/Source/FluidSynthModel.h index 957c870..fa1a79a 100644 --- a/Source/FluidSynthModel.h +++ b/Source/FluidSynthModel.h @@ -74,7 +74,7 @@ private: float currentSampleRate; - const fluid_preset_t getFirstPreset(); + fluid_preset_t* getFirstPreset(); void selectFirstPreset(); unique_ptr getFirstBankAndPreset(); @@ -91,4 +91,4 @@ private: ListenerList eventListeners; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FluidSynthModel) -}; \ No newline at end of file +}; diff --git a/Source/TablesComponent.cpp b/Source/TablesComponent.cpp index 3f8f1f1..6df4632 100644 --- a/Source/TablesComponent.cpp +++ b/Source/TablesComponent.cpp @@ -18,8 +18,8 @@ TablesComponent::TablesComponent( int selectedPreset = -1; if (currentPreset != nullptr) { - selectedBank = currentPreset->get_banknum(currentPreset); - selectedPreset = currentPreset->get_num(currentPreset); + selectedBank = fluid_preset_get_banknum(currentPreset); + selectedPreset = fluid_preset_get_num(currentPreset); } auto rowToPresetMapper = [this](const vector &row) { @@ -169,8 +169,8 @@ void TablesComponent::fontChanged(FluidSynthModel *, const String &) { fluid_preset_t* currentPreset = getCurrentPreset(); - selectedBank = currentPreset->get_banknum(currentPreset); - int selectedPreset = currentPreset->get_num(currentPreset); + selectedBank = fluid_preset_get_banknum(currentPreset); + int selectedPreset = fluid_preset_get_num(currentPreset); presetTable->setRows( mapPresets(