Skip to content

MacOS Fixes#3148

Merged
3 commits merged into
EasyRPG:masterfrom
tyrone-sudeium:macos-fixes
Nov 20, 2023
Merged

MacOS Fixes#3148
3 commits merged into
EasyRPG:masterfrom
tyrone-sudeium:macos-fixes

Conversation

@tyrone-sudeium
Copy link
Copy Markdown
Member

@tyrone-sudeium tyrone-sudeium commented Nov 16, 2023

Fixes three issues:

  • 5-beatles-lustig.mid from Unterwegs in Duesterburg causes a crash in MusicDeviceMIDIEvent due to a bogus MIDI message. We're in some good company here, both VLC (at least on macOS) and Sekaiju also crash attempting to play it.
  • I also noticed Unterwegs in Duesterburg in macOS has a lot of stuck notes issues in macOS (i.e when changing BGM, some notes from the previous track will be permanently stuck on). I tracked it down to Fix broken native midiout playback after playing a song that alters pitch bend #3090 removing the midimsg_all_sound_off from reset, to be more accurate with Harmony. Harmony never supported macOS, and the macOS synthesizer being prone to stuck notes is why those messages were there in the first place. I'm open to other solutions to fix this, but without it, MIDI is pretty scuffed on Macs.
  • The -G Xcode generator in cmake will completely fail to build (at least on Xcode 15), due to a fundamental disconnect between cmake and Xcode when you have multiple code files with the same filename (like src/audio.cpp vs src/platform/sdl/audio.cpp). Simplest workaround is to remove the duplication by renaming the two files that had duplicated names.

Fix #3135

Copy link
Copy Markdown
Member

@Ghabry Ghabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You inserted space instead of tab for the indent.
  2. Can you add this NeedsSoftReset to Decoder Fluidsynth? Has a similiar issue and your fix is more universal.

Comment thread src/audio_decoder_midi.cpp Outdated
// 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));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry have to ask you for another small change:

Can you move this new code block between the GM reset and the pitch bend block? (I hope this doesn't break macOS?)

Tested this again in fluidsynth and the all sound off will not work properly when executed before the GM reset (same audio glitch remains).

        // GM system on (resets most parameters)
        const unsigned char gm_reset[] = { 0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7 };
        mididec->SendSysExMessage(gm_reset, sizeof(gm_reset));

        // MIDI reset event
        if (mididec->NeedsSoftReset()) {
                // SoundOff every channel: necessary for synths like macOS which tend to g>
                SendMessageToAllChannels(midimsg_all_sound_off(0));
        }

        // Set the Pitch bend range to 256
        for (int channel = 0; channel < 16; channel++) {

Copy link
Copy Markdown
Member

@Ghabry Ghabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, works now with fluidsynth 👍

@ghost ghost merged commit 48c0468 into EasyRPG:master Nov 20, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

MIDI with soundfont - interrupting a MIDI with BGM (OFF) and playing another MIDI will play a note of the previous MIDI before playing the new one

2 participants