Skip to content

Commit

Permalink
native_midi_macosx: set volume before starting playing (bug #5356)
Browse files Browse the repository at this point in the history
From michaeljosephmaltese:

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.

https://bugzilla.libsdl.org/show_bug.cgi?id=5356
  • Loading branch information
sezero committed Nov 22, 2020
1 parent 7a4655e commit d7f7542
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/codecs/native_midi/native_midi_macosx.c
Expand Up @@ -237,15 +237,15 @@ void native_midi_start(NativeMidiSong *song, int loops)
currentsong->loops = loops;

MusicPlayerPreroll(song->player);
MusicPlayerSetTime(song->player, 0);
MusicPlayerStart(song->player);

GetSequenceAudioUnit(song->sequence, &song->audiounit);

vol = latched_volume;
latched_volume++; /* just make this not match. */
native_midi_setvolume(vol);

MusicPlayerSetTime(song->player, 0);
MusicPlayerStart(song->player);

Mix_LockAudio();
SDL_PauseAudio(0);
}
Expand Down

0 comments on commit d7f7542

Please sign in to comment.