We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5356

Summary: [PATCH] native_midi_macosx: volume should be set before starting playing
Product: SDL_mixer Reporter: michaeljosephmaltese
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: unspecified   
Hardware: All   
OS: Mac OS X (All)   
Attachments: native_midi_macosx: set volume before starting playing

Description michaeljosephmaltese 2020-11-18 20:42:29 UTC
Created attachment 4525 [details]
native_midi_macosx: set volume before starting playing

On macOS, the native MIDI backend applies volume after the MIDI file starts playing, which can lead to a split second of music at an incorrect volume (e.g. say you want to fade it in, or just have it start muted).

I tracked this to native_midi_start in native_midi_macosx.c, which calls MusicPlayerStart before calling GetSequenceAudioUnit and native_midi_setvolume — this needs to be the other way round. We can safely move these around since we have a valid AudioUnit in the graph after calling MusicPlayerPreroll.

Patch attached.
Comment 1 Ozkan Sezer 2020-11-22 08:37:59 UTC
This patch is in: https://hg.libsdl.org/SDL_mixer/rev/900ad643ac68
Thanks.