Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 2 bugs that prevented GS banks from being selected. #55

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/mididevices/music_fluidsynth_mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ void FluidSynthMIDIDevice::HandleEvent(int status, int parm1, int parm2)

void FluidSynthMIDIDevice::HandleLongEvent(const uint8_t *data, int len)
{
if (len > 1 && (data[0] == 0xF0 || data[0] == 0xF7))
constexpr int excludedByteCount = 2; // 0xF0 (first byte) and 0xF7 (last byte) are not given to FluidSynth.
if (len > excludedByteCount && data[0] == 0xF0 && data[len - 1] == 0xF7)
{
fluid_synth_sysex(FluidSynth, (const char *)data + 1, len - 1, NULL, NULL, NULL, 0);
fluid_synth_sysex(FluidSynth, (const char *)data + 1, len - excludedByteCount, NULL, NULL, NULL, 0);
}
}

Expand Down
11 changes: 10 additions & 1 deletion source/musicformats/music_midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,14 +815,23 @@ int MIDIStreamer::FillBuffer(int buffer_num, int max_events, uint32_t max_time)
if (InitialPlayback)
{
InitialPlayback = false;
// Send the GS System Reset SysEx message.
// Send the GM System Enable SysEx message.
events[0] = 0; // dwDeltaTime
events[1] = 0; // dwStreamID
events[2] = (MEVENT_LONGMSG << 24) | 6; // dwEvent
events[3] = MAKE_ID(0xf0, 0x7e, 0x7f, 0x09); // dwParms[0]
events[4] = MAKE_ID(0x01, 0xf7, 0x00, 0x00); // dwParms[1]
events += 5;

// Send the GS DT1 MODE SET GS Reset SysEx message.
events[0] = 0; // dwDeltaTime
events[1] = 0; // dwStreamID
events[2] = (MEVENT_LONGMSG << 24) | 11; // dwEvent
events[3] = MAKE_ID(0xf0, 0x41, 0x7f, 0x42); // dwParms[0]
events[4] = MAKE_ID(0x12, 0x40, 0x00, 0x7f); // dwParms[1]
events[5] = MAKE_ID(0x00, 0x41, 0xf7, 0x00); // dwParms[2]
events += 6;

// Send the full master volume SysEx message.
events[0] = 0; // dwDeltaTime
events[1] = 0; // dwStreamID
Expand Down
Loading