V45.36: fix SF2 preset thieu tren soundfont non-GM (Cajon.sf2) - fluidsynth error 'There is no preset with bank number 0 and preset number 40/44' lam track violin/contrabass silent. selectProgram/programChange gio fallback 3 bac: (bank,program) -> (0,program) -> (0,0) thay vi chi bank128->bank0 (fluidsynth giu preset cu -> sai am). Rebuild daw_vst_bridge MSBuild 20260901-1003.

This commit is contained in:
2026-09-01 10:03:55 +07:00
parent 5467c50fb7
commit 60a87626f0
3 changed files with 18 additions and 10 deletions
+18 -10
View File
@@ -69,16 +69,27 @@ bool FluidSynthInstrument::init(double sampleRate, uint32_t maxBlockSize) {
return synth != nullptr;
}
// SF2 fallback: nhieu soundfont khong co bank 128 (GM drum) hoac thieu preset
// GM (vd Cajon.sf2 chi co it preset, khong co violin 40 / contrabass 44) —
// neu select fail thi lui dan (bank,program) -> (0,program) -> (0,0) de khong
// cam (fluidsynth giu preset cu -> sai am) hay silent (log error preset 40/44).
static void selectPresetFallback(fluid_synth_t* synth, int sfontId, uint32_t channel,
uint32_t& bank, uint32_t& program) {
if (fluid_synth_program_select(synth, channel, sfontId, bank, program) == FLUID_OK) return;
if (bank != 0 && fluid_synth_program_select(synth, channel, sfontId, 0, program) == FLUID_OK) {
bank = 0;
return;
}
bank = 0;
program = 0;
fluid_synth_program_select(synth, channel, sfontId, 0, 0);
}
void FluidSynthInstrument::selectProgram(uint32_t channel, uint32_t bank, uint32_t program) {
if (!synth || channel >= 16) return;
bank_[channel] = bank;
program_[channel] = program;
// SF2 fallback: nhieu soundfont khong co bank 128 (GM drum) — neu select
// fail, thu lai bank 0 de khong cam (fluidsynth giu preset cu -> sai am).
if (fluid_synth_program_select(FS_SYNTH, channel, sfontId, bank, program) != FLUID_OK && bank != 0) {
bank_[channel] = 0;
fluid_synth_program_select(FS_SYNTH, channel, sfontId, 0, program);
}
selectPresetFallback(FS_SYNTH, sfontId, channel, bank_[channel], program_[channel]);
}
void FluidSynthInstrument::noteOn(uint32_t channel, uint32_t pitch, float velocity, uint32_t sampleOffset) {
@@ -105,10 +116,7 @@ void FluidSynthInstrument::programChange(uint32_t channel, uint32_t program) {
// Dung bank da nhan tu CC0/CC32 — bank hardcode 0 lam preset o bank != 0
// khong duoc chon (fluid giu preset cu -> ra piano sai).
program_[channel] = program;
if (fluid_synth_program_select(FS_SYNTH, channel, sfontId, bank_[channel], program) != FLUID_OK && bank_[channel] != 0) {
bank_[channel] = 0;
fluid_synth_program_select(FS_SYNTH, channel, sfontId, 0, program);
}
selectPresetFallback(FS_SYNTH, sfontId, channel, bank_[channel], program_[channel]);
}
void FluidSynthInstrument::pitchBend(uint32_t channel, uint32_t bend14) {
Binary file not shown.