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

MacOS Fixes #3148

Merged
merged 3 commits into from Nov 20, 2023
Merged

MacOS Fixes #3148

merged 3 commits into from Nov 20, 2023

Conversation

tyrone-sudeium
Copy link
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
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.

@@ -378,6 +402,10 @@ 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));
Copy link
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
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 👍

@fdelapena fdelapena merged commit 48c0468 into EasyRPG:master Nov 20, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants