From 77b52c86589a4b226e67eeb019d603f5683ab841 Mon Sep 17 00:00:00 2001 From: Tyrone Trevorrow <819705+tyrone-sudeium@users.noreply.github.com> Date: Sat, 18 Nov 2023 10:57:52 +1100 Subject: [PATCH] Midi: opt FluidSynth into NeedsSoftReset (Fixes #3135) --- src/audio_decoder_midi.cpp | 9 +++++---- src/decoder_fluidsynth.cpp | 4 ++++ src/decoder_fluidsynth.h | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/audio_decoder_midi.cpp b/src/audio_decoder_midi.cpp index 4985f92391..31b773ede7 100755 --- a/src/audio_decoder_midi.cpp +++ b/src/audio_decoder_midi.cpp @@ -402,16 +402,17 @@ void AudioDecoderMidi::meta_event(int event, const void* data, std::size_t size) void AudioDecoderMidi::reset() { // MIDI reset event - if (mididec->NeedsSoftReset()) { - // SoundOff every channel: necessary for synths like macOS which tend to get stuck - SendMessageToAllChannels(midimsg_all_sound_off(0)); - } SendMessageToAllChannels(midimsg_reset_all_controller(0)); // GM system on (resets most parameters) const unsigned char gm_reset[] = { 0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7 }; mididec->SendSysExMessage(gm_reset, sizeof(gm_reset)); + // SoundOff every channel: only necessary for synths like macOS which tend to get stuck + if (mididec->NeedsSoftReset()) { + SendMessageToAllChannels(midimsg_all_sound_off(0)); + } + // Set the Pitch bend range to 256 for (int channel = 0; channel < 16; channel++) { auto midi_msg = midimsg_make(midi_event_control_change, channel, midi_set_reg_param_number_upper, 0); diff --git a/src/decoder_fluidsynth.cpp b/src/decoder_fluidsynth.cpp index a4d6bf3c92..2c6506d023 100644 --- a/src/decoder_fluidsynth.cpp +++ b/src/decoder_fluidsynth.cpp @@ -347,4 +347,8 @@ fluid_synth_t *FluidSynthDecoder::GetSynthInstance() { } } +bool FluidSynthDecoder::NeedsSoftReset() { + return true; +} + #endif diff --git a/src/decoder_fluidsynth.h b/src/decoder_fluidsynth.h index a5e2896d8f..f0799413e3 100644 --- a/src/decoder_fluidsynth.h +++ b/src/decoder_fluidsynth.h @@ -69,6 +69,8 @@ class FluidSynthDecoder : public MidiDecoder { #endif }; + bool NeedsSoftReset() override; + private: #if defined(HAVE_FLUIDSYNTH) || defined(HAVE_FLUIDLITE) fluid_synth_t* GetSynthInstance();