begins life with no soundfont and survives
This commit is contained in:
parent
86a0c005ef
commit
c78756aeef
@ -36,8 +36,7 @@ void FluidSynthModel::initialise() {
|
||||
|
||||
synth = new_fluid_synth(settings);
|
||||
|
||||
sfont_id = 0;
|
||||
loadFont("/Users/birch/Documents/soundfont/EarthBound.sf2");
|
||||
// loadFont("/Users/birch/Documents/soundfont/EarthBound.sf2");
|
||||
|
||||
|
||||
fluid_synth_set_gain(synth, 2.0);
|
||||
@ -85,11 +84,23 @@ void FluidSynthModel::selectFirstPreset() {
|
||||
BanksToPresets FluidSynthModel::getBanks() {
|
||||
BanksToPresets banksToPresets;
|
||||
|
||||
int soundfontCount = fluid_synth_sfcount(synth);
|
||||
|
||||
if (soundfontCount == 0) {
|
||||
// no soundfont selected
|
||||
return banksToPresets;
|
||||
}
|
||||
|
||||
fluid_sfont_t* sfont = fluid_synth_get_sfont_by_id(synth, sfont_id);
|
||||
if(sfont == nullptr) {
|
||||
// no soundfont found by that ID
|
||||
// the above guard (soundfontCount) protects us for the
|
||||
// main case we're expecting. this guard is just defensive programming.
|
||||
return banksToPresets;
|
||||
}
|
||||
|
||||
int offset = fluid_synth_get_bank_offset(synth, sfont_id);
|
||||
|
||||
jassert(sfont != nullptr);
|
||||
sfont->iteration_start(sfont);
|
||||
|
||||
fluid_preset_t preset;
|
||||
|
@ -14,9 +14,13 @@ TablesComponent::TablesComponent(
|
||||
initialised(false)
|
||||
{
|
||||
fluid_preset_t* currentPreset = getCurrentPreset();
|
||||
selectedBank = -1;
|
||||
int selectedPreset = -1;
|
||||
|
||||
selectedBank = currentPreset->get_banknum(currentPreset);
|
||||
int selectedPreset = currentPreset->get_num(currentPreset);
|
||||
if (currentPreset != nullptr) {
|
||||
selectedBank = currentPreset->get_banknum(currentPreset);
|
||||
selectedPreset = currentPreset->get_num(currentPreset);
|
||||
}
|
||||
|
||||
auto rowToPresetMapper = [this](const vector<string> &row) {
|
||||
return stoi(row[0]);
|
||||
@ -29,7 +33,7 @@ TablesComponent::TablesComponent(
|
||||
{"Preset", "Name"},
|
||||
mapPresets(
|
||||
banksToPresets,
|
||||
currentPreset->get_banknum(currentPreset)
|
||||
selectedBank
|
||||
),
|
||||
[this](int preset){
|
||||
this->onPresetSelected(preset);
|
||||
@ -71,7 +75,7 @@ Preset TablesComponent::getFirstPresetInBank(int bank) {
|
||||
}
|
||||
|
||||
void TablesComponent::onBankSelected(int bank) {
|
||||
if (!initialised) {
|
||||
if (!initialised || bank == -1) {
|
||||
return;
|
||||
}
|
||||
cout << "Bank " << bank << endl;
|
||||
@ -99,7 +103,7 @@ int TablesComponent::presetToIndexMapper(int preset) {
|
||||
}
|
||||
|
||||
void TablesComponent::onPresetSelected(int preset) {
|
||||
if (!initialised) {
|
||||
if (!initialised || preset == -1) {
|
||||
return;
|
||||
}
|
||||
cout << "Preset " << preset << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user