Skip to content

Commit

Permalink
Fluidsynth: Exhaust the internal synth buffer to prevent playing of o…
Browse files Browse the repository at this point in the history
…ld samples after long pauses

Fix #3135 (this time for real)
  • Loading branch information
Ghabry committed Sep 1, 2024
1 parent 1efa7a9 commit b91639f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/decoder_fluidsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ FluidSynthDecoder::~FluidSynthDecoder() {
--instances;
assert(instances >= 0);

if (!use_global_synth) {
if (use_global_synth) {
// Exhaust the internal synth buffer
// Prevents that old samples play when a new Midi song starts (even when there was a longer break between them)
std::array<uint8_t, 64 * 4> buffer;
fluid_synth_write_s16(global_synth.get(), buffer.size() / 4, buffer.data(), 0, 2, buffer.data(), 1, 2);
} else {
delete_fluid_synth(local_synth);
}
}
Expand Down

0 comments on commit b91639f

Please sign in to comment.