From 01b2b93d5f5fbb04915fcb62c91f4c38d393f97b Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 23 Jul 2023 12:20:19 +0200 Subject: [PATCH] Turn off pending notes and issue a warning --- src/midi/fluid_midi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index c8ad9d2c5..5df704a20 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -1641,6 +1641,23 @@ fluid_player_handle_reset_synth(void *data, const char *name, int value) player->reset_synth_between_songs = value; } +static int check_for_on_notes(fluid_synth_t *synth) +{ + fluid_voice_t* v[1024]; + int i, res=FALSE; + fluid_synth_get_voicelist(synth, v, FLUID_N_ELEMENTS(v), -1); + for(i=0; iend_pedals_disabled) { + if(check_for_on_notes(synth)) + { + FLUID_LOG(FLUID_WARN, "End of the MIDI file reached, but not all notes have received a note off event! OFFing them now! Run with --verbose to spot pending voices."); + } + for(i = 0; i < synth->midi_channels; i++) { fluid_synth_cc(player->synth, i, SUSTAIN_SWITCH, 0); fluid_synth_cc(player->synth, i, SOSTENUTO_SWITCH, 0); + fluid_synth_cc(player->synth, i, ALL_NOTES_OFF, 0); } player->end_pedals_disabled = 1;